2017-08-18 21:35:53 -07:00
|
|
|
apply plugin: 'cpp'
|
2018-07-08 15:42:59 -07:00
|
|
|
apply plugin: 'c'
|
2018-04-29 13:29:07 -07:00
|
|
|
apply plugin: 'google-test-test-suite'
|
2017-08-18 21:35:53 -07:00
|
|
|
apply plugin: 'visual-studio'
|
2025-12-13 21:44:00 -08:00
|
|
|
apply plugin: 'org.wpilib.NativeUtils'
|
2018-04-29 13:29:07 -07:00
|
|
|
apply plugin: SingleNativeBuild
|
|
|
|
|
apply plugin: ExtraTasks
|
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
|
|
|
ext {
|
|
|
|
|
nativeName = 'wpilibc'
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
apply from: "${rootDir}/shared/config.gradle"
|
2016-10-20 23:54:04 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
def wpilibVersionFileInput = file("src/generate/WPILibVersion.cpp.in")
|
|
|
|
|
def wpilibVersionFileOutput = file("$buildDir/generated/cpp/WPILibVersion.cpp")
|
2016-10-20 23:54:04 -07:00
|
|
|
|
|
|
|
|
task generateCppVersion() {
|
|
|
|
|
description = 'Generates the wpilib version class'
|
|
|
|
|
group = 'WPILib'
|
|
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
outputs.file wpilibVersionFileOutput
|
|
|
|
|
inputs.file wpilibVersionFileInput
|
|
|
|
|
|
2019-08-22 21:48:43 -07:00
|
|
|
if (wpilibVersioning.releaseMode) {
|
2018-04-29 13:29:07 -07:00
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 23:54:04 -07:00
|
|
|
// We follow a simple set of checks to determine whether we should generate a new version file:
|
2019-03-10 18:40:16 -07:00
|
|
|
// 1. If the release type is not development, we generate a new version file
|
2016-10-20 23:54:04 -07:00
|
|
|
// 2. If there is no generated version number, we generate a new version file
|
|
|
|
|
// 3. If there is a generated build number, and the release type is development, then we will
|
|
|
|
|
// only generate if the publish task is run.
|
|
|
|
|
doLast {
|
2019-08-22 21:48:43 -07:00
|
|
|
def version = wpilibVersioning.version.get()
|
|
|
|
|
println "Writing version ${version} to $wpilibVersionFileOutput"
|
2016-10-20 23:54:04 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
if (wpilibVersionFileOutput.exists()) {
|
|
|
|
|
wpilibVersionFileOutput.delete()
|
2016-10-20 23:54:04 -07:00
|
|
|
}
|
2019-08-22 21:48:43 -07:00
|
|
|
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
|
2018-04-29 13:29:07 -07:00
|
|
|
wpilibVersionFileOutput.write(read)
|
2016-10-20 23:54:04 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
|
|
|
|
|
def willPublish = graph.hasTask(publish)
|
|
|
|
|
if (willPublish) {
|
|
|
|
|
generateCppVersion.outputs.upToDateWhen { false }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
project(':').libraryBuild.dependsOn build
|
|
|
|
|
|
2018-05-27 21:44:12 -07:00
|
|
|
ext {
|
|
|
|
|
staticGtestConfigs = [:]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staticGtestConfigs["${nativeName}Test"] = []
|
|
|
|
|
|
|
|
|
|
apply from: "${rootDir}/shared/googletest.gradle"
|
|
|
|
|
|
2019-06-28 14:09:10 -07:00
|
|
|
nativeUtils.exportsConfigs {
|
|
|
|
|
wpilibc {
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
2019-06-28 14:09:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model {
|
2017-08-18 21:35:53 -07:00
|
|
|
components {
|
2018-04-29 13:29:07 -07:00
|
|
|
"${nativeName}Base"(NativeLibrarySpec) {
|
2017-08-18 21:35:53 -07:00
|
|
|
sources {
|
|
|
|
|
cpp {
|
|
|
|
|
source {
|
2020-12-30 16:17:20 -08:00
|
|
|
srcDirs = [
|
2024-06-08 12:59:07 -04:00
|
|
|
'src/main/native/cpp',
|
|
|
|
|
'src/generated/main/native/cpp'
|
2020-12-30 16:17:20 -08:00
|
|
|
]
|
2018-04-29 13:29:07 -07:00
|
|
|
include '**/*.cpp'
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
2024-06-08 12:59:07 -04:00
|
|
|
srcDirs = [
|
|
|
|
|
'src/main/native/include',
|
|
|
|
|
'src/generated/main/native/include'
|
|
|
|
|
]
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
binaries.all {
|
|
|
|
|
if (it instanceof SharedLibraryBinarySpec) {
|
|
|
|
|
it.buildable = false
|
|
|
|
|
return
|
|
|
|
|
}
|
2022-11-14 20:19:00 -08:00
|
|
|
|
|
|
|
|
it.sources {
|
|
|
|
|
versionSources(CppSourceSet) {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs = [
|
|
|
|
|
"${rootDir}/shared/singlelib",
|
|
|
|
|
"$buildDir/generated/cpp"
|
|
|
|
|
]
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/native/include'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-27 08:37:30 -07:00
|
|
|
cppCompiler.define 'DYNAMIC_CAMERA_SERVER'
|
2022-10-08 10:01:31 -07:00
|
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
2018-09-19 21:57:58 -07:00
|
|
|
project(':hal').addHalDependency(it, 'shared')
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2018-04-29 13:29:07 -07:00
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
2020-08-06 23:57:39 -07:00
|
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
2025-02-19 23:08:17 -06:00
|
|
|
lib project: ':datalog', library: 'datalog', linkage: 'shared'
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
"${nativeName}"(NativeLibrarySpec) {
|
|
|
|
|
sources {
|
|
|
|
|
cpp {
|
|
|
|
|
source {
|
2019-10-27 08:37:30 -07:00
|
|
|
srcDirs "src/main/native/cppcs"
|
2018-04-29 13:29:07 -07:00
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
2024-06-08 12:59:07 -04:00
|
|
|
srcDirs 'src/main/native/include', 'src/generated/main/native/include', '../cameraserver/src/main/native/include'
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binaries.all {
|
2022-10-08 10:01:31 -07:00
|
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
2018-09-19 21:57:58 -07:00
|
|
|
project(':hal').addHalDependency(it, 'shared')
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2018-04-29 13:29:07 -07:00
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
2020-08-06 23:57:39 -07:00
|
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
2019-10-27 08:37:30 -07:00
|
|
|
|
|
|
|
|
if (it instanceof SharedLibraryBinarySpec) {
|
|
|
|
|
cppCompiler.define 'DYNAMIC_CAMERA_SERVER'
|
|
|
|
|
if (buildType == buildTypes.debug) {
|
|
|
|
|
cppCompiler.define 'DYNAMIC_CAMERA_SERVER_DEBUG'
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
|
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
2019-10-30 21:28:45 -07:00
|
|
|
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
|
2019-10-27 08:37:30 -07:00
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
2018-10-27 00:19:38 -07:00
|
|
|
appendDebugPathToBinaries(binaries)
|
2017-08-31 21:29:35 -07:00
|
|
|
}
|
2017-08-18 21:35:53 -07:00
|
|
|
// By default, a development executable will be generated. This is to help the case of
|
|
|
|
|
// testing specific functionality of the library.
|
2018-04-29 13:29:07 -07:00
|
|
|
"${nativeName}Dev"(NativeExecutableSpec) {
|
2018-10-27 00:19:38 -07:00
|
|
|
targetBuildTypes 'debug'
|
2018-04-29 13:29:07 -07:00
|
|
|
sources {
|
|
|
|
|
cpp {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs 'src/dev/native/cpp'
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
lib library: 'wpilibc'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/dev/native/include'
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
binaries.all {
|
2022-10-08 10:01:31 -07:00
|
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
2018-04-29 13:29:07 -07:00
|
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
2018-09-19 21:57:58 -07:00
|
|
|
project(':hal').addHalDependency(it, 'shared')
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2018-04-29 13:29:07 -07:00
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
2020-08-06 23:57:39 -07:00
|
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
2018-04-29 13:29:07 -07:00
|
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
2019-10-30 21:28:45 -07:00
|
|
|
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
testSuites {
|
2018-04-29 13:29:07 -07:00
|
|
|
"${nativeName}Test"(GoogleTestTestSuiteSpec) {
|
|
|
|
|
for(NativeComponentSpec c : $.components) {
|
|
|
|
|
if (c.name == nativeName) {
|
|
|
|
|
testing c
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sources {
|
|
|
|
|
cpp {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs 'src/test/native/cpp'
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/test/native/include', 'src/main/native/cpp'
|
|
|
|
|
}
|
2017-08-31 21:29:35 -07:00
|
|
|
}
|
2026-06-11 16:06:45 -07:00
|
|
|
generatedCpp(CppSourceSet) {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs 'src/generated/test/native/cpp'
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/test/native/include'
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-08 15:42:59 -07:00
|
|
|
c {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs 'src/test/native/c'
|
|
|
|
|
include '**/*.c'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/test/native/include', 'src/main/native/c'
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
2026-06-11 16:06:45 -07:00
|
|
|
it.sources.each {
|
|
|
|
|
it.exportedHeaders {
|
|
|
|
|
srcDirs 'src/test/native/include'
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binaries {
|
|
|
|
|
all {
|
|
|
|
|
tasks.withType(CppCompile) {
|
|
|
|
|
dependsOn generateCppVersion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
withType(GoogleTestTestSuiteBinarySpec) {
|
2022-10-08 10:01:31 -07:00
|
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
2019-06-29 09:27:11 -07:00
|
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
|
|
|
project(':hal').addHalDependency(it, 'shared')
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2019-06-29 09:27:11 -07:00
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
2020-08-06 23:57:39 -07:00
|
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
2019-06-29 09:27:11 -07:00
|
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
2019-10-30 21:28:45 -07:00
|
|
|
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
|
2019-06-29 09:27:11 -07:00
|
|
|
lib library: nativeName, linkage: 'shared'
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tasks {
|
2018-04-29 13:29:07 -07:00
|
|
|
def c = $.components
|
|
|
|
|
project.tasks.create('runCpp', Exec) {
|
2017-08-18 21:35:53 -07:00
|
|
|
def found = false
|
2018-04-29 13:29:07 -07:00
|
|
|
c.each {
|
|
|
|
|
if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") {
|
2017-08-18 21:35:53 -07:00
|
|
|
it.binaries.each {
|
|
|
|
|
if (!found) {
|
|
|
|
|
def arch = it.targetPlatform.architecture.name
|
|
|
|
|
if (arch == 'x86-64' || arch == 'x86') {
|
|
|
|
|
dependsOn it.tasks.install
|
2021-05-01 10:26:33 -07:00
|
|
|
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
|
2017-08-18 21:35:53 -07:00
|
|
|
found = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
2015-09-24 20:26:49 -04:00
|
|
|
|
2019-12-20 13:48:26 -08:00
|
|
|
apply from: "${rootDir}/shared/cppDesktopTestTask.gradle"
|
2017-08-18 21:35:53 -07:00
|
|
|
apply from: 'publish.gradle'
|
2018-04-29 13:29:07 -07:00
|
|
|
|
|
|
|
|
def oldWpilibVersionFile = file('src/main/native/cpp/WPILibVersion.cpp')
|
|
|
|
|
|
|
|
|
|
clean {
|
|
|
|
|
delete oldWpilibVersionFile
|
|
|
|
|
}
|