xref: /aosp_15_r20/external/tflite-support/Android.bp (revision b16991f985baa50654c05c5adbb3c8bbcfb40082)
1*b16991f9SAndroid Build Coastguard Workerpackage {
2*b16991f9SAndroid Build Coastguard Worker    default_applicable_licenses: ["external_tflite-support_license"],
3*b16991f9SAndroid Build Coastguard Worker}
4*b16991f9SAndroid Build Coastguard Worker
5*b16991f9SAndroid Build Coastguard Worker// Added automatically by a large-scale-change that took the approach of
6*b16991f9SAndroid Build Coastguard Worker// 'apply every license found to every target'. While this makes sure we respect
7*b16991f9SAndroid Build Coastguard Worker// every license restriction, it may not be entirely correct.
8*b16991f9SAndroid Build Coastguard Worker//
9*b16991f9SAndroid Build Coastguard Worker// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10*b16991f9SAndroid Build Coastguard Worker//
11*b16991f9SAndroid Build Coastguard Worker// Please consider splitting the single license below into multiple licenses,
12*b16991f9SAndroid Build Coastguard Worker// taking care not to lose any license_kind information, and overriding the
13*b16991f9SAndroid Build Coastguard Worker// default license using the 'licenses: [...]' property on targets as needed.
14*b16991f9SAndroid Build Coastguard Worker//
15*b16991f9SAndroid Build Coastguard Worker// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16*b16991f9SAndroid Build Coastguard Worker// to attach the license to, and including a comment whether the files may be
17*b16991f9SAndroid Build Coastguard Worker// used in the current project.
18*b16991f9SAndroid Build Coastguard Worker// See: http://go/android-license-faq
19*b16991f9SAndroid Build Coastguard Worker
20*b16991f9SAndroid Build Coastguard Worker// TODO (ag/17748161): Split into smaller localized build files as necessary.
21*b16991f9SAndroid Build Coastguard Worker
22*b16991f9SAndroid Build Coastguard Workerlicense {
23*b16991f9SAndroid Build Coastguard Worker    name: "external_tflite-support_license",
24*b16991f9SAndroid Build Coastguard Worker    visibility: [":__subpackages__"],
25*b16991f9SAndroid Build Coastguard Worker    license_kinds: [
26*b16991f9SAndroid Build Coastguard Worker        "SPDX-license-identifier-Apache-2.0",
27*b16991f9SAndroid Build Coastguard Worker        "SPDX-license-identifier-BSD",
28*b16991f9SAndroid Build Coastguard Worker        "SPDX-license-identifier-MIT",
29*b16991f9SAndroid Build Coastguard Worker    ],
30*b16991f9SAndroid Build Coastguard Worker    license_text: [
31*b16991f9SAndroid Build Coastguard Worker        "LICENSE",
32*b16991f9SAndroid Build Coastguard Worker    ],
33*b16991f9SAndroid Build Coastguard Worker}
34*b16991f9SAndroid Build Coastguard Worker
35*b16991f9SAndroid Build Coastguard Workercc_defaults {
36*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_defaults",
37*b16991f9SAndroid Build Coastguard Worker    cflags: [
38*b16991f9SAndroid Build Coastguard Worker        "-Wno-ignored-qualifiers",
39*b16991f9SAndroid Build Coastguard Worker        "-Wno-missing-field-initializers",
40*b16991f9SAndroid Build Coastguard Worker        "-Wno-unused-parameter",
41*b16991f9SAndroid Build Coastguard Worker        "-Wno-unused-variable",
42*b16991f9SAndroid Build Coastguard Worker    ],
43*b16991f9SAndroid Build Coastguard Worker}
44*b16991f9SAndroid Build Coastguard Worker
45*b16991f9SAndroid Build Coastguard Workercc_library_static {
46*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support",
47*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
48*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
49*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
50*b16991f9SAndroid Build Coastguard Worker    export_include_dirs: ["."],
51*b16991f9SAndroid Build Coastguard Worker    srcs: [
52*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/utils/common_utils.cc",
53*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/custom_ops/kernel/sentencepiece/sentencepiece_tokenizer_tflite.cc",
54*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/custom_ops/kernel/sentencepiece/optimized_encoder.cc",
55*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/custom_ops/kernel/ragged/ragged_range_tflite.cc",
56*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/custom_ops/kernel/ragged/ragged_tensor_to_tensor_tflite.cc",
57*b16991f9SAndroid Build Coastguard Worker    ],
58*b16991f9SAndroid Build Coastguard Worker    cflags: [
59*b16991f9SAndroid Build Coastguard Worker        "-Werror",
60*b16991f9SAndroid Build Coastguard Worker        "-Wall",
61*b16991f9SAndroid Build Coastguard Worker        "-O2",
62*b16991f9SAndroid Build Coastguard Worker        "-Wno-missing-field-initializers",
63*b16991f9SAndroid Build Coastguard Worker        "-Wno-unused-parameter",
64*b16991f9SAndroid Build Coastguard Worker        "-Wno-unused-variable",
65*b16991f9SAndroid Build Coastguard Worker    ],
66*b16991f9SAndroid Build Coastguard Worker    generated_headers: [
67*b16991f9SAndroid Build Coastguard Worker        "tflite_support_spm_config",
68*b16991f9SAndroid Build Coastguard Worker        "tflite_support_spm_encoder_config",
69*b16991f9SAndroid Build Coastguard Worker    ],
70*b16991f9SAndroid Build Coastguard Worker    header_libs: [
71*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
72*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
73*b16991f9SAndroid Build Coastguard Worker    ],
74*b16991f9SAndroid Build Coastguard Worker    static_libs: [
75*b16991f9SAndroid Build Coastguard Worker        "libabsl",
76*b16991f9SAndroid Build Coastguard Worker        "libtflite_static",
77*b16991f9SAndroid Build Coastguard Worker    ],
78*b16991f9SAndroid Build Coastguard Worker    apex_available: [
79*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
80*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
81*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
82*b16991f9SAndroid Build Coastguard Worker    ],
83*b16991f9SAndroid Build Coastguard Worker
84*b16991f9SAndroid Build Coastguard Worker    visibility: ["//external/libtextclassifier:__subpackages__"],
85*b16991f9SAndroid Build Coastguard Worker}
86*b16991f9SAndroid Build Coastguard Worker
87*b16991f9SAndroid Build Coastguard Workerjava_library {
88*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_java",
89*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
90*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
91*b16991f9SAndroid Build Coastguard Worker    srcs: [
92*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/java/org/tensorflow/lite/support/**/*.java",
93*b16991f9SAndroid Build Coastguard Worker    ],
94*b16991f9SAndroid Build Coastguard Worker    libs: [
95*b16991f9SAndroid Build Coastguard Worker        "guava-android-annotation-stubs",
96*b16991f9SAndroid Build Coastguard Worker    ],
97*b16991f9SAndroid Build Coastguard Worker    static_libs: [
98*b16991f9SAndroid Build Coastguard Worker        "tensorflowlite_java",
99*b16991f9SAndroid Build Coastguard Worker    ],
100*b16991f9SAndroid Build Coastguard Worker    apex_available: [
101*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
102*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
103*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
104*b16991f9SAndroid Build Coastguard Worker    ],
105*b16991f9SAndroid Build Coastguard Worker}
106*b16991f9SAndroid Build Coastguard Worker
107*b16991f9SAndroid Build Coastguard Workercc_library_static {
108*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_tokenizers",
109*b16991f9SAndroid Build Coastguard Worker    srcs: [
110*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/task/core/task_utils.cc",
111*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/text/tokenizers/regex_tokenizer.cc",
112*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/text/tokenizers/tokenizer_utils.cc",
113*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/utils/common_utils.cc",
114*b16991f9SAndroid Build Coastguard Worker    ],
115*b16991f9SAndroid Build Coastguard Worker    defaults: ["tflite_support_defaults"],
116*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
117*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
118*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
119*b16991f9SAndroid Build Coastguard Worker    export_include_dirs: ["."],
120*b16991f9SAndroid Build Coastguard Worker    header_libs: [
121*b16991f9SAndroid Build Coastguard Worker        // TODO (ag/17748161): Create target for just TFLite headers and use here.
122*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
123*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
124*b16991f9SAndroid Build Coastguard Worker        "libtextclassifier_flatbuffer_headers",
125*b16991f9SAndroid Build Coastguard Worker    ],
126*b16991f9SAndroid Build Coastguard Worker    generated_headers: ["tflite_support_metadata_schema"],
127*b16991f9SAndroid Build Coastguard Worker    static_libs: [
128*b16991f9SAndroid Build Coastguard Worker        "libabsl",
129*b16991f9SAndroid Build Coastguard Worker        "libtextclassifier_bert_tokenizer",
130*b16991f9SAndroid Build Coastguard Worker        "libtflite_static",
131*b16991f9SAndroid Build Coastguard Worker    ],
132*b16991f9SAndroid Build Coastguard Worker    apex_available: [
133*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
134*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
135*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
136*b16991f9SAndroid Build Coastguard Worker    ],
137*b16991f9SAndroid Build Coastguard Worker}
138*b16991f9SAndroid Build Coastguard Worker
139*b16991f9SAndroid Build Coastguard Workercc_test {
140*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_tokenizer_tests",
141*b16991f9SAndroid Build Coastguard Worker    srcs: [
142*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/test/text/regex_tokenizer_test.cc",
143*b16991f9SAndroid Build Coastguard Worker    ],
144*b16991f9SAndroid Build Coastguard Worker    defaults: ["tflite_support_defaults"],
145*b16991f9SAndroid Build Coastguard Worker    data: ["tensorflow_lite_support/cc/test/testdata/task/text/**/*.txt"],
146*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
147*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
148*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
149*b16991f9SAndroid Build Coastguard Worker    static_libs: [
150*b16991f9SAndroid Build Coastguard Worker        "libabsl",
151*b16991f9SAndroid Build Coastguard Worker        "libbase_ndk",
152*b16991f9SAndroid Build Coastguard Worker        "libgmock_ndk",
153*b16991f9SAndroid Build Coastguard Worker        "tflite_support_tokenizers",
154*b16991f9SAndroid Build Coastguard Worker    ],
155*b16991f9SAndroid Build Coastguard Worker    header_libs: [
156*b16991f9SAndroid Build Coastguard Worker        // TODO (ag/17748161): Create target for just TFLite headers and use here.
157*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
158*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
159*b16991f9SAndroid Build Coastguard Worker    ],
160*b16991f9SAndroid Build Coastguard Worker    generated_headers: ["tflite_support_metadata_schema"],
161*b16991f9SAndroid Build Coastguard Worker}
162*b16991f9SAndroid Build Coastguard Worker
163*b16991f9SAndroid Build Coastguard Workercc_library_static {
164*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_classifiers",
165*b16991f9SAndroid Build Coastguard Worker    srcs: [
166*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/task/text/nlclassifier/**/*.cc",
167*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/common.cc",
168*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/port/default/tflite_wrapper.cc",
169*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/port/default/statusor.cc",
170*b16991f9SAndroid Build Coastguard Worker    ],
171*b16991f9SAndroid Build Coastguard Worker    defaults: ["tflite_support_defaults"],
172*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
173*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
174*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
175*b16991f9SAndroid Build Coastguard Worker    export_include_dirs: ["."],
176*b16991f9SAndroid Build Coastguard Worker    header_libs: [
177*b16991f9SAndroid Build Coastguard Worker        // TODO (ag/17748161): Create target for just TFLite headers and use here.
178*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
179*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
180*b16991f9SAndroid Build Coastguard Worker    ],
181*b16991f9SAndroid Build Coastguard Worker    generated_headers: ["tflite_support_metadata_schema"],
182*b16991f9SAndroid Build Coastguard Worker    static_libs: [
183*b16991f9SAndroid Build Coastguard Worker        "libabsl",
184*b16991f9SAndroid Build Coastguard Worker        "libtflite_static",
185*b16991f9SAndroid Build Coastguard Worker        "tflite_configuration_proto",
186*b16991f9SAndroid Build Coastguard Worker        "tflite_support_task_core_proto",
187*b16991f9SAndroid Build Coastguard Worker        "tflite_support_tokenizers",
188*b16991f9SAndroid Build Coastguard Worker        "tflite_support_metadata_extractor",
189*b16991f9SAndroid Build Coastguard Worker    ],
190*b16991f9SAndroid Build Coastguard Worker    apex_available: [
191*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
192*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
193*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
194*b16991f9SAndroid Build Coastguard Worker    ],
195*b16991f9SAndroid Build Coastguard Worker}
196*b16991f9SAndroid Build Coastguard Worker
197*b16991f9SAndroid Build Coastguard Workerjava_library {
198*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_classifiers_java",
199*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
200*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
201*b16991f9SAndroid Build Coastguard Worker    srcs: [
202*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/text/nlclassifier/**/*.java",
203*b16991f9SAndroid Build Coastguard Worker    ],
204*b16991f9SAndroid Build Coastguard Worker    static_libs: [
205*b16991f9SAndroid Build Coastguard Worker        "auto_value_annotations",
206*b16991f9SAndroid Build Coastguard Worker        "tflite_support_java",
207*b16991f9SAndroid Build Coastguard Worker        "tflite_support_base_task_api_java",
208*b16991f9SAndroid Build Coastguard Worker    ],
209*b16991f9SAndroid Build Coastguard Worker    plugins: [
210*b16991f9SAndroid Build Coastguard Worker        "auto_value_plugin",
211*b16991f9SAndroid Build Coastguard Worker    ],
212*b16991f9SAndroid Build Coastguard Worker    apex_available: [
213*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
214*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
215*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
216*b16991f9SAndroid Build Coastguard Worker    ],
217*b16991f9SAndroid Build Coastguard Worker}
218*b16991f9SAndroid Build Coastguard Worker
219*b16991f9SAndroid Build Coastguard Workercc_library_shared {
220*b16991f9SAndroid Build Coastguard Worker    name: "libtflite_support_classifiers_native",
221*b16991f9SAndroid Build Coastguard Worker    srcs: [
222*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/native/task/text/nlclassifier/bert_nlclassifier/bert_nl_classifier_jni.cc",
223*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/native/task/text/nlclassifier/nl_classifier_jni.cc",
224*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/native/task/text/nlclassifier/nl_classifier_jni_utils.cc",
225*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/native/task/core/rbtml_op_resolver.cc",
226*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/custom_ops/kernel/unsorted_segment.cc",
227*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/utils/jni_utils.cc",
228*b16991f9SAndroid Build Coastguard Worker    ],
229*b16991f9SAndroid Build Coastguard Worker    version_script: "tensorflow_lite_support/java/tflite_version_script.lds",
230*b16991f9SAndroid Build Coastguard Worker    shared_libs: [
231*b16991f9SAndroid Build Coastguard Worker        "liblog",
232*b16991f9SAndroid Build Coastguard Worker        "libz",
233*b16991f9SAndroid Build Coastguard Worker    ],
234*b16991f9SAndroid Build Coastguard Worker    static_libs: [
235*b16991f9SAndroid Build Coastguard Worker        "libabsl",
236*b16991f9SAndroid Build Coastguard Worker        "libprotobuf-cpp-lite-ndk",
237*b16991f9SAndroid Build Coastguard Worker        "libtextclassifier_bert_tokenizer",
238*b16991f9SAndroid Build Coastguard Worker        "libtflite_static",
239*b16991f9SAndroid Build Coastguard Worker        "tflite_configuration_proto",
240*b16991f9SAndroid Build Coastguard Worker        "tflite_support_classifiers",
241*b16991f9SAndroid Build Coastguard Worker        "tflite_support_libz",
242*b16991f9SAndroid Build Coastguard Worker        "tflite_support_metadata_extractor",
243*b16991f9SAndroid Build Coastguard Worker        "tflite_support_task_core",
244*b16991f9SAndroid Build Coastguard Worker        "tflite_support_task_core_proto",
245*b16991f9SAndroid Build Coastguard Worker        "tflite_support_tokenizers",
246*b16991f9SAndroid Build Coastguard Worker    ],
247*b16991f9SAndroid Build Coastguard Worker    header_libs: [
248*b16991f9SAndroid Build Coastguard Worker        // TODO (ag/17748161): Create target for just TFLite headers and use here.
249*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
250*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
251*b16991f9SAndroid Build Coastguard Worker        "jni_headers",
252*b16991f9SAndroid Build Coastguard Worker        "libtextclassifier_flatbuffer_headers",
253*b16991f9SAndroid Build Coastguard Worker    ],
254*b16991f9SAndroid Build Coastguard Worker    generated_headers: [
255*b16991f9SAndroid Build Coastguard Worker        "libtflite_mutable_schema",
256*b16991f9SAndroid Build Coastguard Worker        "tflite_support_metadata_schema",
257*b16991f9SAndroid Build Coastguard Worker    ],
258*b16991f9SAndroid Build Coastguard Worker    defaults: ["tflite_support_defaults"],
259*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
260*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
261*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
262*b16991f9SAndroid Build Coastguard Worker    export_include_dirs: ["."],
263*b16991f9SAndroid Build Coastguard Worker    apex_available: [
264*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
265*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
266*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
267*b16991f9SAndroid Build Coastguard Worker    ],
268*b16991f9SAndroid Build Coastguard Worker}
269*b16991f9SAndroid Build Coastguard Worker
270*b16991f9SAndroid Build Coastguard Workerjava_library {
271*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_base_task_api_java",
272*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
273*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
274*b16991f9SAndroid Build Coastguard Worker    srcs: [
275*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/core/*.java",
276*b16991f9SAndroid Build Coastguard Worker    ],
277*b16991f9SAndroid Build Coastguard Worker    optimize: {
278*b16991f9SAndroid Build Coastguard Worker        proguard_flags_files: ["proguard.flags"],
279*b16991f9SAndroid Build Coastguard Worker    },
280*b16991f9SAndroid Build Coastguard Worker    apex_available: [
281*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
282*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
283*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
284*b16991f9SAndroid Build Coastguard Worker    ],
285*b16991f9SAndroid Build Coastguard Worker}
286*b16991f9SAndroid Build Coastguard Worker
287*b16991f9SAndroid Build Coastguard Workercc_library_static {
288*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_metadata_extractor",
289*b16991f9SAndroid Build Coastguard Worker    srcs: [
290*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/metadata/cc/metadata_extractor.cc",
291*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/metadata/cc/utils/zip_readonly_mem_file.cc",
292*b16991f9SAndroid Build Coastguard Worker    ],
293*b16991f9SAndroid Build Coastguard Worker    defaults: ["tflite_support_defaults"],
294*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
295*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
296*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
297*b16991f9SAndroid Build Coastguard Worker    export_include_dirs: ["."],
298*b16991f9SAndroid Build Coastguard Worker    header_libs: [
299*b16991f9SAndroid Build Coastguard Worker        // TODO (ag/17748161): Create target for just TFLite headers and use here.
300*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
301*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
302*b16991f9SAndroid Build Coastguard Worker        "libtextclassifier_flatbuffer_headers",
303*b16991f9SAndroid Build Coastguard Worker    ],
304*b16991f9SAndroid Build Coastguard Worker    generated_headers: [
305*b16991f9SAndroid Build Coastguard Worker        "libtflite_mutable_schema",
306*b16991f9SAndroid Build Coastguard Worker        "tflite_support_metadata_schema",
307*b16991f9SAndroid Build Coastguard Worker    ],
308*b16991f9SAndroid Build Coastguard Worker    static_libs: [
309*b16991f9SAndroid Build Coastguard Worker        "libabsl",
310*b16991f9SAndroid Build Coastguard Worker        "tflite_support_libz",
311*b16991f9SAndroid Build Coastguard Worker    ],
312*b16991f9SAndroid Build Coastguard Worker    apex_available: [
313*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
314*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
315*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
316*b16991f9SAndroid Build Coastguard Worker    ],
317*b16991f9SAndroid Build Coastguard Worker}
318*b16991f9SAndroid Build Coastguard Worker
319*b16991f9SAndroid Build Coastguard Workercc_library_static {
320*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_task_core",
321*b16991f9SAndroid Build Coastguard Worker    srcs: ["tensorflow_lite_support/cc/task/core/**/*.cc"],
322*b16991f9SAndroid Build Coastguard Worker    defaults: ["tflite_support_defaults"],
323*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
324*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
325*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
326*b16991f9SAndroid Build Coastguard Worker    export_include_dirs: ["."],
327*b16991f9SAndroid Build Coastguard Worker    header_libs: [
328*b16991f9SAndroid Build Coastguard Worker        // TODO (ag/17748161): Create target for just TFLite headers and use here.
329*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
330*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
331*b16991f9SAndroid Build Coastguard Worker    ],
332*b16991f9SAndroid Build Coastguard Worker    generated_headers: [
333*b16991f9SAndroid Build Coastguard Worker        "libtflite_mutable_schema",
334*b16991f9SAndroid Build Coastguard Worker        "tflite_support_metadata_schema",
335*b16991f9SAndroid Build Coastguard Worker    ],
336*b16991f9SAndroid Build Coastguard Worker    static_libs: [
337*b16991f9SAndroid Build Coastguard Worker        "libabsl",
338*b16991f9SAndroid Build Coastguard Worker        "tflite_configuration_proto",
339*b16991f9SAndroid Build Coastguard Worker        "tflite_support_task_core_proto",
340*b16991f9SAndroid Build Coastguard Worker    ],
341*b16991f9SAndroid Build Coastguard Worker    apex_available: [
342*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
343*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
344*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
345*b16991f9SAndroid Build Coastguard Worker    ],
346*b16991f9SAndroid Build Coastguard Worker}
347*b16991f9SAndroid Build Coastguard Worker
348*b16991f9SAndroid Build Coastguard Workercc_test {
349*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_classifier_tests",
350*b16991f9SAndroid Build Coastguard Worker    srcs: [
351*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/cc/test/task/text/bert_nl_classifier_test.cc",
352*b16991f9SAndroid Build Coastguard Worker    ],
353*b16991f9SAndroid Build Coastguard Worker    data: ["tensorflow_lite_support/cc/test/testdata/task/text/**/*.tflite"],
354*b16991f9SAndroid Build Coastguard Worker    defaults: [
355*b16991f9SAndroid Build Coastguard Worker        "tflite_support_defaults",
356*b16991f9SAndroid Build Coastguard Worker    ],
357*b16991f9SAndroid Build Coastguard Worker    stl: "libc++_static",
358*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
359*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
360*b16991f9SAndroid Build Coastguard Worker    shared_libs: [
361*b16991f9SAndroid Build Coastguard Worker        "liblog",
362*b16991f9SAndroid Build Coastguard Worker        "libz",
363*b16991f9SAndroid Build Coastguard Worker    ],
364*b16991f9SAndroid Build Coastguard Worker    static_libs: [
365*b16991f9SAndroid Build Coastguard Worker        "libabsl",
366*b16991f9SAndroid Build Coastguard Worker        "libbase_ndk",
367*b16991f9SAndroid Build Coastguard Worker        "libgmock_ndk",
368*b16991f9SAndroid Build Coastguard Worker        "libprotobuf-cpp-lite-ndk",
369*b16991f9SAndroid Build Coastguard Worker        "libtextclassifier_bert_tokenizer",
370*b16991f9SAndroid Build Coastguard Worker        "libtflite_static",
371*b16991f9SAndroid Build Coastguard Worker        "tflite_configuration_proto",
372*b16991f9SAndroid Build Coastguard Worker        "tflite_support_classifiers",
373*b16991f9SAndroid Build Coastguard Worker        "tflite_support_libz",
374*b16991f9SAndroid Build Coastguard Worker        "tflite_support_metadata_extractor",
375*b16991f9SAndroid Build Coastguard Worker        "tflite_support_task_core_proto",
376*b16991f9SAndroid Build Coastguard Worker        "tflite_support_task_core",
377*b16991f9SAndroid Build Coastguard Worker        "tflite_support_tokenizers",
378*b16991f9SAndroid Build Coastguard Worker    ],
379*b16991f9SAndroid Build Coastguard Worker    header_libs: [
380*b16991f9SAndroid Build Coastguard Worker        // TODO (ag/17748161): Create target for just TFLite headers and use here.
381*b16991f9SAndroid Build Coastguard Worker        "tensorflow_headers",
382*b16991f9SAndroid Build Coastguard Worker        "flatbuffer_headers",
383*b16991f9SAndroid Build Coastguard Worker        "liblog_headers",
384*b16991f9SAndroid Build Coastguard Worker        "libtextclassifier_flatbuffer_headers",
385*b16991f9SAndroid Build Coastguard Worker    ],
386*b16991f9SAndroid Build Coastguard Worker    generated_headers: [
387*b16991f9SAndroid Build Coastguard Worker        "libtflite_mutable_schema",
388*b16991f9SAndroid Build Coastguard Worker        "tflite_support_metadata_schema",
389*b16991f9SAndroid Build Coastguard Worker    ],
390*b16991f9SAndroid Build Coastguard Worker}
391*b16991f9SAndroid Build Coastguard Worker
392*b16991f9SAndroid Build Coastguard Workerandroid_test {
393*b16991f9SAndroid Build Coastguard Worker    name: "TfliteSupportClassifierTests",
394*b16991f9SAndroid Build Coastguard Worker    srcs: [
395*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/javatests/org/tensorflow/lite/task/text/nlclassifier/BertNLClassifierTest.java",
396*b16991f9SAndroid Build Coastguard Worker    ],
397*b16991f9SAndroid Build Coastguard Worker    asset_dirs: [
398*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/javatests/testdata/task/text",
399*b16991f9SAndroid Build Coastguard Worker    ],
400*b16991f9SAndroid Build Coastguard Worker    defaults: ["modules-utils-testable-device-config-defaults"],
401*b16991f9SAndroid Build Coastguard Worker    manifest: "tensorflow_lite_support/java/AndroidManifest.xml",
402*b16991f9SAndroid Build Coastguard Worker    sdk_version: "module_current",
403*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
404*b16991f9SAndroid Build Coastguard Worker    static_libs: [
405*b16991f9SAndroid Build Coastguard Worker        "androidx.test.core",
406*b16991f9SAndroid Build Coastguard Worker        "tensorflowlite_java",
407*b16991f9SAndroid Build Coastguard Worker        "truth",
408*b16991f9SAndroid Build Coastguard Worker        "tflite_support_classifiers_java",
409*b16991f9SAndroid Build Coastguard Worker        "tflite_support_test_utils_java",
410*b16991f9SAndroid Build Coastguard Worker    ],
411*b16991f9SAndroid Build Coastguard Worker    libs: [
412*b16991f9SAndroid Build Coastguard Worker        "android.test.base.stubs.system",
413*b16991f9SAndroid Build Coastguard Worker        "android.test.mock.stubs",
414*b16991f9SAndroid Build Coastguard Worker    ],
415*b16991f9SAndroid Build Coastguard Worker    test_suites: [
416*b16991f9SAndroid Build Coastguard Worker        "general-tests",
417*b16991f9SAndroid Build Coastguard Worker    ],
418*b16991f9SAndroid Build Coastguard Worker    jni_libs: [
419*b16991f9SAndroid Build Coastguard Worker        "libtflite_support_classifiers_native",
420*b16991f9SAndroid Build Coastguard Worker    ],
421*b16991f9SAndroid Build Coastguard Worker    aaptflags: [
422*b16991f9SAndroid Build Coastguard Worker        // Avoid compression on tflite files as the Interpreter
423*b16991f9SAndroid Build Coastguard Worker        // can not load compressed flat buffer formats.
424*b16991f9SAndroid Build Coastguard Worker        // (*appt compresses all assets into the apk by default)
425*b16991f9SAndroid Build Coastguard Worker        // See https://elinux.org/Android_aapt for more detail.
426*b16991f9SAndroid Build Coastguard Worker        "-0 .tflite",
427*b16991f9SAndroid Build Coastguard Worker    ],
428*b16991f9SAndroid Build Coastguard Worker}
429*b16991f9SAndroid Build Coastguard Worker
430*b16991f9SAndroid Build Coastguard Workerjava_library_static {
431*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_test_utils_java",
432*b16991f9SAndroid Build Coastguard Worker    sdk_version: "module_current",
433*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
434*b16991f9SAndroid Build Coastguard Worker    srcs: [
435*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/java/src/javatests/org/tensorflow/lite/task/core/TestUtils.java",
436*b16991f9SAndroid Build Coastguard Worker    ],
437*b16991f9SAndroid Build Coastguard Worker    static_libs: [
438*b16991f9SAndroid Build Coastguard Worker        "apache-commons-compress",
439*b16991f9SAndroid Build Coastguard Worker        "guava",
440*b16991f9SAndroid Build Coastguard Worker    ],
441*b16991f9SAndroid Build Coastguard Worker}
442*b16991f9SAndroid Build Coastguard Worker
443*b16991f9SAndroid Build Coastguard Workercc_library_static {
444*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_task_core_proto",
445*b16991f9SAndroid Build Coastguard Worker    proto: {
446*b16991f9SAndroid Build Coastguard Worker        type: "lite",
447*b16991f9SAndroid Build Coastguard Worker        canonical_path_from_root: false,
448*b16991f9SAndroid Build Coastguard Worker        export_proto_headers: true,
449*b16991f9SAndroid Build Coastguard Worker    },
450*b16991f9SAndroid Build Coastguard Worker    stl: "libc++",
451*b16991f9SAndroid Build Coastguard Worker    srcs: ["tensorflow_lite_support/cc/task/core/proto/**/*.proto"],
452*b16991f9SAndroid Build Coastguard Worker    sdk_version: "current",
453*b16991f9SAndroid Build Coastguard Worker    min_sdk_version: "30",
454*b16991f9SAndroid Build Coastguard Worker    apex_available: [
455*b16991f9SAndroid Build Coastguard Worker        "//apex_available:platform",
456*b16991f9SAndroid Build Coastguard Worker        "com.android.adservices",
457*b16991f9SAndroid Build Coastguard Worker        "com.android.extservices",
458*b16991f9SAndroid Build Coastguard Worker    ],
459*b16991f9SAndroid Build Coastguard Worker}
460*b16991f9SAndroid Build Coastguard Worker
461*b16991f9SAndroid Build Coastguard Worker// -----------------
462*b16991f9SAndroid Build Coastguard Worker// Generate headers with FlatBuffer schema compiler.
463*b16991f9SAndroid Build Coastguard Worker// -----------------
464*b16991f9SAndroid Build Coastguard Worker
465*b16991f9SAndroid Build Coastguard WorkerFLATC_ARGS = "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -I external/tflite-support -o $$(dirname $(out)) "
466*b16991f9SAndroid Build Coastguard Worker
467*b16991f9SAndroid Build Coastguard Workergenrule {
468*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_metadata_schema",
469*b16991f9SAndroid Build Coastguard Worker    tools: ["flatc"],
470*b16991f9SAndroid Build Coastguard Worker    srcs: ["tensorflow_lite_support/metadata/metadata_schema.fbs"],
471*b16991f9SAndroid Build Coastguard Worker    cmd: FLATC_ARGS + " $(in)",
472*b16991f9SAndroid Build Coastguard Worker    out: ["tensorflow_lite_support/metadata/metadata_schema_generated.h"],
473*b16991f9SAndroid Build Coastguard Worker}
474*b16991f9SAndroid Build Coastguard Worker
475*b16991f9SAndroid Build Coastguard Workergenrule {
476*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_spm_config",
477*b16991f9SAndroid Build Coastguard Worker    tools: ["flatc"],
478*b16991f9SAndroid Build Coastguard Worker    srcs: ["tensorflow_lite_support/custom_ops/kernel/sentencepiece/config.fbs"],
479*b16991f9SAndroid Build Coastguard Worker    cmd: FLATC_ARGS + " $(in)",
480*b16991f9SAndroid Build Coastguard Worker    out: ["tensorflow_lite_support/custom_ops/kernel/sentencepiece/config_generated.h"],
481*b16991f9SAndroid Build Coastguard Worker}
482*b16991f9SAndroid Build Coastguard Worker
483*b16991f9SAndroid Build Coastguard Workergenrule {
484*b16991f9SAndroid Build Coastguard Worker    name: "tflite_support_spm_encoder_config",
485*b16991f9SAndroid Build Coastguard Worker    tools: ["flatc"],
486*b16991f9SAndroid Build Coastguard Worker    srcs: [
487*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/custom_ops/kernel/sentencepiece/config.fbs",
488*b16991f9SAndroid Build Coastguard Worker        "tensorflow_lite_support/custom_ops/kernel/sentencepiece/encoder_config.fbs",
489*b16991f9SAndroid Build Coastguard Worker    ],
490*b16991f9SAndroid Build Coastguard Worker    cmd: FLATC_ARGS + " $(location tensorflow_lite_support/custom_ops/kernel/sentencepiece/encoder_config.fbs)",
491*b16991f9SAndroid Build Coastguard Worker    out: ["tensorflow_lite_support/custom_ops/kernel/sentencepiece/encoder_config_generated.h"],
492*b16991f9SAndroid Build Coastguard Worker}
493