mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
With fixes to Windows and macOS library path handling, all the tricks we used in the past to make library loading work are no longer required.
321 lines
13 KiB
Groovy
321 lines
13 KiB
Groovy
import edu.wpi.first.deployutils.deploy.target.RemoteTarget
|
|
import edu.wpi.first.deployutils.deploy.target.location.SshDeployLocation
|
|
import edu.wpi.first.deployutils.deploy.artifact.*
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
plugins {
|
|
id 'java'
|
|
id 'application'
|
|
id 'cpp'
|
|
id 'visual-studio'
|
|
}
|
|
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
|
apply plugin: 'edu.wpi.first.DeployUtils'
|
|
|
|
apply from: '../shared/config.gradle'
|
|
|
|
application {
|
|
if (OperatingSystem.current().isMacOsX()) {
|
|
applicationDefaultJvmArgs = ['-XstartOnFirstThread']
|
|
}
|
|
}
|
|
|
|
ext {
|
|
sharedCvConfigs = [developerRobotCpp: []]
|
|
staticCvConfigs = [developerRobotCppStatic: []]
|
|
useJava = true
|
|
useCpp = true
|
|
skipDev = true
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
application {
|
|
mainClass = 'frc.robot.Main'
|
|
}
|
|
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
|
|
repositories {
|
|
maven {
|
|
url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation project(':wpilibj')
|
|
implementation project(':wpimath')
|
|
implementation project(':hal')
|
|
implementation project(':wpiutil')
|
|
implementation project(':wpinet')
|
|
implementation project(':ntcore')
|
|
implementation project(':cscore')
|
|
implementation project(':cameraserver')
|
|
implementation project(':wpilibNewCommands')
|
|
implementation project(':apriltag')
|
|
}
|
|
|
|
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
|
|
onlyIf { false }
|
|
}
|
|
|
|
def simProjects = ['halsim_gui']
|
|
|
|
deploy {
|
|
targets {
|
|
roborio(RemoteTarget) {
|
|
directory = '/home/lvuser'
|
|
maxChannels = 4
|
|
locations {
|
|
ssh(SshDeployLocation) {
|
|
address = "172.22.11.2"
|
|
user = 'admin'
|
|
password = ''
|
|
ipv6 = false
|
|
}
|
|
}
|
|
|
|
def remote = it
|
|
|
|
artifacts.registerFactory(WPIJREArtifact) {
|
|
return objects.newInstance(WPIJREArtifact, it, remote)
|
|
}
|
|
|
|
artifacts {
|
|
all {
|
|
predeploy << { ctx ->
|
|
ctx.execute('. /etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t 2> /dev/null')
|
|
ctx.execute("sed -i -e 's/\"exec /\"/' /usr/local/frc/bin/frcRunRobot.sh")
|
|
}
|
|
postdeploy << { ctx ->
|
|
ctx.execute("sync")
|
|
ctx.execute("ldconfig")
|
|
}
|
|
}
|
|
|
|
developerRobotCpp(NativeExecutableArtifact) {
|
|
libraryDirectory = '/usr/local/frc/third-party/lib'
|
|
def excludes = getLibraryFilter().getExcludes()
|
|
excludes.add('**/*.so.debug')
|
|
excludes.add('**/*.so.*.debug')
|
|
postdeploy << { ctx ->
|
|
ctx.execute("echo '/home/lvuser/developerRobotCpp' > /home/lvuser/robotCommand")
|
|
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
|
|
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCpp\"")
|
|
ctx.execute('chmod +x developerRobotCpp')
|
|
}
|
|
}
|
|
|
|
developerRobotCppStatic(NativeExecutableArtifact) {
|
|
libraryDirectory = '/usr/local/frc/third-party/lib'
|
|
postdeploy << { ctx ->
|
|
ctx.execute("echo '/home/lvuser/developerRobotCppStatic' > /home/lvuser/robotCommand")
|
|
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
|
|
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCppStatic\"")
|
|
ctx.execute('chmod +x developerRobotCppStatic')
|
|
}
|
|
}
|
|
|
|
developerRobotCppJava(NativeExecutableArtifact) {
|
|
libraryDirectory = '/usr/local/frc/third-party/lib'
|
|
def excludes = getLibraryFilter().getExcludes()
|
|
excludes.add('**/*.so.debug')
|
|
excludes.add('**/*.so.*.debug')
|
|
}
|
|
|
|
jre(WPIJREArtifact) {
|
|
}
|
|
|
|
developerRobotJava(JavaArtifact) {
|
|
jarTask = shadowJar
|
|
postdeploy << { ctx ->
|
|
ctx.execute("echo '/usr/local/frc/JRE/bin/java -XX:+UseSerialGC -Djava.library.path=/usr/local/frc/third-party/lib -Djava.lang.invoke.stringConcat=BC_SB -jar /home/lvuser/developerRobot-all.jar' > /home/lvuser/robotCommand")
|
|
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register('deployJava') {
|
|
try {
|
|
dependsOn tasks.named('deployjreroborio')
|
|
dependsOn tasks.named('deploydeveloperRobotJavaroborio')
|
|
dependsOn tasks.named('deploydeveloperRobotCppJavaroborio') // Deploying shared C++ is how to get the Java shared libraries.
|
|
} catch (ignored) {
|
|
}
|
|
}
|
|
|
|
tasks.register('deployShared') {
|
|
try {
|
|
dependsOn tasks.named('deploydeveloperRobotCpproborio')
|
|
} catch (ignored) {
|
|
}
|
|
}
|
|
|
|
tasks.register('deployStatic') {
|
|
try {
|
|
dependsOn tasks.named('deploydeveloperRobotCppStaticroborio')
|
|
} catch (ignored) {
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
developerRobotCpp(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = ['src/main/native/cpp']
|
|
includes = ['**/*.cpp']
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ['src/main/native/include']
|
|
includes = ['**/*.h']
|
|
}
|
|
}
|
|
}
|
|
binaries.all { binary ->
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
if (binary.buildType.name == 'debug') {
|
|
deploy.targets.roborio.artifacts.developerRobotCpp.binary = binary
|
|
deploy.targets.roborio.artifacts.developerRobotCppJava.binary = binary
|
|
}
|
|
}
|
|
lib project: ':apriltag', library: 'apriltag', linkage: 'shared'
|
|
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
project(':ntcore').addNtcoreDependency(binary, 'shared')
|
|
project(':ntcore').addNtcoreJniDependency(binary)
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimathJNIShared', linkage: 'shared'
|
|
lib project: ':wpinet', library: 'wpinetJNIShared', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutilJNIShared', linkage: 'shared'
|
|
project(':hal').addHalDependency(binary, 'shared')
|
|
project(':hal').addHalJniDependency(binary)
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
|
|
} else {
|
|
def systemArch = getCurrentArch()
|
|
if (binary.targetPlatform.name == systemArch) {
|
|
simProjects.each {
|
|
lib project: ":simulation:$it", library: it, linkage: 'shared'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
developerRobotCppStatic(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 ->
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
if (binary.buildType.name == 'debug') {
|
|
deploy.targets.roborio.artifacts.developerRobotCppStatic.binary = binary
|
|
}
|
|
}
|
|
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
|
|
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'static'
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'static'
|
|
project(':ntcore').addNtcoreDependency(binary, 'static')
|
|
lib project: ':cscore', library: 'cscore', linkage: 'static'
|
|
project(':hal').addHalDependency(binary, 'static')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
tasks {
|
|
def c = $.components
|
|
project.tasks.create('runCpp', Exec) {
|
|
group = 'WPILib'
|
|
description = "Run the developerRobotCpp executable"
|
|
def found = false
|
|
def systemArch = getCurrentArch()
|
|
def runTask = it
|
|
c.each {
|
|
if (it in NativeExecutableSpec && it.name == "developerRobotCpp") {
|
|
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
|
|
|
|
def installTask = it.tasks.install
|
|
|
|
def doFirstTask = {
|
|
def extensions = '';
|
|
installTask.installDirectory.get().getAsFile().eachFileRecurse {
|
|
def name = it.name
|
|
if (!(name.endsWith('.dll') || name.endsWith('.so') || name.endsWith('.dylib'))) {
|
|
return
|
|
}
|
|
def file = it
|
|
simProjects.each {
|
|
if (name.startsWith(it) || name.startsWith("lib$it".toString())) {
|
|
extensions += file.absolutePath + File.pathSeparator
|
|
}
|
|
}
|
|
}
|
|
if (extensions != '') {
|
|
run.environment 'HALSIM_EXTENSIONS', extensions
|
|
runTask.environment 'HALSIM_EXTENSIONS', extensions
|
|
}
|
|
}
|
|
|
|
runTask.doFirst doFirstTask
|
|
run.doFirst doFirstTask
|
|
|
|
found = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
installAthena(Task) {
|
|
$.binaries.each {
|
|
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCpp') {
|
|
dependsOn it.tasks.install
|
|
}
|
|
}
|
|
}
|
|
installAthenaStatic(Task) {
|
|
$.binaries.each {
|
|
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCppStatic') {
|
|
dependsOn it.tasks.install
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|