2018-05-04 17:54:56 -07:00
|
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
ext {
|
|
|
|
|
nativeName = 'cscore'
|
2025-11-07 20:00:38 -05:00
|
|
|
devMain = 'org.wpilib.cscore.DevMain'
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
|
|
|
|
|
2019-08-09 16:28:53 -07:00
|
|
|
// 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.
|
2022-12-25 07:36:00 -08:00
|
|
|
if (OperatingSystem.current().isMacOsX()) {
|
|
|
|
|
apply plugin: 'objective-cpp'
|
|
|
|
|
}
|
2018-05-14 19:34:26 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
|
|
|
|
|
2020-06-30 20:39:52 -07:00
|
|
|
model {
|
|
|
|
|
components {
|
|
|
|
|
cscoreJNICvStatic(JniNativeLibrarySpec) {
|
2020-07-03 21:53:56 -07:00
|
|
|
baseName = 'cscorejnicvstatic'
|
2020-06-30 20:39:52 -07:00
|
|
|
|
|
|
|
|
enableCheckTask true
|
|
|
|
|
javaCompileTasks << compileJava
|
2024-11-30 18:04:00 +00:00
|
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.systemcore)
|
2022-06-20 11:28:46 -07:00
|
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64)
|
2020-06-30 20:39:52 -07:00
|
|
|
|
|
|
|
|
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'
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2020-07-03 21:53:56 -07:00
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
}
|
2020-06-30 20:39:52 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-07 10:54:14 -07:00
|
|
|
binaries {
|
|
|
|
|
all {
|
|
|
|
|
if (!it.buildable || !(it instanceof NativeBinarySpec)) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-05-06 05:10:07 +00:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
2022-05-07 10:54:14 -07:00
|
|
|
}
|
|
|
|
|
}
|
2020-06-30 20:39:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
ext {
|
|
|
|
|
sharedCvConfigs = [cscore : [],
|
2020-12-30 16:17:20 -08:00
|
|
|
cscoreBase: [],
|
|
|
|
|
cscoreDev : [],
|
|
|
|
|
cscoreTest: [],
|
|
|
|
|
cscoreJNIShared: []]
|
2020-06-30 20:39:52 -07:00
|
|
|
staticCvConfigs = [cscoreJNI: [],
|
2020-12-30 16:17:20 -08:00
|
|
|
cscoreJNICvStatic: []]
|
2018-04-29 13:29:07 -07:00
|
|
|
useJava = true
|
|
|
|
|
useCpp = true
|
2020-06-30 20:39:52 -07:00
|
|
|
cvStaticBuild = true
|
2018-05-14 19:34:26 -07:00
|
|
|
splitSetup = {
|
2019-06-28 14:09:10 -07:00
|
|
|
if (it.targetPlatform.operatingSystem.isMacOsX()) {
|
2018-05-14 19:34:26 -07:00
|
|
|
it.sources {
|
2022-12-25 07:36:00 -08:00
|
|
|
macObjCpp(ObjectiveCppSourceSet) {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs = ['src/main/native/objcpp']
|
|
|
|
|
include '**/*.mm'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/native/include', 'src/main/native/cpp'
|
|
|
|
|
include '**/*.h'
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-23 22:59:47 -07:00
|
|
|
cscoreMacCpp(CppSourceSet) {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs 'src/main/native/osx'
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/native/include', 'src/main/native/cpp'
|
2018-11-17 23:16:35 -08:00
|
|
|
include '**/*.h'
|
2018-10-23 22:59:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-28 14:09:10 -07:00
|
|
|
} else if (it.targetPlatform.operatingSystem.isLinux()) {
|
2018-10-23 22:59:47 -07:00
|
|
|
it.sources {
|
|
|
|
|
cscoreLinuxCpp(CppSourceSet) {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs 'src/main/native/linux'
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/native/include', 'src/main/native/cpp'
|
2018-11-17 23:16:35 -08:00
|
|
|
include '**/*.h'
|
2018-10-23 22:59:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-28 14:09:10 -07:00
|
|
|
} else if (it.targetPlatform.operatingSystem.isWindows()) {
|
2018-10-23 22:59:47 -07:00
|
|
|
it.sources {
|
|
|
|
|
cscoreWindowsCpp(CppSourceSet) {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs 'src/main/native/windows'
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/native/include', 'src/main/native/cpp'
|
2018-11-17 23:16:35 -08:00
|
|
|
include '**/*.h'
|
2018-10-23 22:59:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
2018-05-14 19:34:26 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:51:50 -07:00
|
|
|
def examplesMap = [:];
|
|
|
|
|
|
2018-11-09 22:42:04 -08:00
|
|
|
File examplesTree = file("$projectDir/examples")
|
|
|
|
|
examplesTree.list(new FilenameFilter() {
|
2020-12-30 16:17:20 -08:00
|
|
|
@Override
|
|
|
|
|
public boolean accept(File current, String name) {
|
|
|
|
|
return new File(current, name).isDirectory();
|
|
|
|
|
}
|
|
|
|
|
}).each {
|
|
|
|
|
sharedCvConfigs.put(it, [])
|
|
|
|
|
examplesMap.put(it, [])
|
|
|
|
|
}
|
2018-05-04 16:51:50 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
|
|
2021-09-19 17:59:14 -07:00
|
|
|
Action<List<String>> symbolFilter = { symbols ->
|
|
|
|
|
symbols.removeIf({ !it.startsWith('CS_') })
|
|
|
|
|
} as Action<List<String>>;
|
|
|
|
|
|
2022-12-25 07:36:00 -08:00
|
|
|
run {
|
|
|
|
|
if (OperatingSystem.current().isMacOsX()) {
|
|
|
|
|
jvmArgs("-XstartOnFirstThread");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-28 14:09:10 -07:00
|
|
|
nativeUtils.exportsConfigs {
|
|
|
|
|
cscore {
|
|
|
|
|
}
|
|
|
|
|
cscoreJNI {
|
2021-09-19 17:59:14 -07:00
|
|
|
x64SymbolFilter = symbolFilter
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
2020-06-30 20:39:52 -07:00
|
|
|
cscoreJNICvStatic {
|
2021-09-19 17:59:14 -07:00
|
|
|
x64SymbolFilter = symbolFilter
|
2020-06-30 20:39:52 -07:00
|
|
|
}
|
2019-06-28 14:09:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model {
|
2018-05-04 16:51:50 -07:00
|
|
|
components {
|
|
|
|
|
examplesMap.each { key, value ->
|
2020-08-29 11:30:45 -07:00
|
|
|
if (key == "usbviewer") {
|
2024-11-30 18:04:00 +00:00
|
|
|
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxsystemcore')) {
|
2020-08-29 11:30:45 -07:00
|
|
|
"${key}"(NativeExecutableSpec) {
|
|
|
|
|
targetBuildTypes 'debug'
|
|
|
|
|
binaries.all {
|
|
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2020-08-29 11:30:45 -07:00
|
|
|
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
|
|
|
|
lib library: 'cscore', linkage: 'shared'
|
2024-12-23 22:05:06 -05:00
|
|
|
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
|
2025-01-13 11:23:54 -08:00
|
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
|
2020-08-29 11:30:45 -07:00
|
|
|
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'
|
2022-10-26 23:16:23 -07:00
|
|
|
if (it.targetPlatform.name.startsWith('linuxarm')) {
|
|
|
|
|
it.linker.args << '-lGL'
|
|
|
|
|
}
|
2020-08-29 11:30:45 -07:00
|
|
|
}
|
|
|
|
|
}
|
2023-09-27 21:45:25 -07:00
|
|
|
sources.cpp.source {
|
|
|
|
|
srcDirs 'examples/' + "${key}"
|
|
|
|
|
include '**/*.cpp'
|
2020-08-29 11:30:45 -07:00
|
|
|
}
|
|
|
|
|
}
|
2018-05-04 16:51:50 -07:00
|
|
|
}
|
2020-08-29 11:30:45 -07:00
|
|
|
} else {
|
|
|
|
|
"${key}"(NativeExecutableSpec) {
|
|
|
|
|
targetBuildTypes 'debug'
|
|
|
|
|
binaries.all {
|
|
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
2022-05-07 10:54:14 -07:00
|
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
2020-08-29 11:30:45 -07:00
|
|
|
lib library: 'cscore', linkage: 'shared'
|
|
|
|
|
}
|
2023-09-27 21:45:25 -07:00
|
|
|
sources.cpp.source {
|
|
|
|
|
srcDirs 'examples/' + "${key}"
|
|
|
|
|
include '**/*.cpp'
|
2018-05-04 16:51:50 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|