Files
allwpilib/hal/build.gradle

235 lines
8.5 KiB
Groovy
Raw Normal View History

apply plugin: 'cpp'
apply plugin: 'google-test'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
apply from: '../config.gradle'
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
ext.addHalCompilerArguments = { binary->
if (binary.targetPlatform.architecture.name == 'athena') {
tasks.withType(CppCompile) {
binary.cppCompiler.args "-DCONFIG_ATHENA"
}
}
tasks.withType(CppCompile) {
binary.cppCompiler.args "-DNAMESPACED_PRIORITY"
}
}
2016-10-23 09:51:30 -07:00
ext.addHalToLinker = { binary->
if (binary.targetPlatform.architecture.name == 'athena') {
binary.lib project: ':hal', library: 'halAthena', linkage: 'shared'
} else {
binary.lib project: ':hal', library: 'halSim', linkage: 'shared'
}
}
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
model {
dependencyConfigs {
wpiutil(DependencyConfig) {
groupId = 'edu.wpi.first.wpiutil'
artifactId = 'wpiutil-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = '3.+'
sharedConfigs = [ halAthena: [], halSim: [], halDev: [], halSimTestingBaseTest: [] ]
staticConfigs = [ halSimStaticDeps: [] ]
}
}
// Exports config is a utility to enable exporting all symbols in a C++ library on windows to a DLL.
// This removes the need for DllExport on a library. However, the gradle C++ builder has a bug
// where some extra symbols are added that cannot be resolved at link time. This configuration
// lets you specify specific symbols to exlude from exporting.
exportsConfigs {
halSim(ExportsConfig) {
x86ExcludeSymbols = [ '_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
'_CT??_R0?AVbad_cast',
'_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
'_TI5?AVfailure' ]
x64ExcludeSymbols = [ '_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
'_CT??_R0?AVbad_cast',
'_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
'_TI5?AVfailure' ]
}
halSimStaticDeps(ExportsConfig) {
x86SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('HAL_')) {
retList << symbol
}
}
return retList
}
x64SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('HAL_')) {
retList << symbol
}
}
return retList
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
}
}
}
components {
if (!project.hasProperty('skipAthena')) {
halAthena(NativeLibrarySpec) {
baseName = 'wpiHal'
sources {
cpp {
source {
srcDirs = [ 'src/main/native/shared', 'src/main/native/athena' ]
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["src/main/native/include"]
}
}
}
binaries.all { binary->
if (binary.targetPlatform.architecture.name != 'athena') {
binary.buildable = false
}
}
}
}
if (!project.hasProperty('onlyAthena')) {
halSim(NativeLibrarySpec) {
baseName = 'wpiHal'
sources {
cpp {
source {
srcDirs = [ 'src/main/native/shared', 'src/main/native/sim' ]
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["src/main/native/include"]
}
}
}
binaries.all { binary ->
if (binary.targetPlatform.operatingSystem.linux) {
linker.args "-ldl"
}
}
}
if (project.hasProperty('buildHalStaticDeps')) {
halSimStaticDeps(NativeLibrarySpec) {
baseName = 'wpiHal'
binaries {
withType(StaticLibraryBinarySpec) {
buildable = false
}
}
sources {
cpp {
source {
srcDirs = [ 'src/main/native/shared', 'src/main/native/sim' ]
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["src/main/native/include"]
}
}
}
}
}
}
// The TestingBase library is a workaround for an issue with the GoogleTest plugin.
// The plugin by default will rebuild the entire test source set, which increases
// build time. By testing an empty library, and then just linking the already built component
// into the test, we save the extra build
halSimTestingBase(NativeLibrarySpec) { }
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
if (!project.hasProperty('skipDevExe')) {
halDev(NativeExecutableSpec) {
binaries.all {
project.addHalToLinker(it)
}
sources {
cpp {
source {
srcDirs 'src/dev/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/dev/native/include'
}
}
}
}
}
}
testSuites {
halSimTestingBaseTest {
sources {
cpp.source.srcDir 'src/test/native/cpp'
cpp.exportedHeaders.srcDir 'src/test/native/include'
}
}
}
binaries {
all {
project.addHalCompilerArguments(it)
project(':ni-libraries').addNiLibrariesToLinker(it)
}
withType(GoogleTestTestSuiteBinarySpec) {
if (it.component.testedComponent.name.contains('TestingBase') && !project.hasProperty('onlyAthena')) {
project(':gmock').addGmockToLinker(it)
project.addHalToLinker(it)
} else {
it.buildable = false
}
}
}
tasks {
runCpp(Exec) {
def found = false
$.components.each {
if (it in NativeExecutableSpec && it.name == 'halDev') {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.architecture.name
if (arch == 'x86-64' || arch == 'x86') {
dependsOn it.tasks.install
commandLine it.tasks.install.runScript
found = true
}
}
}
}
}
}
getHeaders(Task) {
def list = []
$.components.each {
if (it in NativeLibrarySpec && (it.name == 'halAthena' || it.name == 'halSim')) {
it.sources.each {
it.exportedHeaders.srcDirs.each {
list.add(it)
}
}
it.binaries.each {
it.libs.each {
it.includeRoots.each {
list.add(it)
}
}
}
}
}
list = list.unique(false)
doLast {
list.each {
print "WPIHEADER: "
println it
}
}
}
}
}
apply from: 'publish.gradle'