From bf5388393e5896ab5979d63f28501fc195e8071a Mon Sep 17 00:00:00 2001 From: Thad House Date: Wed, 13 Nov 2019 22:45:19 -0800 Subject: [PATCH] Add deploy options to myRobot (#2079) Will only deploy to USB by default, and will not deploy the JRE, but will deploy a Java app. --- buildSrc/build.gradle | 2 +- myRobot/build.gradle | 110 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 105 insertions(+), 7 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index c3674f45fd..8069df0125 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -5,5 +5,5 @@ repositories { } } dependencies { - implementation "edu.wpi.first:native-utils:2020.5.1" + implementation "edu.wpi.first:native-utils:2020.5.2" } diff --git a/myRobot/build.gradle b/myRobot/build.gradle index 2385690408..a1f9a92a30 100644 --- a/myRobot/build.gradle +++ b/myRobot/build.gradle @@ -1,3 +1,6 @@ +import jaci.gradle.toolchains.* +import jaci.gradle.nativedeps.* + plugins { id 'java' id 'application' @@ -6,6 +9,7 @@ plugins { } apply plugin: 'edu.wpi.first.NativeUtils' +apply plugin: 'jaci.gradle.EmbeddedTools' apply from: '../shared/config.gradle' @@ -19,6 +23,106 @@ ext { apply from: "${rootDir}/shared/opencv.gradle" +deploy { + targets { + target('roborio') { + directory = '/home/admin' + maxChannels = 4 + locations { + ssh { + address = "172.22.11.2" + user = 'admin' + password = '' + ipv6 = false + } + } + } + } + artifacts { + all { + targets << 'roborio' + predeploy << { ctx -> + ctx.execute('/usr/local/frc/bin/frcKillRobot.sh -t') + } + postdeploy << { ctx -> + ctx.execute("sync") + ctx.execute("ldconfig") + } + } + + javaArtifact('myRobotJava') { + jar = 'shadowJar' + postdeploy << { ctx -> + ctx.execute("echo '/usr/local/frc/JRE/bin/java -XX:+UseConcMarkSweepGC -Djava.library.path=/usr/local/frc/third-party/lib -Djava.lang.invoke.stringConcat=BC_SB -jar /home/admin/myRobot-all.jar' > /home/admin/myRobotJavaRun") + ctx.execute("chmod +x /home/admin/myRobotJavaRun; chown lvuser /home/admin/myRobotJavaRun") + } + } + + nativeArtifact('myRobotCpp') { + component = 'myRobotCpp' + targetPlatform = nativeUtils.wpi.platforms.roborio + libraryDirectory = '/usr/local/frc/third-party/lib' + buildType = 'debug' + postdeploy << { ctx -> + ctx.execute('chmod +x myRobotCpp') + } + + } + + nativeArtifact('myRobotCppRelease') { + component = 'myRobotCpp' + targetPlatform = nativeUtils.wpi.platforms.roborio + libraryDirectory = '/usr/local/frc/third-party/lib' + buildType = 'release' + postdeploy << { ctx -> + ctx.execute('chmod +x myRobotCpp') + } + } + + nativeArtifact('myRobotCppStatic') { + component = 'myRobotCppStatic' + targetPlatform = nativeUtils.wpi.platforms.roborio + buildType = 'debug' + + postdeploy << { ctx -> + ctx.execute('chmod +x myRobotCppStatic') + } + } + + nativeArtifact('myRobotCppStaticRelease') { + component = 'myRobotCppStatic' + targetPlatform = nativeUtils.wpi.platforms.roborio + buildType = 'release' + postdeploy << { ctx -> + ctx.execute('chmod +x myRobotCppStatic') + } + } + } +} + +tasks.register('deployJava') { + dependsOn tasks.named('deployMyRobotJavaRoborio') + dependsOn tasks.named('deployMyRobotCppLibrariesRoborio') +} + +tasks.register('deployShared') { + dependsOn tasks.named('deployMyRobotCppLibrariesRoborio') + dependsOn tasks.named('deployMyRobotCppRoborio') +} + +tasks.register('deployStatic') { + dependsOn tasks.named('deployMyRobotCppStaticRoborio') +} + +tasks.register('deployReleaseShared') { + dependsOn tasks.named('deployMyRobotCppReleaseLibrariesRoborio') + dependsOn tasks.named('deployMyRobotCppReleaseRoborio') +} + +tasks.register('deployReleaseStatic') { + dependsOn tasks.named('deployMyRobotCppReleaseStaticRoborio') +} + mainClassName = 'Main' apply plugin: 'com.github.johnrengelman.shadow' @@ -38,15 +142,10 @@ dependencies { implementation project(':wpilibNewCommands') } -jar { - manifest { attributes 'Robot-Class': 'MyRobot' } -} - model { components { myRobotCpp(NativeExecutableSpec) { targetBuildTypes 'debug' - baseName = 'FRCUserProgram' sources { cpp { source { @@ -78,7 +177,6 @@ model { } myRobotCppStatic(NativeExecutableSpec) { targetBuildTypes 'debug' - baseName = 'FRCUserProgram' sources { cpp { source {