diff --git a/buildSrc/src/main/groovy/SingleNativeBuild.groovy b/buildSrc/src/main/groovy/SingleNativeBuild.groovy index 2b7e087b24..3dc6fb7bb7 100644 --- a/buildSrc/src/main/groovy/SingleNativeBuild.groovy +++ b/buildSrc/src/main/groovy/SingleNativeBuild.groovy @@ -79,7 +79,7 @@ class SingleNativeBuild implements Plugin { components.each { component -> if (component.name == "${nativeName}Base") { base = (NativeLibrarySpec) component - } else if (component.name == "${nativeName}" || component.name == "${nativeName}JNI") { + } else if (component.name == "${nativeName}" || component.name == "${nativeName}JNI" || component.name == "${nativeName}JNICvStatic") { subs << component } } diff --git a/cscore/build.gradle b/cscore/build.gradle index 383fe68be2..3366f9d72e 100644 --- a/cscore/build.gradle +++ b/cscore/build.gradle @@ -18,7 +18,7 @@ apply from: "${rootDir}/shared/jni/setupBuild.gradle" model { components { cscoreJNICvStatic(JniNativeLibrarySpec) { - baseName = 'cscore-jnicvstatic' + baseName = 'cscorejnicvstatic' enableCheckTask true javaCompileTasks << compileJava @@ -46,6 +46,13 @@ model { } lib library: "${nativeName}", linkage: 'static' 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() + } } } } diff --git a/cscore/src/main/native/LinuxSymbolScript.txt b/cscore/src/main/native/LinuxSymbolScript.txt new file mode 100644 index 0000000000..505808064c --- /dev/null +++ b/cscore/src/main/native/LinuxSymbolScript.txt @@ -0,0 +1,4 @@ +cscorejnicvstatic { + global: CS_*; JNI_*; Java_*; # explicitly list symbols to be exported + local: *; # hide everything else +}; diff --git a/cscore/src/main/native/MacSymbolScript.txt b/cscore/src/main/native/MacSymbolScript.txt new file mode 100644 index 0000000000..ecfe349d53 --- /dev/null +++ b/cscore/src/main/native/MacSymbolScript.txt @@ -0,0 +1,3 @@ +_CS_* +_JNI_* +_Java_*