1 // Copyright (C) 2017 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 cc_library_headers { 16 name: "libtextclassifier_hash_headers", 17 vendor_available: true, 18 export_include_dirs: ["."], 19 } 20 21 cc_defaults { 22 name: "libtextclassifier_hash_defaults", 23 srcs: [ 24 "utils/hash/farmhash.cc", 25 "util/hash/hash.cc", 26 ], 27 cflags: [ 28 "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash", 29 "-Wall", 30 "-Werror", 31 "-Wno-unused-function", 32 ], 33 } 34 35 cc_library_shared { 36 name: "libtextclassifier_hash", 37 defaults: ["libtextclassifier_hash_defaults"], 38 vendor_available: true, 39 double_loadable: true, 40 } 41 42 cc_library_static { 43 name: "libtextclassifier_hash_static", 44 defaults: ["libtextclassifier_hash_defaults"], 45 sdk_version: "current", 46 stl: "libc++_static", 47 } 48 49 java_library_static { 50 name: "libtextclassifier-java", 51 sdk_version: "core_current", 52 no_framework_libs: true, 53 srcs: ["java/**/*.java"], 54 } 55 56 cc_defaults { 57 name: "libtextclassifier_defaults", 58 59 // For debug / treemap purposes. 60 //strip: { 61 // keep_symbols: true, 62 //}, 63 64 cflags: [ 65 "-Wall", 66 "-Werror", 67 "-Wno-deprecated-declarations", 68 "-Wno-ignored-qualifiers", 69 "-Wno-missing-field-initializers", 70 "-Wno-sign-compare", 71 "-Wno-tautological-constant-out-of-range-compare", 72 "-Wno-undefined-var-template", 73 "-Wno-unused-function", 74 "-Wno-unused-parameter", 75 "-Wno-extern-c-compat", 76 77 "-funsigned-char", 78 "-fvisibility=hidden", 79 "-DLIBTEXTCLASSIFIER_UNILIB_ICU", 80 "-DZLIB_CONST", 81 "-DSAFTM_COMPACT_LOGGING", 82 "-DTC3_WITH_ACTIONS_OPS", 83 "-DTC3_UNILIB_JAVAICU", 84 "-DTC3_CALENDAR_JAVAICU", 85 "-DTC3_AOSP" 86 ], 87 88 product_variables: { 89 debuggable: { 90 // Only enable debug logging in userdebug/eng builds. 91 cflags: ["-DTC_DEBUG_LOGGING=1"], 92 }, 93 }, 94 95 generated_headers: [ 96 "libtextclassifier_fbgen_flatbuffers", 97 "libtextclassifier_fbgen_tokenizer", 98 "libtextclassifier_fbgen_codepoint_range", 99 "libtextclassifier_fbgen_entity-data", 100 "libtextclassifier_fbgen_zlib_buffer", 101 "libtextclassifier_fbgen_resources_extra", 102 "libtextclassifier_fbgen_intent_config", 103 "libtextclassifier_fbgen_annotator_model", 104 "libtextclassifier_fbgen_actions_model", 105 "libtextclassifier_fbgen_tflite_text_encoder_config", 106 "libtextclassifier_fbgen_lang_id_embedded_network", 107 "libtextclassifier_fbgen_lang_id_model", 108 "libtextclassifier_fbgen_actions-entity-data", 109 ], 110 111 header_libs: [ 112 "tensorflow_headers", 113 "flatbuffer_headers", 114 ], 115 116 shared_libs: [ 117 "liblog", 118 "libtflite", 119 "libz", 120 ], 121 122 static_libs: [ 123 "liblua", 124 "libutf", 125 ], 126 } 127 128 // ----------------- 129 // Generate headers with FlatBuffer schema compiler. 130 // ----------------- 131 genrule_defaults { 132 name: "fbgen", 133 tools: ["flatc"], 134 // "depfile" is used here in conjunction with flatc's -M to gather the deps 135 cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -I external/libtextclassifier -M $(in) >$(depfile) && " + 136 "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -I external/libtextclassifier -o $$(dirname $(out)) $(in)", 137 depfile: true, 138 } 139 140 genrule { 141 name: "libtextclassifier_fbgen_flatbuffers", 142 srcs: ["utils/flatbuffers.fbs"], 143 out: ["utils/flatbuffers_generated.h"], 144 defaults: ["fbgen"], 145 } 146 147 genrule { 148 name: "libtextclassifier_fbgen_tokenizer", 149 srcs: ["utils/tokenizer.fbs"], 150 out: ["utils/tokenizer_generated.h"], 151 defaults: ["fbgen"], 152 } 153 154 genrule { 155 name: "libtextclassifier_fbgen_codepoint_range", 156 srcs: ["utils/codepoint-range.fbs"], 157 out: ["utils/codepoint-range_generated.h"], 158 defaults: ["fbgen"], 159 } 160 161 genrule { 162 name: "libtextclassifier_fbgen_resources_extra", 163 srcs: ["utils/resources.fbs"], 164 out: ["utils/resources_generated.h"], 165 defaults: ["fbgen"], 166 } 167 168 genrule { 169 name: "libtextclassifier_fbgen_entity-data", 170 srcs: ["annotator/entity-data.fbs"], 171 out: ["annotator/entity-data_generated.h"], 172 defaults: ["fbgen"], 173 } 174 175 genrule { 176 name: "libtextclassifier_fbgen_zlib_buffer", 177 srcs: ["utils/zlib/buffer.fbs"], 178 out: ["utils/zlib/buffer_generated.h"], 179 defaults: ["fbgen"], 180 } 181 182 genrule { 183 name: "libtextclassifier_fbgen_intent_config", 184 srcs: ["utils/intents/intent-config.fbs"], 185 out: ["utils/intents/intent-config_generated.h"], 186 defaults: ["fbgen"], 187 } 188 189 genrule { 190 name: "libtextclassifier_fbgen_annotator_model", 191 srcs: ["annotator/model.fbs"], 192 out: ["annotator/model_generated.h"], 193 defaults: ["fbgen"], 194 } 195 196 genrule { 197 name: "libtextclassifier_fbgen_actions_model", 198 srcs: ["actions/actions_model.fbs"], 199 out: ["actions/actions_model_generated.h"], 200 defaults: ["fbgen"], 201 } 202 203 genrule { 204 name: "libtextclassifier_fbgen_tflite_text_encoder_config", 205 srcs: ["utils/tflite/text_encoder_config.fbs"], 206 out: ["utils/tflite/text_encoder_config_generated.h"], 207 defaults: ["fbgen"], 208 } 209 210 genrule { 211 name: "libtextclassifier_fbgen_lang_id_embedded_network", 212 srcs: ["lang_id/common/flatbuffers/embedding-network.fbs"], 213 out: ["lang_id/common/flatbuffers/embedding-network_generated.h"], 214 defaults: ["fbgen"], 215 } 216 217 genrule { 218 name: "libtextclassifier_fbgen_lang_id_model", 219 srcs: ["lang_id/common/flatbuffers/model.fbs"], 220 out: ["lang_id/common/flatbuffers/model_generated.h"], 221 defaults: ["fbgen"], 222 } 223 224 genrule { 225 name: "libtextclassifier_fbgen_actions-entity-data", 226 srcs: ["actions/actions-entity-data.fbs"], 227 out: ["actions/actions-entity-data_generated.h"], 228 defaults: ["fbgen"], 229 } 230 231 // ----------------- 232 // libtextclassifier 233 // ----------------- 234 cc_library_shared { 235 name: "libtextclassifier", 236 defaults: ["libtextclassifier_defaults"], 237 238 srcs: ["**/*.cc"], 239 exclude_srcs: [ 240 "**/*_test.cc", 241 "**/*-test-lib.cc", 242 "utils/testing/*.cc", 243 "test-util.*", 244 "utils/calendar/*_test-include.*", 245 "utils/utf8/*_test-include.*" 246 ], 247 248 required: [ 249 "libtextclassifier_annotator_en_model", 250 "libtextclassifier_annotator_universal_model", 251 "libtextclassifier_actions_suggestions_universal_model", 252 "libtextclassifier_lang_id_model", 253 ], 254 255 version_script: "jni.lds", 256 } 257 258 // ----------------------- 259 // libtextclassifier_tests 260 // ----------------------- 261 cc_test { 262 name: "libtextclassifier_tests", 263 defaults: ["libtextclassifier_defaults"], 264 265 test_suites: ["device-tests"], 266 267 data: [ 268 "annotator/test_data/**/*", 269 "actions/test_data/**/*", 270 ], 271 272 srcs: ["**/*.cc"], 273 // TODO: Do not filter out tflite test once the dependency issue is resolved. 274 exclude_srcs: [ 275 "utils/tflite/*_test.cc", 276 "utils/flatbuffers_test.cc", 277 "utils/calendar/*_test-include.*", 278 "utils/utf8/*_test-include.*" 279 ], 280 281 static_libs: ["libgmock"], 282 283 multilib: { 284 lib32: { 285 cppflags: ["-DTC3_TEST_DATA_DIR=\"/data/nativetest/libtextclassifier_tests/test_data/\""], 286 }, 287 lib64: { 288 cppflags: ["-DTC3_TEST_DATA_DIR=\"/data/nativetest64/libtextclassifier_tests/test_data/\""], 289 }, 290 }, 291 } 292 293 // ---------------- 294 // Annotator models 295 // ---------------- 296 297 prebuilt_etc { 298 name: "libtextclassifier_annotator_en_model", 299 filename: "textclassifier.en.model", 300 owner: "google", 301 src: "models/textclassifier.en.model", 302 sub_dir: "textclassifier", 303 } 304 305 prebuilt_etc { 306 name: "libtextclassifier_annotator_universal_model", 307 filename: "textclassifier.universal.model", 308 owner: "google", 309 src: "models/textclassifier.universal.model", 310 sub_dir: "textclassifier", 311 } 312 313 // --------------------------- 314 // Actions Suggestions models 315 // --------------------------- 316 317 prebuilt_etc { 318 name: "libtextclassifier_actions_suggestions_universal_model", 319 filename: "actions_suggestions.universal.model", 320 owner: "google", 321 src: "models/actions_suggestions.universal.model", 322 sub_dir: "textclassifier", 323 } 324 325 // ------------ 326 // LangId model 327 // ------------ 328 329 prebuilt_etc { 330 name: "libtextclassifier_lang_id_model", 331 filename: "lang_id.model", 332 owner: "google", 333 src: "models/lang_id.model", 334 sub_dir: "textclassifier", 335 } 336