Files
allwpilib/hal/build.gradle

199 lines
6.5 KiB
Groovy
Raw Normal View History

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)
}
}
apply plugin: DisableBuildingGTest
2018-04-29 13:29:07 -07:00
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'
}
2018-04-29 13:29:07 -07:00
nativeName = 'hal'
setBaseName = 'wpiHal'
devMain = 'edu.wpi.first.hal.DevMain'
2018-04-29 13:29:07 -07:00
niLibraries = true
generatedHeaders = "$buildDir/generated/headers"
jniSplitSetup = {
it.tasks.withType(AbstractNativeSourceCompileTask) {
it.dependsOn generateUsageReporting
}
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.sources {
athenaJniCpp(CppSourceSet) {
source {
srcDirs = ["${rootDir}/shared/singlelib", "$buildDir/generated/cpp"]
include '**/*.cpp'
}
exportedHeaders {
srcDir 'src/main/native/include'
srcDir generatedHeaders
}
}
}
} else {
it.sources {
simJniCpp(CppSourceSet) {
source {
srcDirs 'src/main/native/sim'
include '**/jni/*.cpp'
}
exportedHeaders {
srcDir 'src/main/native/include'
srcDir generatedHeaders
}
}
}
}
}
2018-04-29 13:29:07 -07:00
splitSetup = {
it.tasks.withType(AbstractNativeSourceCompileTask) {
it.dependsOn generateUsageReporting
}
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
2018-04-29 13:29:07 -07:00
it.sources {
athenaCpp(CppSourceSet) {
source {
srcDirs = ['src/main/native/athena']
2018-04-29 13:29:07 -07:00
include '**/*.cpp'
exclude '**/jni/*.cpp'
2018-04-29 13:29:07 -07:00
}
exportedHeaders {
srcDir 'src/main/native/include'
srcDir generatedHeaders
2018-04-29 13:29:07 -07:00
}
}
}
} else {
it.sources {
simCpp(CppSourceSet) {
source {
srcDirs 'src/main/native/sim'
include '**/*.cpp'
exclude '**/jni/*.cpp'
2018-04-29 13:29:07 -07:00
}
exportedHeaders {
srcDir 'src/main/native/include'
srcDir generatedHeaders
2018-04-29 13:29:07 -07:00
}
}
}
}
}
}
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
apply from: 'simjni.gradle'
sourceSets.main.java.srcDir "${buildDir}/generated/java/"
compileJava {
dependsOn generateUsageReporting
}
2018-04-29 13:29:07 -07:00
cppSourcesZip {
from('src/main/native/athena') {
into '/athena'
}
from('src/main/native/sim') {
into '/sim'
}
Gradle Build This adds gradle support for building wpilibj and wpilibc. At this point, both of these libraries should be fully ready to go. Gradle should give us a number of improvements, including less dependencies for getting building up and running, and MUCH faster build times. I'm noticing significantly faster build times already compared to Maven, with neither system building the plugins. The changes here should be pretty straight forward. The basic command for gradle is './gradlew'. This is the gradle wrapper, and it will find and download the correct gradle executable for your system. There is no need to install anything yourself. To see every task available, run './gradlew tasks'. The important tasks for us are listed under the WPILib header when the tasks command is run. To generate unit test binaries, the fRCUserProgramExecutable command will create the C++ tester, and the wpilibjIntegrationTestJar command will create the Java tester. The Jenkins deploy scripts have been modified to know the difference between maven generated and gradle generated jars with an environment variable. Creating the eclipse plugins still requires Maven, but gradle will handle calling it correctly and generating the proper dependencies for it. Create the plugins by calling ./gradlew eclipsePlugins. Jenkins can now be modified to support the new build system. Unit tests are run with ./gradlew test. Generating the integration tests uses the above two commands, and then process proceeds exactly as it did before. For publishing documentation, a new task has been created, ./gradlew publishDocs, which handles putting the documentation where Jenkins expects for publishing. Change-Id: I9a260d391984f98ef9170993efe933e4026161dc
2015-05-05 09:54:14 -04:00
2018-04-29 13:29:07 -07:00
from("$buildDir/generated/cpp") {
into '/athena/jni'
}
2018-04-29 13:29:07 -07:00
dependsOn generateAthenaSimFiles
}
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_') })
}
}
}
2019-11-13 21:35:52 -08:00
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')
2019-11-13 21:35:52 -08:00
}
}
}