mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
The wpimath library is a new library designed to separate the reusable math functionality from the common utility library (wpiutil) and the hardware-dependent library (wpilibc/j). Package names / include file names were NOT changed to minimize breakage. In a future year it would be good to revamp these for a more uniform user experience and to reduce the risk of accidental naming conflicts. While theoretically all of this functionality could be placed into wpiutil, several pieces of this library (e.g. DARE) are very time-consuming to compile, so it's nice to avoid this expense for users who only want cscore or ntcore. It also allows for easy future separation of build tasks vs number of workers on memory-constrained machines. This moves the following functionality from wpiutil into wpimath: - Eigen - ejml - Drake - DARE - wpiutil.math package (Matrix etc) - units And the following functionality from wpilibc/j into wpimath: - Geometry - Kinematics - Spline - Trajectory - LinearFilter - MedianFilter - Feed-forward controllers
252 lines
9.3 KiB
Groovy
252 lines
9.3 KiB
Groovy
apply plugin: 'cpp'
|
|
apply plugin: 'c'
|
|
apply plugin: 'google-test-test-suite'
|
|
apply plugin: 'visual-studio'
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
|
apply plugin: SingleNativeBuild
|
|
apply plugin: ExtraTasks
|
|
|
|
ext {
|
|
nativeName = 'wpilibc'
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/config.gradle"
|
|
|
|
def wpilibVersionFileInput = file("src/generate/WPILibVersion.cpp.in")
|
|
def wpilibVersionFileOutput = file("$buildDir/generated/cpp/WPILibVersion.cpp")
|
|
|
|
task generateCppVersion() {
|
|
description = 'Generates the wpilib version class'
|
|
group = 'WPILib'
|
|
|
|
outputs.file wpilibVersionFileOutput
|
|
inputs.file wpilibVersionFileInput
|
|
|
|
if (wpilibVersioning.releaseMode) {
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
// We follow a simple set of checks to determine whether we should generate a new version file:
|
|
// 1. If the release type is not development, we generate a new version file
|
|
// 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 {
|
|
def version = wpilibVersioning.version.get()
|
|
println "Writing version ${version} to $wpilibVersionFileOutput"
|
|
|
|
if (wpilibVersionFileOutput.exists()) {
|
|
wpilibVersionFileOutput.delete()
|
|
}
|
|
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
|
|
wpilibVersionFileOutput.write(read)
|
|
}
|
|
}
|
|
|
|
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
|
|
def willPublish = graph.hasTask(publish)
|
|
if (willPublish) {
|
|
generateCppVersion.outputs.upToDateWhen { false }
|
|
}
|
|
}
|
|
|
|
project(':').libraryBuild.dependsOn build
|
|
|
|
ext {
|
|
staticGtestConfigs = [:]
|
|
}
|
|
|
|
staticGtestConfigs["${nativeName}Test"] = []
|
|
|
|
apply from: "${rootDir}/shared/googletest.gradle"
|
|
|
|
apply plugin: DisableBuildingGTest
|
|
|
|
nativeUtils.exportsConfigs {
|
|
wpilibc {
|
|
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']
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
"${nativeName}Base"(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = ['src/main/native/cpp', "$buildDir/generated/cpp"]
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
binaries.all {
|
|
if (it instanceof SharedLibraryBinarySpec) {
|
|
it.buildable = false
|
|
return
|
|
}
|
|
cppCompiler.define 'DYNAMIC_CAMERA_SERVER'
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
}
|
|
}
|
|
"${nativeName}"(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs "src/main/native/cppcs"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include', '../cameraserver/src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
binaries.all {
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
|
|
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'
|
|
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
|
|
}
|
|
|
|
}
|
|
appendDebugPathToBinaries(binaries)
|
|
}
|
|
// By default, a development executable will be generated. This is to help the case of
|
|
// testing specific functionality of the library.
|
|
"${nativeName}Dev"(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/dev/native/cpp'
|
|
include '**/*.cpp'
|
|
lib library: 'wpilibc'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/dev/native/include'
|
|
}
|
|
}
|
|
}
|
|
binaries.all {
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
testSuites {
|
|
"${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'
|
|
}
|
|
}
|
|
c {
|
|
source {
|
|
srcDirs 'src/test/native/c'
|
|
include '**/*.c'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/test/native/include', 'src/main/native/c'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
binaries {
|
|
all {
|
|
tasks.withType(CppCompile) {
|
|
dependsOn generateCppVersion
|
|
}
|
|
}
|
|
withType(GoogleTestTestSuiteBinarySpec) {
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
|
|
lib library: nativeName, linkage: 'shared'
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
|
}
|
|
}
|
|
}
|
|
tasks {
|
|
def c = $.components
|
|
project.tasks.create('runCpp', Exec) {
|
|
def found = false
|
|
c.each {
|
|
if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") {
|
|
it.binaries.each {
|
|
if (!found) {
|
|
def arch = it.targetPlatform.architecture.name
|
|
if (arch == 'x86-64' || arch == 'x86') {
|
|
dependsOn it.tasks.install
|
|
|
|
found = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/cppDesktopTestTask.gradle"
|
|
|
|
tasks.withType(RunTestExecutable) {
|
|
args "--gtest_output=xml:test_detail.xml"
|
|
outputs.dir outputDir
|
|
}
|
|
|
|
apply from: 'publish.gradle'
|
|
|
|
def oldWpilibVersionFile = file('src/main/native/cpp/WPILibVersion.cpp')
|
|
|
|
clean {
|
|
delete oldWpilibVersionFile
|
|
}
|