mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Putting an early exit if statement at the top instead of wrapping the whole file contents unbreaks unit test configs, as was discovered for SysId. It reduces nesting as well. Unused plugins were removed from the beginnings of files as well.
248 lines
9.1 KiB
Groovy
248 lines
9.1 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
|
|
ext {
|
|
nativeName = 'cscore'
|
|
devMain = 'edu.wpi.first.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.linuxarm32)
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64)
|
|
|
|
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
|
|
}
|
|
if (it.component.name == "${nativeName}JNI") {
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
|
} else {
|
|
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', 'src/main/native/cpp'
|
|
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>>;
|
|
|
|
run {
|
|
if (OperatingSystem.current().isMacOsX()) {
|
|
jvmArgs("-XstartOnFirstThread");
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/imgui.gradle"
|
|
|
|
model {
|
|
components {
|
|
examplesMap.each { key, value ->
|
|
if (key == "usbviewer") {
|
|
if (!project.hasProperty('onlylinuxathena')) {
|
|
"${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')
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
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'
|
|
if (it.targetPlatform.name.startsWith('linuxarm')) {
|
|
it.linker.args << '-lGL'
|
|
}
|
|
}
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
|
|
}
|
|
}
|
|
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'
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
|
|
}
|
|
}
|
|
sources.cpp.source {
|
|
srcDirs 'examples/' + "${key}"
|
|
include '**/*.cpp'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|