mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Also deletes object files. Both of these things are only done on the build server (-PbuildServer flag). This will remove all test folders, which removes lots of copies of dependencies. This also fixes an issue where gtest exectubables were installed for cross builds, even though they should not have been.
161 lines
5.3 KiB
Groovy
161 lines
5.3 KiB
Groovy
def javaResourceFile = file("$buildDir/generated/java/edu/wpi/first/hal/FRCNetComm.java")
|
|
def cppResourceFile = file("$buildDir/generated/headers/hal/FRCUsageReporting.h")
|
|
|
|
def generateUsageReporting = tasks.register('generateUsageReporting') {
|
|
def javaBase = file('src/generate/FRCNetComm.java.in')
|
|
def cppBase = file('src/generate/FRCUsageReporting.h.in')
|
|
|
|
def instances = file('src/generate/Instances.txt')
|
|
def resourceType = file('src/generate/ResourceType.txt')
|
|
|
|
inputs.file(javaBase)
|
|
inputs.file(cppBase)
|
|
inputs.file(instances)
|
|
inputs.file(resourceType)
|
|
|
|
outputs.file(javaResourceFile)
|
|
outputs.file(cppResourceFile)
|
|
|
|
doLast {
|
|
def instanceTextJava = instances as String[]
|
|
def instanceTextCpp = instances as String[]
|
|
def resourceTextJava = resourceType as String[]
|
|
def resourceTextCpp = resourceType as String[]
|
|
|
|
instanceTextJava = instanceTextJava.collect {
|
|
" public static final int ${it};"
|
|
}.join('\n')
|
|
|
|
instanceTextCpp = instanceTextCpp.collect {
|
|
" ${it},"
|
|
}.join('\n')
|
|
|
|
resourceTextJava = resourceTextJava.collect {
|
|
" public static final int ${it};"
|
|
}.join('\n')
|
|
|
|
resourceTextCpp = resourceTextCpp.collect {
|
|
" ${it},"
|
|
}.join('\n')
|
|
|
|
javaResourceFile.text = javaBase.text.replace('${usage_reporting_types}', resourceTextJava).replace('${usage_reporting_instances}', instanceTextJava)
|
|
cppResourceFile.text = cppBase.text.replace('${usage_reporting_types_cpp}', resourceTextCpp).replace('${usage_reporting_instances_cpp}', instanceTextCpp)
|
|
}
|
|
}
|
|
|
|
ext {
|
|
addHalDependency = { binary, shared->
|
|
binary.tasks.withType(AbstractNativeSourceCompileTask) {
|
|
it.dependsOn generateUsageReporting
|
|
}
|
|
binary.lib project: ':hal', library: 'hal', linkage: shared
|
|
}
|
|
|
|
addHalJniDependency = { binary->
|
|
binary.tasks.withType(AbstractNativeSourceCompileTask) {
|
|
it.dependsOn generateUsageReporting
|
|
}
|
|
binary.lib project: ':hal', library: 'halJNIShared', linkage: 'shared'
|
|
}
|
|
|
|
nativeName = 'hal'
|
|
setBaseName = 'wpiHal'
|
|
devMain = 'edu.wpi.first.hal.DevMain'
|
|
niLibraries = true
|
|
generatedHeaders = "$buildDir/generated/headers"
|
|
jniSplitSetup = {
|
|
it.tasks.withType(AbstractNativeSourceCompileTask) {
|
|
it.dependsOn generateUsageReporting
|
|
}
|
|
}
|
|
splitSetup = {
|
|
it.tasks.withType(AbstractNativeSourceCompileTask) {
|
|
it.dependsOn generateUsageReporting
|
|
}
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
it.sources {
|
|
athenaCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs = ['src/main/native/athena']
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDir 'src/main/native/include'
|
|
srcDir generatedHeaders
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
it.sources {
|
|
simCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs 'src/main/native/sim'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDir 'src/main/native/include'
|
|
srcDir generatedHeaders
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
|
|
|
sourceSets.main.java.srcDir "${buildDir}/generated/java/"
|
|
|
|
compileJava {
|
|
dependsOn generateUsageReporting
|
|
}
|
|
|
|
cppSourcesZip {
|
|
from('src/main/native/athena') {
|
|
into '/athena'
|
|
}
|
|
|
|
from('src/main/native/sim') {
|
|
into '/sim'
|
|
}
|
|
}
|
|
|
|
cppHeadersZip {
|
|
dependsOn generateUsageReporting
|
|
from(generatedHeaders) {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
nativeUtils.exportsConfigs {
|
|
hal {
|
|
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']
|
|
}
|
|
halJNI {
|
|
x86SymbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('HAL_') && !it.startsWith('HALSIM_') })
|
|
}
|
|
x64SymbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('HAL_') && !it.startsWith('HALSIM_') })
|
|
}
|
|
}
|
|
}
|
|
|
|
model {
|
|
binaries {
|
|
all {
|
|
if (!(it instanceof NativeBinarySpec)) return
|
|
if (it.component.name != 'hal' && it.component.name != 'halBase') return
|
|
if (it.targetPlatform.name != nativeUtils.wpi.platforms.roborio) return
|
|
nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared')
|
|
}
|
|
}
|
|
}
|