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/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..94895da0 --- /dev/null +++ b/procstart.gradle @@ -0,0 +1,68 @@ +import org.gradle.internal.os.OperatingSystem +import java.nio.file.Paths +import java.nio.file.Files +import java.nio.file.attribute.PosixFilePermission + +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') + } + } + 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 + } + + 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 +}