mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
This adds support for two serialization formats for complex data types: - Protobuf for complex objects with variable length internals that need forward and backward wire compatibility (lower speed, more flexible) - Raw struct (ByteBuffer-style) for fixed-length objects (higher speed, less flexible) Deserialization can be done either by creating a new object (for immutable objects) or overwriting the contents of an existing object (for mutable objects). Implementing classes should provide inner classes that implement the Protobuf or Struct interface (in Java) or specialize the wpi::Protobuf or wpi::Struct struct (in C++). It is possible for classes to implement both. If the class itself does not implement serialization, it's possible for third parties/users to provide an implementation instead. Uses the Google protobuf implementation for C++ and the QuickBuffers alternative protobuf implementation for Java.
194 lines
6.8 KiB
Groovy
194 lines
6.8 KiB
Groovy
apply plugin: 'cpp'
|
|
apply plugin: 'google-test-test-suite'
|
|
apply plugin: 'visual-studio'
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
|
apply plugin: SingleNativeBuild
|
|
apply plugin: ExtraTasks
|
|
|
|
apply from: "${rootDir}/shared/config.gradle"
|
|
|
|
ext {
|
|
baseId = nativeName
|
|
groupId = "edu.wpi.first.${nativeName}"
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/java/javacommon.gradle"
|
|
|
|
project(':').libraryBuild.dependsOn build
|
|
|
|
ext {
|
|
staticGtestConfigs = [:]
|
|
}
|
|
|
|
staticGtestConfigs["${nativeName}Test"] = []
|
|
|
|
apply from: "${rootDir}/shared/googletest.gradle"
|
|
|
|
model {
|
|
components {
|
|
"${nativeName}Base"(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/native/cpp', "$buildDir/generated/source/proto/main/cpp"
|
|
include '**/*.cpp', '**/*.cc'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include', "$buildDir/generated/source/proto/main/cpp"
|
|
}
|
|
}
|
|
}
|
|
binaries.all {
|
|
if (it instanceof SharedLibraryBinarySpec) {
|
|
it.buildable = false
|
|
return
|
|
}
|
|
it.tasks.withType(CppCompile) {
|
|
it.dependsOn generateProto
|
|
}
|
|
if (project.hasProperty('extraSetup')) {
|
|
extraSetup(it)
|
|
}
|
|
}
|
|
}
|
|
"${nativeName}"(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs "${rootDir}/shared/singlelib"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
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: nativeName
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/dev/native/include'
|
|
}
|
|
}
|
|
}
|
|
binaries.all {
|
|
lib library: nativeName, linkage: 'shared'
|
|
if (!project.hasProperty('noWpiutil')) {
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
|
|
}
|
|
}
|
|
if (project.hasProperty('exeSplitSetup')) {
|
|
exeSplitSetup(it)
|
|
}
|
|
}
|
|
}
|
|
"${nativeName}TestLib"(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/testlib/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/test/native/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
binaries {
|
|
withType(GoogleTestTestSuiteBinarySpec) {
|
|
lib library: nativeName, linkage: 'shared'
|
|
lib library: "${nativeName}TestLib", linkage: 'shared'
|
|
if (!project.hasProperty('noWpiutil')) {
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutilTestLib', linkage: 'shared'
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
|
|
}
|
|
}
|
|
if (project.hasProperty('exeSplitSetup')) {
|
|
exeSplitSetup(it)
|
|
}
|
|
}
|
|
}
|
|
tasks {
|
|
def c = $.components
|
|
project.tasks.create('runCpp', Exec) {
|
|
group = 'WPILib'
|
|
description = "Run the ${nativeName}Dev executable"
|
|
def found = false
|
|
def systemArch = getCurrentArch()
|
|
c.each {
|
|
if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") {
|
|
it.binaries.each {
|
|
if (!found) {
|
|
def arch = it.targetPlatform.name
|
|
if (arch == systemArch) {
|
|
dependsOn it.tasks.install
|
|
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
|
|
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
|
|
test.dependsOn it.tasks.install
|
|
test.systemProperty 'java.library.path', filePath
|
|
test.environment 'LD_LIBRARY_PATH', filePath
|
|
test.environment 'DYLD_LIBRARY_PATH', filePath
|
|
test.workingDir filePath
|
|
run.dependsOn it.tasks.install
|
|
run.systemProperty 'java.library.path', filePath
|
|
run.environment 'LD_LIBRARY_PATH', filePath
|
|
run.environment 'DYLD_LIBRARY_PATH', filePath
|
|
run.workingDir filePath
|
|
|
|
found = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/cppDesktopTestTask.gradle"
|
|
apply from: "${rootDir}/shared/javaDesktopTestTask.gradle"
|
|
|
|
tasks.withType(RunTestExecutable) {
|
|
args "--gtest_output=xml:test_detail.xml"
|
|
outputs.dir outputDir
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/javacpp/publish.gradle"
|