| import jaci.gradle.toolchains.* |
| import jaci.gradle.nativedeps.* |
| |
| plugins { |
| id 'java' |
| id 'application' |
| id 'cpp' |
| id 'visual-studio' |
| } |
| |
| apply plugin: 'edu.wpi.first.NativeUtils' |
| apply plugin: 'jaci.gradle.EmbeddedTools' |
| |
| apply from: '../shared/config.gradle' |
| |
| ext { |
| sharedCvConfigs = [myRobotCpp: []] |
| staticCvConfigs = [myRobotCppStatic: []] |
| useJava = true |
| useCpp = true |
| skipDev = true |
| } |
| |
| 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") |
| } |
| } |
| |
| artifact('jre', JREArtifact) { |
| jreDependency = 'edu.wpi.first.jdk:roborio-2020:11.0.4u10-2' |
| } |
| |
| 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('myRobotCppStatic') { |
| component = 'myRobotCppStatic' |
| targetPlatform = nativeUtils.wpi.platforms.roborio |
| buildType = 'debug' |
| |
| postdeploy << { ctx -> |
| ctx.execute('chmod +x myRobotCppStatic') |
| } |
| } |
| } |
| } |
| |
| tasks.register('deployJava') { |
| try { |
| dependsOn tasks.named('deployJreRoborio') |
| dependsOn tasks.named('deployMyRobotJavaRoborio') |
| dependsOn tasks.named('deployMyRobotCppLibrariesRoborio') |
| } catch (ignored) { |
| } |
| } |
| |
| tasks.register('deployShared') { |
| try { |
| dependsOn tasks.named('deployMyRobotCppLibrariesRoborio') |
| dependsOn tasks.named('deployMyRobotCppRoborio') |
| } catch (ignored) { |
| } |
| } |
| |
| tasks.register('deployStatic') { |
| try { |
| dependsOn tasks.named('deployMyRobotCppStaticRoborio') |
| } catch (ignored) { |
| } |
| } |
| |
| mainClassName = 'Main' |
| |
| apply plugin: 'com.github.johnrengelman.shadow' |
| |
| repositories { |
| mavenCentral() |
| } |
| |
| dependencies { |
| implementation project(':wpilibj') |
| implementation project(':hal') |
| implementation project(':wpiutil') |
| implementation project(':ntcore') |
| implementation project(':cscore') |
| implementation project(':cameraserver') |
| implementation project(':wpilibOldCommands') |
| implementation project(':wpilibNewCommands') |
| } |
| |
| model { |
| components { |
| myRobotCpp(NativeExecutableSpec) { |
| targetBuildTypes 'debug' |
| sources { |
| cpp { |
| source { |
| srcDirs = ['src/main/native/cpp'] |
| includes = ['**/*.cpp'] |
| } |
| exportedHeaders { |
| srcDirs = ['src/main/native/include'] |
| includes = ['**/*.h'] |
| } |
| } |
| } |
| binaries.all { binary -> |
| lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared' |
| lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared' |
| lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' |
| lib project: ':ntcore', library: 'ntcore', linkage: 'shared' |
| lib project: ':cscore', library: 'cscore', linkage: 'shared' |
| lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared' |
| lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared' |
| project(':hal').addHalDependency(binary, 'shared') |
| project(':hal').addHalJniDependency(binary) |
| lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
| lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' |
| if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
| nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared') |
| } |
| } |
| } |
| myRobotCppStatic(NativeExecutableSpec) { |
| targetBuildTypes 'debug' |
| nativeUtils.excludeBinariesFromStrip(it) |
| sources { |
| cpp { |
| source { |
| srcDirs = ['src/main/native/cpp'] |
| includes = ['**/*.cpp'] |
| } |
| exportedHeaders { |
| srcDirs = ['src/main/native/include'] |
| includes = ['**/*.h'] |
| } |
| } |
| } |
| binaries.all { binary -> |
| lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'static' |
| lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'static' |
| lib project: ':wpilibc', library: 'wpilibc', linkage: 'static' |
| lib project: ':ntcore', library: 'ntcore', linkage: 'static' |
| lib project: ':cscore', library: 'cscore', linkage: 'static' |
| project(':hal').addHalDependency(binary, 'static') |
| lib project: ':wpiutil', library: 'wpiutil', linkage: 'static' |
| lib project: ':cameraserver', library: 'cameraserver', linkage: 'static' |
| if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
| nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared') |
| } |
| } |
| } |
| } |
| tasks { |
| def c = $.components |
| project.tasks.create('runCpp', Exec) { |
| group = 'WPILib' |
| description = "Run the myRobotCpp executable" |
| def found = false |
| def systemArch = getCurrentArch() |
| c.each { |
| if (it in NativeExecutableSpec && it.name == "myRobotCpp") { |
| it.binaries.each { |
| if (!found) { |
| def arch = it.targetPlatform.name |
| if (arch == systemArch) { |
| dependsOn it.tasks.install |
| commandLine it.tasks.install.runScriptFile.get().asFile.toString() |
| def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib' |
| run.dependsOn it.tasks.install |
| run.systemProperty 'java.library.path', filePath |
| run.environment 'LD_LIBRARY_PATH', filePath |
| run.workingDir filePath |
| |
| found = true |
| } |
| } |
| } |
| } |
| } |
| } |
| installAthena(Task) { |
| $.binaries.each { |
| if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCpp') { |
| dependsOn it.tasks.install |
| } |
| } |
| } |
| installAthenaStatic(Task) { |
| $.binaries.each { |
| if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCppStatic') { |
| dependsOn it.tasks.install |
| } |
| } |
| } |
| } |
| } |