[cscore] Limit jnicvstatic exports to only C and JNI symbols (#2565)

Reduces risk even more about accidentally interfering with OpenCV.
This commit is contained in:
Thad House
2020-07-03 21:53:56 -07:00
committed by GitHub
parent 2a0f79b90f
commit 6e4ee8da2b
4 changed files with 16 additions and 2 deletions

View File

@@ -79,7 +79,7 @@ class SingleNativeBuild implements Plugin<Project> {
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
}
}

View File

@@ -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()
}
}
}
}

View File

@@ -0,0 +1,4 @@
cscorejnicvstatic {
global: CS_*; JNI_*; Java_*; # explicitly list symbols to be exported
local: *; # hide everything else
};

View File

@@ -0,0 +1,3 @@
_CS_*
_JNI_*
_Java_*