mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Currently the major DataLog backend API (reading and writing) is split between wpiutil and glass. In the interest of allowing code that wants to use these APIs to not need to link to glass and declutter wpiutil, all of those APIs are moved to a new library named "datalog". Signed-off-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
262 lines
9.3 KiB
Groovy
262 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"
|
|
|
|
nativeUtils.exportsConfigs {
|
|
wpilibc {
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
"${nativeName}Base"(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = [
|
|
'src/main/native/cpp',
|
|
'src/generated/main/native/cpp'
|
|
]
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = [
|
|
'src/main/native/include',
|
|
'src/generated/main/native/include'
|
|
]
|
|
}
|
|
}
|
|
}
|
|
binaries.all {
|
|
if (it instanceof SharedLibraryBinarySpec) {
|
|
it.buildable = false
|
|
return
|
|
}
|
|
|
|
it.sources {
|
|
versionSources(CppSourceSet) {
|
|
source {
|
|
srcDirs = [
|
|
"${rootDir}/shared/singlelib",
|
|
"$buildDir/generated/cpp"
|
|
]
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
|
|
cppCompiler.define 'DYNAMIC_CAMERA_SERVER'
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':datalog', library: 'datalog', linkage: 'shared'
|
|
}
|
|
}
|
|
"${nativeName}"(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs "src/main/native/cppcs"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include', 'src/generated/main/native/include', '../cameraserver/src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
binaries.all {
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: '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 {
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: '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')
|
|
}
|
|
}
|
|
}
|
|
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) {
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: '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'
|
|
}
|
|
}
|
|
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
|
|
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
|
|
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
|
|
}
|