From f4b0cf1cffe3f38dc7c43c0b65e502074733d33d Mon Sep 17 00:00:00 2001 From: Jiuqiang Tang Date: Mon, 6 Feb 2023 11:45:55 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 507540898 --- mediapipe/tasks/java/BUILD | 4 ++++ .../com/google/mediapipe/tasks/audio/BUILD | 5 ++++ .../com/google/mediapipe/tasks/text/BUILD | 5 ++++ .../com/google/mediapipe/tasks/vision/BUILD | 5 ++++ mediapipe/tasks/java/version_script.lds | 24 +++++++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 mediapipe/tasks/java/version_script.lds diff --git a/mediapipe/tasks/java/BUILD b/mediapipe/tasks/java/BUILD index 7e6283261..13a319bb7 100644 --- a/mediapipe/tasks/java/BUILD +++ b/mediapipe/tasks/java/BUILD @@ -13,3 +13,7 @@ # limitations under the License. licenses(["notice"]) + +exports_files([ + "version_script.lds", +]) diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/audio/BUILD b/mediapipe/tasks/java/com/google/mediapipe/tasks/audio/BUILD index e5d472e8a..50ee56f66 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/audio/BUILD +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/audio/BUILD @@ -34,12 +34,17 @@ android_library( # The native library of all MediaPipe audio tasks. cc_binary( name = "libmediapipe_tasks_audio_jni.so", + linkopts = [ + "-Wl,--no-undefined", + "-Wl,--version-script,$(location //mediapipe/tasks/java:version_script.lds)", + ], linkshared = 1, linkstatic = 1, deps = [ "//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni", "//mediapipe/tasks/cc/audio/audio_classifier:audio_classifier_graph", "//mediapipe/tasks/cc/audio/audio_embedder:audio_embedder_graph", + "//mediapipe/tasks/java:version_script.lds", "//mediapipe/tasks/java/com/google/mediapipe/tasks/core/jni:model_resources_cache_jni", ], ) diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/text/BUILD b/mediapipe/tasks/java/com/google/mediapipe/tasks/text/BUILD index 31cd2c89a..69bc2ab13 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/text/BUILD +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/text/BUILD @@ -19,12 +19,17 @@ package(default_visibility = ["//visibility:public"]) # The native library of all MediaPipe text tasks. cc_binary( name = "libmediapipe_tasks_text_jni.so", + linkopts = [ + "-Wl,--no-undefined", + "-Wl,--version-script,$(location //mediapipe/tasks/java:version_script.lds)", + ], linkshared = 1, linkstatic = 1, deps = [ "//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni", "//mediapipe/tasks/cc/text/text_classifier:text_classifier_graph", "//mediapipe/tasks/cc/text/text_embedder:text_embedder_graph", + "//mediapipe/tasks/java:version_script.lds", "//mediapipe/tasks/java/com/google/mediapipe/tasks/core/jni:model_resources_cache_jni", ], ) diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD index 0c30d7646..a0732495f 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD @@ -36,6 +36,10 @@ android_library( # The native library of all MediaPipe vision tasks. cc_binary( name = "libmediapipe_tasks_vision_jni.so", + linkopts = [ + "-Wl,--no-undefined", + "-Wl,--version-script,$(location //mediapipe/tasks/java:version_script.lds)", + ], linkshared = 1, linkstatic = 1, deps = [ @@ -46,6 +50,7 @@ cc_binary( "//mediapipe/tasks/cc/vision/image_embedder:image_embedder_graph", "//mediapipe/tasks/cc/vision/image_segmenter:image_segmenter_graph", "//mediapipe/tasks/cc/vision/object_detector:object_detector_graph", + "//mediapipe/tasks/java:version_script.lds", "//mediapipe/tasks/java/com/google/mediapipe/tasks/core/jni:model_resources_cache_jni", ], ) diff --git a/mediapipe/tasks/java/version_script.lds b/mediapipe/tasks/java/version_script.lds new file mode 100644 index 000000000..08577b101 --- /dev/null +++ b/mediapipe/tasks/java/version_script.lds @@ -0,0 +1,24 @@ +VERS_1.0 { + # Export JNI and native C symbols. + global: + Java_com_google_mediapipe_framework_AndroidAssetUtil*; + Java_com_google_mediapipe_framework_AndroidPacketCreator*; + Java_com_google_mediapipe_framework_Graph_nativeAddMultiStreamCallback; + Java_com_google_mediapipe_framework_Graph_nativeAddPacketToInputStream; + Java_com_google_mediapipe_framework_Graph_nativeCloseAllPacketSources; + Java_com_google_mediapipe_framework_Graph_nativeCreateGraph; + Java_com_google_mediapipe_framework_Graph_nativeLoadBinaryGraph*; + Java_com_google_mediapipe_framework_Graph_nativeMovePacketToInputStream; + Java_com_google_mediapipe_framework_Graph_nativeReleaseGraph; + Java_com_google_mediapipe_framework_Graph_nativeStartRunningGraph; + Java_com_google_mediapipe_framework_Graph_nativeWaitUntilGraphDone; + Java_com_google_mediapipe_framework_Graph_nativeWaitUntilGraphIdle; + Java_com_google_mediapipe_framework_PacketCreator*; + Java_com_google_mediapipe_framework_PacketGetter*; + Java_com_google_mediapipe_framework_Packet*; + Java_com_google_mediapipe_tasks_core_ModelResourcesCache*; + + # Hide everything else. + local: + *; +};