mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Adds spotless formatting for Gradle, xml, md, and gitignore files. yml linting is not performed as it requires a dependency on npm.
283 lines
10 KiB
Groovy
283 lines
10 KiB
Groovy
import jaci.gradle.toolchains.*
|
|
import jaci.gradle.nativedeps.*
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
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'
|
|
|
|
application {
|
|
if (OperatingSystem.current().isMacOsX()) {
|
|
applicationDefaultJvmArgs = ['-XstartOnFirstThread']
|
|
}
|
|
}
|
|
|
|
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 = 'frc.robot.Main'
|
|
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
implementation project(':wpilibj')
|
|
implementation project(':wpimath')
|
|
implementation project(':hal')
|
|
implementation project(':wpiutil')
|
|
implementation project(':ntcore')
|
|
implementation project(':cscore')
|
|
implementation project(':cameraserver')
|
|
implementation project(':wpilibOldCommands')
|
|
implementation project(':wpilibNewCommands')
|
|
}
|
|
|
|
def simProjects = ['halsim_gui']
|
|
|
|
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: ':wpimath', library: 'wpimath', 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')
|
|
} else {
|
|
def systemArch = getCurrentArch()
|
|
if (binary.targetPlatform.name == systemArch) {
|
|
simProjects.each {
|
|
lib project: ":simulation:$it", library: it, linkage: '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: ':wpimath', library: 'wpimath', 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()
|
|
def runTask = it
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|