import org.gradle.internal.os.OperatingSystem ext { nativeName = 'cscore' devMain = 'org.wpilib.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.systemcore) 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 } 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> symbolFilter = { symbols -> symbols.removeIf({ !it.startsWith('CS_') }) } as Action>; run { if (OperatingSystem.current().isMacOsX()) { jvmArgs("-XstartOnFirstThread"); } } nativeUtils.exportsConfigs { cscore { } cscoreJNI { x64SymbolFilter = symbolFilter } cscoreJNICvStatic { x64SymbolFilter = symbolFilter } } model { components { examplesMap.each { key, value -> if (key == "usbviewer") { if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxsystemcore')) { "${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' lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static' if (it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) { 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' } } } 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' } } } } } }