Files
allwpilib/myRobot/build.gradle
Peter Johnson 42993b15c6 [wpimath] Move math functionality into new wpimath library (#2629)
The wpimath library is a new library designed to separate the reusable math functionality
from the common utility library (wpiutil) and the hardware-dependent library (wpilibc/j).

Package names / include file names were NOT changed to minimize breakage.  In a future year
it would be good to revamp these for a more uniform user experience and to reduce the risk
of accidental naming conflicts.

While theoretically all of this functionality could be placed into wpiutil, several pieces
of this library (e.g. DARE) are very time-consuming to compile, so it's nice to avoid this
expense for users who only want cscore or ntcore.  It also allows for easy future separation
of build tasks vs number of workers on memory-constrained machines.

This moves the following functionality from wpiutil into wpimath:
- Eigen
- ejml
- Drake
- DARE
- wpiutil.math package (Matrix etc)
- units

And the following functionality from wpilibc/j into wpimath:
- Geometry
- Kinematics
- Spline
- Trajectory
- LinearFilter
- MedianFilter
- Feed-forward controllers
2020-08-06 23:57:39 -07:00

241 lines
8.7 KiB
Groovy

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 = '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')
}
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')
}
}
}
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()
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
}
}
}
}
}