mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
This also makes the Gradle build work with JDK 17. The extra JVM args in gradle.properties works around a bug with spotless and JDK 17: https://github.com/diffplug/spotless/issues/834 PMD.CloseResource was ignored because it's almost always a false positive, and there are many of them.
103 lines
2.7 KiB
Groovy
103 lines
2.7 KiB
Groovy
import com.hubspot.jinjava.Jinjava;
|
|
import com.hubspot.jinjava.JinjavaConfig;
|
|
|
|
ext {
|
|
useJava = true
|
|
useCpp = true
|
|
baseId = 'wpimath'
|
|
groupId = 'edu.wpi.first.wpimath'
|
|
|
|
nativeName = 'wpimath'
|
|
devMain = 'edu.wpi.first.math.DevMain'
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
|
|
|
cppHeadersZip {
|
|
from('src/main/native/eigeninclude') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
all {
|
|
it.sources.each {
|
|
it.exportedHeaders {
|
|
srcDirs 'src/main/native/include', 'src/main/native/eigeninclude'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
api "org.ejml:ejml-simple:0.41"
|
|
api "com.fasterxml.jackson.core:jackson-annotations:2.12.4"
|
|
api "com.fasterxml.jackson.core:jackson-core:2.12.4"
|
|
api "com.fasterxml.jackson.core:jackson-databind:2.12.4"
|
|
}
|
|
|
|
def wpilibNumberFileInput = file("src/generate/GenericNumber.java.jinja")
|
|
def natFileInput = file("src/generate/Nat.java.jinja")
|
|
def wpilibNumberFileOutputDir = file("$buildDir/generated/java/edu/wpi/first/math/numbers")
|
|
def wpilibNatFileOutput = file("$buildDir/generated/java/edu/wpi/first/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()
|
|
|
|
def config = new JinjavaConfig()
|
|
def jinjava = new Jinjava(config)
|
|
|
|
def template = wpilibNumberFileInput.text
|
|
|
|
for(i in 0..maxNum) {
|
|
def outputFile = new File(wpilibNumberFileOutputDir, "N${i}.java")
|
|
def replacements = new HashMap<String,?>()
|
|
replacements.put("num", i)
|
|
def output = jinjava.render(template, replacements)
|
|
outputFile.write(output)
|
|
}
|
|
}
|
|
}
|
|
|
|
task generateNat() {
|
|
description = "Generates Nat.java"
|
|
group = "WPILib"
|
|
inputs.file natFileInput
|
|
outputs.file wpilibNatFileOutput
|
|
dependsOn generateNumbers
|
|
|
|
doLast {
|
|
if(wpilibNatFileOutput.exists()) {
|
|
wpilibNatFileOutput.delete()
|
|
}
|
|
|
|
def config = new JinjavaConfig()
|
|
def jinjava = new Jinjava(config)
|
|
|
|
def template = natFileInput.text
|
|
|
|
def replacements = new HashMap<String,?>()
|
|
replacements.put("nums", 0..maxNum)
|
|
|
|
def output = jinjava.render(template, replacements)
|
|
wpilibNatFileOutput.write(output)
|
|
}
|
|
}
|
|
|
|
sourceSets.main.java.srcDir "${buildDir}/generated/java"
|
|
compileJava.dependsOn generateNumbers
|
|
compileJava.dependsOn generateNat
|