Partial fix for TFLite Java path on mac

PiperOrigin-RevId: 251685458
This commit is contained in:
Jared Duke 2019-06-05 11:41:53 -07:00 committed by TensorFlower Gardener
parent 338318d5bf
commit 8b5b49f7d2
3 changed files with 16 additions and 5 deletions

View File

@ -42,6 +42,7 @@ def tflite_copts():
return copts
EXPORTED_SYMBOLS = "//tensorflow/lite/java/src/main/native:exported_symbols.lds"
LINKER_SCRIPT = "//tensorflow/lite/java/src/main/native:version_script.lds"
def tflite_linkopts_unstripped():
@ -113,22 +114,28 @@ def tflite_jni_binary(
copts = tflite_copts(),
linkopts = tflite_jni_linkopts(),
linkscript = LINKER_SCRIPT,
exported_symbols = EXPORTED_SYMBOLS,
linkshared = 1,
linkstatic = 1,
testonly = 0,
deps = [],
srcs = []):
"""Builds a jni binary for TFLite."""
linkopts = linkopts + [
"-Wl,--version-script", # Export only jni functions & classes.
"$(location {})".format(linkscript),
]
linkopts = linkopts + select({
"//tensorflow:macos": [
"-Wl,-exported_symbols_list,$(location {})".format(exported_symbols),
],
"//tensorflow:windows": [],
"//conditions:default": [
"-Wl,--version-script,$(location {})".format(linkscript),
],
})
native.cc_binary(
name = name,
copts = copts,
linkshared = linkshared,
linkstatic = linkstatic,
deps = deps + [linkscript],
deps = deps + [linkscript, exported_symbols],
srcs = srcs,
linkopts = linkopts,
testonly = testonly,

View File

@ -66,6 +66,7 @@ cc_library(
exports_files(
[
"exported_symbols.lds",
"version_script.lds",
],
)

View File

@ -0,0 +1,3 @@
*Java_*
*JNI_OnLoad
*JNI_OnUnload