1package(default_visibility = ["//tensorflow_lite_support:__subpackages__"]) 2 3licenses(["notice"]) # Apache 2.0 4 5# Helper target for exposing JNI headers across multiple platforms. 6cc_library( 7 name = "jni", 8 hdrs = select({ 9 # The Android toolchain makes "jni.h" available in the include path. 10 # For non-Android toolchains, generate jni.h and jni_md.h. 11 "//tensorflow_lite_support:android": [], 12 "//conditions:default": [ 13 ":jni.h", 14 ":jni_md.h", 15 ], 16 }), 17 includes = select({ 18 "//tensorflow_lite_support:android": [], 19 "//conditions:default": ["."], 20 }), 21 visibility = ["//visibility:public"], 22) 23 24# Silly rules to make 25# #include <jni.h> 26# in the source headers work 27# (in combination with the "includes" attribute of the tf_cuda_library rule 28# above. Not needed when using the Android toolchain). 29# 30# Inspired from: 31# https://github.com/bazelbuild/bazel/blob/f99a0543f8d97339d32075c7176b79f35be84606/src/main/native/BUILD 32# but hopefully there is a simpler alternative to this. 33genrule( 34 name = "copy_jni_h", 35 srcs = ["@bazel_tools//tools/jdk:jni_header"], 36 outs = ["jni.h"], 37 cmd = "cp -f $< $@", 38) 39 40genrule( 41 name = "copy_jni_md_h", 42 srcs = select({ 43 "//tensorflow_lite_support:macos": ["@bazel_tools//tools/jdk:jni_md_header-darwin"], 44 "//conditions:default": ["@bazel_tools//tools/jdk:jni_md_header-linux"], 45 }), 46 outs = ["jni_md.h"], 47 cmd = "cp -f $< $@", 48) 49