From 9627b4a1b070caff75fc578945da4f3994f992f5 Mon Sep 17 00:00:00 2001 From: Thad House Date: Wed, 11 Jan 2023 21:23:08 -0800 Subject: [PATCH 1/2] Add extraction for custom process starter executable --- build.gradle | 2 ++ procstart.gradle | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 procstart.gradle diff --git a/build.gradle b/build.gradle index 5f948ac9..08a2852c 100644 --- a/build.gradle +++ b/build.gradle @@ -203,6 +203,8 @@ tasks.withType(Jar).configureEach { } } +apply from: 'procstart.gradle' + wrapper { gradleVersion = '7.5.1' } diff --git a/procstart.gradle b/procstart.gradle new file mode 100644 index 00000000..99559b86 --- /dev/null +++ b/procstart.gradle @@ -0,0 +1,52 @@ +import org.gradle.internal.os.OperatingSystem + +configurations { + processstarter +} + +def wpilibClassifier = wpilibTools.deps.platformMapper.wpilibClassifier +def wpilibVersion = wpilibTools.deps.wpilibVersion + +dependencies { + processstarter "edu.wpi.first.tools:processstarter:$wpilibVersion:$wpilibClassifier@zip" +} + +tasks.register("extractProcessStarterBinary", Sync) { + from(project.zipTree(configurations.processstarter.resolvedConfiguration.resolvedArtifacts.first().file)) { + exclude "LICENSE.md" + exclude "ThirdPartyNotices.txt" + eachFile { + def oldName = name + name = name.replace('processstarter', 'PathWeaver') + if (oldName != name) { + mode = 775 + } + } + } + into "$buildDir/procstarter" +} + +tasks.register("createProcessStarterBundle", Sync) { + if (OperatingSystem.current().isMacOsX()) { + + } else { + from extractProcessStarterBinary + } + + into ("$buildDir/bundle") +} + +tasks.register('createProcessStarterZip', Zip) { + from createProcessStarterBundle + + classifier = wpilibTools.deps.platformMapper.currentPlatform.platformName + archiveBaseName = "${rootProject.name}Launcher" + archiveVersion = "" + + destinationDirectory = project.file("$buildDir/bundleZip") +} + +copyAllOutputs.configure { + dependsOn createProcessStarterZip + from createProcessStarterZip +} From e0e7802b82afc9c81dd74101a756a680c8c2b6d0 Mon Sep 17 00:00:00 2001 From: Thad House Date: Wed, 11 Jan 2023 21:46:50 -0800 Subject: [PATCH 2/2] Add macos bundle --- Info.plist | 30 ++++++++++++++++++++++++++++++ procstart.gradle | 24 ++++++++++++++++++++---- 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 Info.plist diff --git a/Info.plist b/Info.plist new file mode 100644 index 00000000..e81889f9 --- /dev/null +++ b/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleName + PathWeaver + CFBundleExecutable + PathWeaver + CFBundleDisplayName + PathWeaver + CFBundleIdentifier + edu.wpi.first.tools.PathWeaver + CFBundlePackageType + APPL + CFBundleSupportedPlatforms + + MacOSX + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleShortVersionString + 2021 + CFBundleVersion + 2021 + LSMinimumSystemVersion + 10.11 + NSHighResolutionCapable + + + diff --git a/procstart.gradle b/procstart.gradle index 99559b86..94895da0 100644 --- a/procstart.gradle +++ b/procstart.gradle @@ -1,4 +1,7 @@ import org.gradle.internal.os.OperatingSystem +import java.nio.file.Paths +import java.nio.file.Files +import java.nio.file.attribute.PosixFilePermission configurations { processstarter @@ -18,17 +21,30 @@ tasks.register("extractProcessStarterBinary", Sync) { eachFile { def oldName = name name = name.replace('processstarter', 'PathWeaver') - if (oldName != name) { - mode = 775 - } } } into "$buildDir/procstarter" + + if (!OperatingSystem.current().isWindows()) { + doLast { + new File("$buildDir/procstarter").eachFileRecurse { def file -> + def path = Paths.get(file.absolutePath) + def perms = Files.getPosixFilePermissions(path) + perms << PosixFilePermission.OWNER_EXECUTE << PosixFilePermission.GROUP_EXECUTE << PosixFilePermission.OTHERS_EXECUTE + Files.setPosixFilePermissions(path, perms) + } + } + } } tasks.register("createProcessStarterBundle", Sync) { if (OperatingSystem.current().isMacOsX()) { - + from(extractProcessStarterBinary) { + into "/${rootProject.name}.app/Contents/MacOS" + } + from(project.file("Info.plist")) { + into "/${rootProject.name}.app/Contents" + } } else { from extractProcessStarterBinary }