mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
The tools plugin won't include them in the binary, but it will be easy to look them up if needed.
191 lines
6.5 KiB
Groovy
191 lines
6.5 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
|
|
ext {
|
|
nativeName = 'cscore'
|
|
devMain = 'edu.wpi.cscore.DevMain'
|
|
}
|
|
|
|
// Removed because having the objective-cpp plugin added breaks
|
|
// embedded tools and its toolchain check. It causes an obj-cpp
|
|
// source set to be added to all binaries, even cross binaries
|
|
// with no support.
|
|
// if (OperatingSystem.current().isMacOsX()) {
|
|
// apply plugin: 'objective-cpp'
|
|
// }
|
|
|
|
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
|
|
|
model {
|
|
components {
|
|
cscoreJNICvStatic(JniNativeLibrarySpec) {
|
|
baseName = 'cscorejnicvstatic'
|
|
|
|
enableCheckTask true
|
|
javaCompileTasks << compileJava
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio)
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.raspbian)
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.aarch64bionic)
|
|
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/native/cpp'
|
|
include '**/jni/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDir 'src/main/native/include'
|
|
include '**/*.h'
|
|
}
|
|
|
|
}
|
|
}
|
|
binaries.all {
|
|
if (it instanceof StaticLibraryBinarySpec) {
|
|
it.buildable = false
|
|
return
|
|
}
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
|
|
if (it.targetPlatform.operatingSystem.linux) {
|
|
it.linker.args '-Wl,--version-script=' + file('src/main/native/LinuxSymbolScript.txt')
|
|
} else if (it.targetPlatform.operatingSystem.macOsX) {
|
|
it.linker.args '-exported_symbols_list'
|
|
it.linker.args file('src/main/native/MacSymbolScript.txt').toString()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
ext {
|
|
sharedCvConfigs = [cscore : [],
|
|
cscoreBase: [],
|
|
cscoreDev : [],
|
|
cscoreTest: [],
|
|
cscoreJNIShared: []]
|
|
staticCvConfigs = [cscoreJNI: [],
|
|
cscoreJNICvStatic: []]
|
|
useJava = true
|
|
useCpp = true
|
|
cvStaticBuild = true
|
|
splitSetup = {
|
|
if (it.targetPlatform.operatingSystem.isMacOsX()) {
|
|
it.sources {
|
|
// macObjCpp(ObjectiveCppSourceSet) {
|
|
// source {
|
|
// srcDirs = ['src/main/native/objcpp']
|
|
// include '**/*.mm'
|
|
// }
|
|
// exportedHeaders {
|
|
// srcDirs 'src/main/native/include'
|
|
// include '**/*.h'
|
|
// }
|
|
// }
|
|
cscoreMacCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs 'src/main/native/osx'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include', 'src/main/native/cpp'
|
|
include '**/*.h'
|
|
}
|
|
}
|
|
}
|
|
} else if (it.targetPlatform.operatingSystem.isLinux()) {
|
|
it.sources {
|
|
cscoreLinuxCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs 'src/main/native/linux'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include', 'src/main/native/cpp'
|
|
include '**/*.h'
|
|
}
|
|
}
|
|
}
|
|
} else if (it.targetPlatform.operatingSystem.isWindows()) {
|
|
it.sources {
|
|
cscoreWindowsCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs 'src/main/native/windows'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include', 'src/main/native/cpp'
|
|
include '**/*.h'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def examplesMap = [:];
|
|
|
|
File examplesTree = file("$projectDir/examples")
|
|
examplesTree.list(new FilenameFilter() {
|
|
@Override
|
|
public boolean accept(File current, String name) {
|
|
return new File(current, name).isDirectory();
|
|
}
|
|
}).each {
|
|
sharedCvConfigs.put(it, [])
|
|
examplesMap.put(it, [])
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
nativeUtils.exportsConfigs {
|
|
cscore {
|
|
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']
|
|
}
|
|
cscoreJNI {
|
|
x86SymbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('CS_') })
|
|
}
|
|
x64SymbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('CS_') })
|
|
}
|
|
}
|
|
cscoreJNICvStatic {
|
|
x86SymbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('CS_') })
|
|
}
|
|
x64SymbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('CS_') })
|
|
}
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
examplesMap.each { key, value ->
|
|
"${key}"(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
binaries.all {
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib library: 'cscore', linkage: 'shared'
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'examples/' + "${key}"
|
|
include '**/*.cpp'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|