mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Also fixes the google compile-testing library to 0.23.0 (the latest available at time of writing) instead of a wildcard Jackson versions were inconsistent across projects; most were on 2.19.2, but the fields subproject was on 2.15.2. All projects are now on 2.19.2 for consistency
335 lines
13 KiB
Groovy
335 lines
13 KiB
Groovy
import org.wpilib.deployutils.deploy.target.RemoteTarget
|
|
import org.wpilib.deployutils.deploy.target.location.SshDeployLocation
|
|
import org.wpilib.deployutils.deploy.artifact.*
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
plugins {
|
|
id 'java'
|
|
id 'application'
|
|
id 'cpp'
|
|
id 'visual-studio'
|
|
}
|
|
|
|
apply plugin: 'org.wpilib.NativeUtils'
|
|
apply plugin: 'org.wpilib.DeployUtils'
|
|
|
|
apply from: "${rootDir}/shared/config.gradle"
|
|
|
|
application {
|
|
if (OperatingSystem.current().isMacOsX()) {
|
|
applicationDefaultJvmArgs = ['-XstartOnFirstThread']
|
|
}
|
|
}
|
|
|
|
ext {
|
|
sharedCvConfigs = [benchmarkCpp: []]
|
|
staticCvConfigs = [benchmarkCppStatic: []]
|
|
useJava = true
|
|
useCpp = true
|
|
skipDev = true
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
application {
|
|
mainClass = 'wpilib.robot.Main'
|
|
}
|
|
|
|
apply plugin: 'com.gradleup.shadow'
|
|
|
|
repositories {
|
|
maven {
|
|
url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation project(':apriltag')
|
|
implementation project(':cameraserver')
|
|
implementation project(':cscore')
|
|
implementation project(':epilogue-runtime')
|
|
implementation project(':hal')
|
|
implementation project(':ntcore')
|
|
implementation project(':wpilibj')
|
|
implementation project(':commandsv2')
|
|
implementation project(':wpimath')
|
|
implementation project(':wpinet')
|
|
implementation project(':wpiunits')
|
|
implementation project(':wpiutil')
|
|
annotationProcessor project(':epilogue-processor')
|
|
implementation libs.jmh.core
|
|
annotationProcessor libs.jmh.annotationprocessor
|
|
}
|
|
|
|
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
|
|
onlyIf { false }
|
|
}
|
|
|
|
deploy {
|
|
targets {
|
|
systemcore(RemoteTarget) {
|
|
directory = '/home/systemcore'
|
|
maxChannels = 4
|
|
locations {
|
|
mdns(SshDeployLocation) {
|
|
address = "robot.local"
|
|
user = 'systemcore'
|
|
password = 'systemcore'
|
|
ipv6 = false
|
|
}
|
|
usb(SshDeployLocation) {
|
|
address = "172.26.0.1"
|
|
user = 'systemcore'
|
|
password = 'systemcore'
|
|
ipv6 = false
|
|
}
|
|
}
|
|
|
|
timeout = 7
|
|
|
|
def remote = it
|
|
|
|
artifacts {
|
|
all {
|
|
postdeploy << { ctx ->
|
|
ctx.execute("sync")
|
|
ctx.execute("sudo ldconfig /home/systemcore/frc/third-party/lib")
|
|
}
|
|
}
|
|
|
|
benchmarkCpp(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/benchmarkCpp' > /home/lvuser/robotCommand")
|
|
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
|
|
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/benchmarkCpp\"")
|
|
ctx.execute('chmod +x benchmarkCpp')
|
|
}
|
|
}
|
|
|
|
benchmarkCppStatic(NativeExecutableArtifact) {
|
|
libraryDirectory = '/usr/local/frc/third-party/lib'
|
|
postdeploy << { ctx ->
|
|
ctx.execute("echo '/home/lvuser/benchmarkCppStatic' > /home/lvuser/robotCommand")
|
|
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
|
|
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/benchmarkCppStatic\"")
|
|
ctx.execute('chmod +x benchmarkCppStatic')
|
|
}
|
|
}
|
|
|
|
benchmarkCppJava(NativeExecutableArtifact) {
|
|
libraryDirectory = '/usr/local/frc/third-party/lib'
|
|
def excludes = getLibraryFilter().getExcludes()
|
|
excludes.add('**/*.so.debug')
|
|
excludes.add('**/*.so.*.debug')
|
|
}
|
|
|
|
benchmarkJava(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/benchmark-all.jar' > /home/lvuser/robotCommand")
|
|
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Prevent the eclipse compiler (used by the VS Code extension for intellisense and debugging)
|
|
// from generating bad class files from annotation processors like Epilogue
|
|
eclipse {
|
|
classpath {
|
|
containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
|
|
file.whenMerged { cp ->
|
|
def entries = cp.entries;
|
|
def src = new org.gradle.plugins.ide.eclipse.model.SourceFolder('build/generated/sources/annotationProcessor/java/main/', null)
|
|
entries.add(src)
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register('deployJava') {
|
|
try {
|
|
dependsOn tasks.named('deployjresystemcore')
|
|
dependsOn tasks.named('deploybenchmarkJavasystemcore')
|
|
dependsOn tasks.named('deploybenchmarkCppJavasystemcore') // Deploying shared C++ is how to get the Java shared libraries.
|
|
} catch (ignored) {
|
|
}
|
|
}
|
|
|
|
tasks.register('deployShared') {
|
|
try {
|
|
dependsOn tasks.named('deploybenchmarkCppsystemcore')
|
|
} catch (ignored) {
|
|
}
|
|
}
|
|
|
|
tasks.register('deployStatic') {
|
|
try {
|
|
dependsOn tasks.named('deploybenchmarkCppStaticsystemcore')
|
|
} catch (ignored) {
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
benchmarkCpp(NativeExecutableSpec) {
|
|
if (project.hasProperty('ciDebugOnly')) {
|
|
targetBuildTypes 'debug'
|
|
} else {
|
|
targetBuildTypes 'release'
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = [
|
|
'src/main/native/cpp',
|
|
'src/main/native/thirdparty/benchmark/src'
|
|
]
|
|
includes = ['**/*.cpp']
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = [
|
|
'src/main/native/include',
|
|
'src/main/native/thirdparty/benchmark/include',
|
|
'src/main/native/thirdparty/benchmark/src'
|
|
]
|
|
includes = ['**/*.h']
|
|
}
|
|
}
|
|
}
|
|
binaries.all { binary ->
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
|
|
if (binary.buildType.name == 'debug') {
|
|
deploy.targets.systemcore.artifacts.benchmarkCpp.binary = binary
|
|
deploy.targets.systemcore.artifacts.benchmarkCppJava.binary = binary
|
|
}
|
|
}
|
|
lib project: ':apriltag', library: 'apriltag', linkage: 'shared'
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
|
|
project(':hal').addHalDependency(binary, 'shared')
|
|
project(':hal').addHalJniDependency(binary)
|
|
project(':ntcore').addNtcoreDependency(binary, 'shared')
|
|
project(':ntcore').addNtcoreJniDependency(binary)
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
lib project: ':commandsv2', library: 'commandsv2', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimathJNIShared', linkage: 'shared'
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib project: ':wpinet', library: 'wpinetJNIShared', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutilJNIShared', linkage: 'shared'
|
|
if (binary.targetPlatform.operatingSystem.isWindows()) {
|
|
// Shlwapi.lib is needed for SHGetValueA() inside thirdparty benchmark
|
|
binary.linker.args << "Shlwapi.lib"
|
|
}
|
|
binary.cppCompiler.define 'benchmark_EXPORTS'
|
|
}
|
|
}
|
|
benchmarkCppStatic(NativeExecutableSpec) {
|
|
if (project.hasProperty('ciDebugOnly')) {
|
|
targetBuildTypes 'debug'
|
|
} else {
|
|
targetBuildTypes 'release'
|
|
}
|
|
nativeUtils.excludeBinariesFromStrip(it)
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = [
|
|
'src/main/native/cpp',
|
|
'src/main/native/thirdparty/benchmark/src'
|
|
]
|
|
includes = ['**/*.cpp']
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = [
|
|
'src/main/native/include',
|
|
'src/main/native/thirdparty/benchmark/include',
|
|
'src/main/native/thirdparty/benchmark/src'
|
|
]
|
|
includes = ['**/*.h']
|
|
}
|
|
}
|
|
}
|
|
binaries.all { binary ->
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
|
|
if (binary.buildType.name == 'debug') {
|
|
deploy.targets.systemcore.artifacts.benchmarkCppStatic.binary = binary
|
|
}
|
|
}
|
|
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'static'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'static'
|
|
project(':hal').addHalDependency(binary, 'static')
|
|
project(':ntcore').addNtcoreDependency(binary, 'static')
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
|
|
lib project: ':commandsv2', library: 'commandsv2', linkage: 'static'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
|
if (binary.targetPlatform.operatingSystem.isWindows()) {
|
|
// Shlwapi.lib is needed for SHGetValueA() inside thirdparty benchmark
|
|
binary.linker.args << "Shlwapi.lib"
|
|
}
|
|
binary.cppCompiler.define 'benchmark_EXPORTS'
|
|
binary.cppCompiler.define 'BENCHMARK_STATIC_DEFINE'
|
|
}
|
|
}
|
|
all {
|
|
it.sources.each {
|
|
it.exportedHeaders {
|
|
srcDirs 'src/main/native/thirdparty/benchmark/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
tasks {
|
|
def c = $.components
|
|
project.tasks.create('runCpp', Exec) {
|
|
group = 'WPILib'
|
|
description = "Run the benchmarkCpp executable"
|
|
def found = false
|
|
def systemArch = getCurrentArch()
|
|
c.each {
|
|
if (it in NativeExecutableSpec && it.name == "benchmarkCpp") {
|
|
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
|
|
|
|
found = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
installAthena(Task) {
|
|
$.binaries.each {
|
|
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore && it.component.name == 'benchmarkCpp') {
|
|
dependsOn it.tasks.install
|
|
}
|
|
}
|
|
}
|
|
installAthenaStatic(Task) {
|
|
$.binaries.each {
|
|
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore && it.component.name == 'benchmarkCppStatic') {
|
|
dependsOn it.tasks.install
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|