mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
235 lines
8.6 KiB
Groovy
235 lines
8.6 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'
|
|
lib project: ':wpinet', library: 'wpinet', 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()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
binaries {
|
|
all {
|
|
if (!it.buildable || !(it instanceof NativeBinarySpec)) {
|
|
return
|
|
}
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
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"
|
|
|
|
Action<List<String>> symbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('CS_') })
|
|
} as Action<List<String>>;
|
|
|
|
nativeUtils.exportsConfigs {
|
|
cscore {
|
|
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 {
|
|
x64SymbolFilter = symbolFilter
|
|
}
|
|
cscoreJNICvStatic {
|
|
x64SymbolFilter = symbolFilter
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
examplesMap.each { key, value ->
|
|
if (key == "usbviewer") {
|
|
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
|
|
"${key}"(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
binaries.all {
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
|
lib library: 'cscore', linkage: 'shared'
|
|
nativeUtils.useRequiredLibrary(it, 'imgui_static')
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
|
|
it.buildable = false
|
|
return
|
|
}
|
|
if (it.targetPlatform.operatingSystem.isWindows()) {
|
|
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
|
|
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
|
|
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
|
|
} else {
|
|
it.linker.args << '-lX11'
|
|
}
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'examples/' + "${key}"
|
|
include '**/*.cpp'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
"${key}"(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
binaries.all {
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib library: 'cscore', linkage: 'shared'
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'examples/' + "${key}"
|
|
include '**/*.cpp'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|