blob: 76c38e29e094b081b1dfe119158d631e448375e6 [file] [log] [blame]
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//common-mk/mojom_bindings_generator.gni")
import("//common-mk/pkg_config.gni")
import("//common-mk/proto_library.gni")
group("all") {
deps = [
":ml_cmdline",
":ml_service",
]
if (use.test) {
deps += [
":ml_cmdline_test",
":ml_service_test",
]
}
if (use.fuzzer) {
deps += [
":ml_service_impl_fuzzer",
":ml_service_load_flatbuffer_fuzzer",
]
}
if (use.ml_benchmark_drivers) {
deps += [ ":libml_for_benchmark" ]
}
}
generate_mojom_bindings("ml_mojo_bindings") {
mojo_root = "${platform2_root}"
if (use.ml_benchmark_drivers) {
use_pic = true
}
sources = [
"mojom/grammar_checker.mojom",
"mojom/graph_executor.mojom",
"mojom/handwriting_recognizer.mojom",
"mojom/machine_learning_service.mojom",
"mojom/model.mojom",
"mojom/soda.mojom",
"mojom/tensor.mojom",
"mojom/text_classifier.mojom",
"mojom/time.mojom",
]
mojo_extra_args = [
"--typemap",
rebase_path("mojom/type_mappings.json"),
]
}
source_set("ml_mojo_bindings_lib") {
sources = [ "mojom/time_mojom_traits.h" ]
public_deps = [ ":ml_mojo_bindings" ]
}
pkg_config("ml_common_pkg_deps") {
pkg_deps = [
"libbrillo",
"libchrome",
"libmetrics",
"libmojo",
"system_api",
"zlib",
]
}
proto_library("ml_grammar_proto") {
proto_in_dir = "${sysroot}/usr/include/chromeos/libgrammar/proto"
proto_out_dir = "chrome/knowledge/grammar/"
sources = [ "${proto_in_dir}/grammar_interface.proto" ]
}
proto_library("ml_handwriting_proto") {
proto_in_dir = "${sysroot}/usr/include/chromeos/libhandwriting/proto"
proto_out_dir = "chrome/knowledge/handwriting/"
sources = [
"${proto_in_dir}/handwriting_interface.proto",
"${proto_in_dir}/handwriting_validate.proto",
]
}
proto_library("ml_soda_proto") {
proto_in_dir = "${sysroot}/usr/include/chromeos/libsoda/proto"
proto_out_dir = "chrome/knowledge/soda/"
sources = [ "${proto_in_dir}/extended_soda_api.proto" ]
}
static_library("ml_common") {
include_dirs = [
"${sysroot}/usr/include/icu-chrome/common",
"${sysroot}/usr/include/icu-chrome/i18n",
"${sysroot}/usr/include/libtextclassifier",
"${sysroot}/usr/include/marisa-aosp",
"${sysroot}/usr/include/tensorflow",
]
libs = [
"icui18n-chrome",
"icuuc-chrome",
"marisa-aosp",
"tensorflowlite",
"textclassifier",
"utf",
]
pkg_deps = [ "protobuf" ]
deps = [
":ml_grammar_proto",
":ml_handwriting_proto",
]
public_deps = [ ":ml_mojo_bindings_lib" ]
all_dependent_configs = [ ":ml_common_pkg_deps" ]
sources = [
"daemon.cc",
"dlcservice_client.cc",
"grammar_checker_impl.cc",
"grammar_library.cc",
"grammar_proto_mojom_conversion.cc",
"graph_executor_impl.cc",
"handwriting.cc",
"handwriting_proto_mojom_conversion.cc",
"handwriting_recognizer_impl.cc",
"machine_learning_service_impl.cc",
"metrics.cc",
"model_impl.cc",
"model_metadata.cc",
"request_metrics.cc",
"tensor_view.cc",
"text_classifier_impl.cc",
"util.cc",
]
if (use.ondevice_speech) {
sources += [
"soda.cc",
"soda_proto_mojom_conversion.cc",
"soda_recognizer_impl.cc",
]
deps += [ ":ml_soda_proto" ]
} else {
sources += [ "soda_recognizer_impl_fake.cc" ]
}
defines = [
"USE_ONDEVICE_GRAMMAR=${use.ondevice_grammar}",
"USE_ONDEVICE_HANDWRITING=${use.ondevice_handwriting}",
"USE_ONDEVICE_HANDWRITING_DLC=${use.ondevice_handwriting_dlc}",
"TC3_VOCAB_ANNOTATOR_IMPL",
]
}
proto_library("benchmark_proto") {
proto_in_dir = "./proto/"
proto_out_dir = "include/ml"
sources = [ "${proto_in_dir}/benchmark.proto" ]
standalone = true
use_pic = true
}
shared_library("libml_for_benchmark") {
deps = [ ":ml_mojo_bindings_lib" ]
include_dirs = [ "${sysroot}/usr/include/tensorflow" ]
libs = [ "tensorflowlite" ]
pkg_deps = [
"libbrillo",
"libchrome",
"libmetrics",
"libmojo",
"protobuf",
]
public_deps = [
":benchmark_proto",
"//ml_benchmark:libmlbenchmark_proto",
]
sources = [
"benchmark.cc",
"graph_executor_impl.cc",
"metrics.cc",
"model_impl.cc",
"model_metadata.cc",
"request_metrics.cc",
"tensor_view.cc",
"util.cc",
]
}
static_library("ml_cmdline_common") {
deps = [ ":ml_common" ]
sources = [ "simple.cc" ]
}
executable("ml_service") {
deps = [ ":ml_common" ]
sources = [ "main.cc" ]
}
executable("ml_cmdline") {
include_dirs = [ "${sysroot}/usr/include/tensorflow" ]
deps = [ ":ml_cmdline_common" ]
sources = [ "command_line.cc" ]
}
if (use.test) {
executable("ml_service_test") {
configs += [ "//common-mk:test" ]
include_dirs = [ "${sysroot}/usr/include/tensorflow" ]
deps = [
":ml_common",
":ml_grammar_proto",
":ml_handwriting_proto",
"//common-mk/testrunner:testrunner",
]
sources = [
"dlcservice_client_test.cc",
"grammar_library_test.cc",
"grammar_proto_mojom_conversion_test.cc",
"graph_executor_impl_test.cc",
"handwriting_proto_mojom_conversion_test.cc",
"handwriting_test.cc",
"machine_learning_service_impl_test.cc",
"model_impl_test.cc",
"test_utils.cc",
"testrunner.cc",
"util_test.cc",
]
if (use.ml_benchmark_drivers) {
deps += [ ":libml_for_benchmark" ]
sources += [ "benchmark_test.cc" ]
}
defines = [
"USE_ONDEVICE_GRAMMAR=${use.ondevice_grammar}",
"USE_ONDEVICE_HANDWRITING=${use.ondevice_handwriting}",
"USE_ONDEVICE_HANDWRITING_DLC=${use.ondevice_handwriting_dlc}",
]
if (use.ondevice_speech && !use.asan) {
defines += [ "USE_ONDEVICE_SPEECH" ]
sources += [
"soda_proto_mojom_conversion_test.cc",
"soda_test.cc",
]
}
}
executable("ml_cmdline_test") {
configs += [ "//common-mk:test" ]
include_dirs = [ "${sysroot}/usr/include/tensorflow" ]
deps = [ ":ml_cmdline_common" ]
sources = [
"simple_test.cc",
"testrunner.cc",
]
}
}
# Fuzzer target.
if (use.fuzzer) {
executable("ml_service_impl_fuzzer") {
configs += [ "//common-mk/common_fuzzer:common_fuzzer" ]
deps = [ ":ml_common" ]
sources = [ "fuzzers/ml_service_impl_fuzzer.cc" ]
}
executable("ml_service_load_flatbuffer_fuzzer") {
configs += [ "//common-mk/common_fuzzer" ]
deps = [ ":ml_common" ]
sources = [ "fuzzers/ml_service_load_flatbuffer_fuzzer.cc" ]
}
}