blob: 3c04a18788d2ad441412c844c7c4b174d518dad3 [file] [log] [blame]
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
cc_library_headers {
name: "libtextclassifier_hash_headers",
vendor_available: true,
export_include_dirs: ["."],
}
cc_defaults {
name: "libtextclassifier_hash_defaults",
srcs: [
"utils/hash/farmhash.cc",
"util/hash/hash.cc",
],
cflags: [
"-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
"-Wall",
"-Werror",
"-Wno-unused-function",
],
}
cc_library_shared {
name: "libtextclassifier_hash",
defaults: ["libtextclassifier_hash_defaults"],
vendor_available: true,
double_loadable: true,
}
cc_library_static {
name: "libtextclassifier_hash_static",
defaults: ["libtextclassifier_hash_defaults"],
sdk_version: "current",
stl: "libc++_static",
}
java_library_static {
name: "libtextclassifier-java",
sdk_version: "core_current",
no_framework_libs: true,
srcs: ["java/**/*.java"],
}
cc_defaults {
name: "libtextclassifier_defaults",
// For debug / treemap purposes.
//strip: {
// keep_symbols: true,
//},
cflags: [
"-Wall",
"-Werror",
"-Wno-deprecated-declarations",
"-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_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_zlib_buffer",
"libtextclassifier_fbgen_intent_config",
"libtextclassifier_fbgen_annotator_model",
],
header_libs: [
"tensorflow_headers",
"flatbuffer_headers",
],
shared_libs: [
"liblog",
"libtflite",
"libz",
],
static_libs: [
"libutf",
],
}
// -----------------
// Generate headers with FlatBuffer schema compiler.
// -----------------
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"],
}
// -----------------
// libtextclassifier
// -----------------
cc_library_shared {
name: "libtextclassifier",
defaults: ["libtextclassifier_defaults"],
srcs: ["**/*.cc"],
exclude_srcs: [
"**/*_test.cc",
"**/*-test-lib.cc",
"test-util.*",
],
required: [
"libtextclassifier_annotator_en_model",
"libtextclassifier_annotator_universal_model",
],
version_script: "jni.lds",
}
// -----------------------
// libtextclassifier_tests
// -----------------------
cc_test {
name: "libtextclassifier_tests",
defaults: ["libtextclassifier_defaults"],
test_suites: ["device-tests"],
data: [
"annotator/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",
}