summaryrefslogtreecommitdiff
path: root/Android.bp
diff options
context:
space:
mode:
Diffstat (limited to 'Android.bp')
-rw-r--r--Android.bp240
1 files changed, 239 insertions, 1 deletions
diff --git a/Android.bp b/Android.bp
index 887ce14..efe93b0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -22,7 +22,7 @@ cc_defaults {
name: "libtextclassifier_hash_defaults",
srcs: [
"utils/hash/farmhash.cc",
- "util/hash/hash.cc"
+ "util/hash/hash.cc",
],
cflags: [
"-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
@@ -51,3 +51,241 @@ java_library_static {
no_framework_libs: true,
srcs: ["java/**/*.java"],
}
+
+cc_defaults {
+ name: "libtextclassifier_defaults",
+
+ // For debug / treemap purposes.
+ //strip: {
+ // keep_symbols: true,
+ //},
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-ignored-qualifiers",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-Wno-tautological-constant-out-of-range-compare",
+ "-Wno-undefined-var-template",
+ "-Wno-unused-function",
+ "-Wno-unused-parameter",
+ "-Wno-extern-c-compat",
+
+ "-fvisibility=hidden",
+ "-DLIBTEXTCLASSIFIER_UNILIB_ICU",
+ "-DZLIB_CONST",
+ "-DSAFTM_COMPACT_LOGGING",
+ "-DTC3_WITH_ACTIONS_OPS",
+ "-DTC3_UNILIB_JAVAICU",
+ "-DTC3_CALENDAR_JAVAICU",
+ ],
+
+ product_variables: {
+ debuggable: {
+ // Only enable debug logging in userdebug/eng builds.
+ cflags: ["-DTC_DEBUG_LOGGING=1"],
+ },
+ },
+
+ generated_headers: [
+ "libtextclassifier_fbgen_named_extra",
+ "libtextclassifier_fbgen_zlib_buffer",
+ "libtextclassifier_fbgen_intent_config",
+ "libtextclassifier_fbgen_annotator_model",
+ "libtextclassifier_fbgen_actions_model",
+ "libtextclassifier_fbgen_tflite_text_encoder_config",
+ "libtextclassifier_fbgen_lang_id_embedded_network",
+ "libtextclassifier_fbgen_lang_id_model",
+ ],
+
+ header_libs: [
+ "tensorflow_headers",
+ "flatbuffer_headers",
+ ],
+
+ shared_libs: [
+ "liblog",
+ "libtflite",
+ "libz",
+ ],
+
+ static_libs: [
+ "liblua",
+ "libutf",
+ ],
+}
+
+// -----------------
+// Generate headers with FlatBuffer schema compiler.
+// -----------------
+
+genrule {
+ name: "libtextclassifier_fbgen_named_extra",
+ tools: ["flatc"],
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -o $(genDir)/utils $(in)",
+ srcs: ["utils/named-extra.fbs"],
+ out: ["utils/named-extra_generated.h"],
+}
+
+genrule {
+ name: "libtextclassifier_fbgen_zlib_buffer",
+ tools: ["flatc"],
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -o $(genDir)/utils/zlib $(in)",
+ srcs: ["utils/zlib/buffer.fbs"],
+ out: ["utils/zlib/buffer_generated.h"],
+}
+
+genrule {
+ name: "libtextclassifier_fbgen_intent_config",
+ tools: ["flatc"],
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -o $(genDir)/utils/intents $(in)",
+ srcs: ["utils/intents/intent-config.fbs"],
+ out: ["utils/intents/intent-config_generated.h"],
+}
+
+genrule {
+ name: "libtextclassifier_fbgen_annotator_model",
+ tools: ["flatc"],
+ // "depfile" is used here in conjunction with flatc's -M to gather the deps of annotator/model.fbs
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -I external/libtextclassifier -M $(in) >$(depfile) && " +
+ "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -I external/libtextclassifier -o $(genDir)/annotator $(in)",
+ depfile: true,
+ srcs: ["annotator/model.fbs"],
+ out: ["annotator/model_generated.h"],
+}
+
+genrule {
+ name: "libtextclassifier_fbgen_actions_model",
+ tools: ["flatc"],
+ // "depfile" is used here in conjunction with flatc's -M to gather the deps of actions/actions_model.fbs
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -I external/libtextclassifier -M $(in) >$(depfile) && " +
+ "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -I external/libtextclassifier -o $(genDir)/actions $(in)",
+ depfile: true,
+ srcs: ["actions/actions_model.fbs"],
+ out: ["actions/actions_model_generated.h"],
+}
+
+genrule {
+ name: "libtextclassifier_fbgen_tflite_text_encoder_config",
+ tools: ["flatc"],
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -o $(genDir)/utils/tflite $(in)",
+ srcs: ["utils/tflite/text_encoder_config.fbs"],
+ out: ["utils/tflite/text_encoder_config_generated.h"],
+}
+
+genrule {
+ name: "libtextclassifier_fbgen_lang_id_embedded_network",
+ tools: ["flatc"],
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -o $(genDir)/lang_id/common/flatbuffers $(in)",
+ srcs: ["lang_id/common/flatbuffers/embedding-network.fbs"],
+ out: ["lang_id/common/flatbuffers/embedding-network_generated.h"],
+}
+
+genrule {
+ name: "libtextclassifier_fbgen_lang_id_model",
+ tools: ["flatc"],
+ cmd: "$(location flatc) --cpp --no-union-value-namespacing --gen-object-api --keep-prefix -o $(genDir)/lang_id/common/flatbuffers $(in)",
+ srcs: ["lang_id/common/flatbuffers/model.fbs"],
+ out: ["lang_id/common/flatbuffers/model_generated.h"],
+}
+
+// -----------------
+// libtextclassifier
+// -----------------
+cc_library_shared {
+ name: "libtextclassifier",
+ defaults: ["libtextclassifier_defaults"],
+
+ srcs: ["**/*.cc"],
+ exclude_srcs: [
+ "**/*_test.cc",
+ "**/*-test-lib.cc",
+ "utils/testing/*.cc",
+ "test-util.*",
+ ],
+
+ required: [
+ "libtextclassifier_annotator_en_model",
+ "libtextclassifier_annotator_universal_model",
+ "libtextclassifier_actions_suggestions_model",
+ "libtextclassifier_lang_id_model",
+ ],
+
+ version_script: "jni.lds",
+}
+
+// -----------------------
+// libtextclassifier_tests
+// -----------------------
+cc_test {
+ name: "libtextclassifier_tests",
+ defaults: ["libtextclassifier_defaults"],
+
+ test_suites: ["device-tests"],
+
+ data: [
+ "annotator/test_data/**/*",
+ "actions/test_data/**/*",
+ ],
+
+ srcs: ["**/*.cc"],
+ // TODO: Do not filter out tflite test once the dependency issue is resolved.
+ exclude_srcs: ["utils/tflite/*_test.cc"],
+
+ static_libs: ["libgmock"],
+
+ multilib: {
+ lib32: {
+ cppflags: ["-DTC3_TEST_DATA_DIR=\"/data/nativetest/libtextclassifier_tests/test_data/\""],
+ },
+ lib64: {
+ cppflags: ["-DTC3_TEST_DATA_DIR=\"/data/nativetest64/libtextclassifier_tests/test_data/\""],
+ },
+ },
+}
+
+// ----------------
+// Annotator models
+// ----------------
+
+prebuilt_etc {
+ name: "libtextclassifier_annotator_en_model",
+ filename: "textclassifier.en.model",
+ owner: "google",
+ src: "models/textclassifier.en.model",
+ sub_dir: "textclassifier",
+}
+
+prebuilt_etc {
+ name: "libtextclassifier_annotator_universal_model",
+ filename: "textclassifier.universal.model",
+ owner: "google",
+ src: "models/textclassifier.universal.model",
+ sub_dir: "textclassifier",
+}
+
+// ---------------------------
+// Actions Suggestions models
+// ---------------------------
+// STOPSHIP: The model size is now around 7.5mb, we should trim it down before shipping it.
+
+prebuilt_etc {
+ name: "libtextclassifier_actions_suggestions_model",
+ filename: "actions_suggestions.model",
+ owner: "google",
+ src: "models/actions_suggestions.model",
+ sub_dir: "textclassifier",
+}
+
+// ------------
+// LangId model
+// ------------
+
+prebuilt_etc {
+ name: "libtextclassifier_lang_id_model",
+ filename: "lang_id.model",
+ owner: "google",
+ src: "models/lang_id.model",
+ sub_dir: "textclassifier",
+}