mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
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
104 lines
3.3 KiB
Groovy
104 lines
3.3 KiB
Groovy
ext {
|
|
useJava = true
|
|
useCpp = true
|
|
baseId = 'wpimath'
|
|
groupId = 'edu.wpi.first.wpimath'
|
|
|
|
nativeName = 'wpimath'
|
|
devMain = 'edu.wpi.first.wpiutil.math.DevMain'
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
|
|
|
nativeUtils.exportsConfigs {
|
|
wpimath {
|
|
x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
|
|
'_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
|
|
'_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range',
|
|
'_TI3?AVout_of_range', '_CT??_R0?AVbad_cast']
|
|
x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
|
|
'_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
|
|
'_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range',
|
|
'_TI3?AVout_of_range', '_CT??_R0?AVbad_cast']
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
all {
|
|
it.sources.each {
|
|
it.exportedHeaders {
|
|
srcDirs 'src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
api "org.ejml:ejml-simple:0.38"
|
|
api "com.fasterxml.jackson.core:jackson-annotations:2.10.0"
|
|
api "com.fasterxml.jackson.core:jackson-core:2.10.0"
|
|
api "com.fasterxml.jackson.core:jackson-databind:2.10.0"
|
|
}
|
|
|
|
def wpilibNumberFileInput = file("src/generate/GenericNumber.java.in")
|
|
def natFileInput = file("src/generate/Nat.java.in")
|
|
def natGetterInput = file("src/generate/NatGetter.java.in")
|
|
def wpilibNumberFileOutputDir = file("$buildDir/generated/java/edu/wpi/first/wpiutil/math/numbers")
|
|
def wpilibNatFileOutput = file("$buildDir/generated/java/edu/wpi/first/wpiutil/math/Nat.java")
|
|
def maxNum = 20
|
|
|
|
task generateNumbers() {
|
|
description = "Generates generic number classes from template"
|
|
group = "WPILib"
|
|
|
|
inputs.file wpilibNumberFileInput
|
|
outputs.dir wpilibNumberFileOutputDir
|
|
|
|
doLast {
|
|
if(wpilibNumberFileOutputDir.exists()) {
|
|
wpilibNumberFileOutputDir.delete()
|
|
}
|
|
wpilibNumberFileOutputDir.mkdirs()
|
|
|
|
for(i in 0..maxNum) {
|
|
def outputFile = new File(wpilibNumberFileOutputDir, "N${i}.java")
|
|
def read = wpilibNumberFileInput.text.replace('${num}', i.toString())
|
|
outputFile.write(read)
|
|
}
|
|
}
|
|
}
|
|
|
|
task generateNat() {
|
|
description = "Generates Nat.java"
|
|
group = "WPILib"
|
|
inputs.files([natFileInput, natGetterInput])
|
|
outputs.file wpilibNatFileOutput
|
|
dependsOn generateNumbers
|
|
|
|
doLast {
|
|
if(wpilibNatFileOutput.exists()) {
|
|
wpilibNatFileOutput.delete()
|
|
}
|
|
|
|
def template = natFileInput.text + "\n"
|
|
|
|
def importsString = "";
|
|
|
|
for(i in 0..maxNum) {
|
|
importsString += "import edu.wpi.first.wpiutil.math.numbers.N${i};\n"
|
|
template += natGetterInput.text.replace('${num}', i.toString()) + "\n"
|
|
}
|
|
template += "}\n" // Close the class body
|
|
|
|
template = template.replace('{{REPLACEWITHIMPORTS}}', importsString)
|
|
|
|
wpilibNatFileOutput.write(template)
|
|
}
|
|
}
|
|
|
|
sourceSets.main.java.srcDir "${buildDir}/generated/java"
|
|
compileJava.dependsOn generateNumbers
|
|
compileJava.dependsOn generateNat
|