blob: b471d32d1fa8fb5a87ff18485879099290a0beaf [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",
]
}
}
source_set("mojo_bindings_traits") {
sources = [
"mojom/time_mojom_traits.h",
]
}
generate_mojom_bindings("ml_mojo_bindings") {
mojo_root = "${platform2_root}"
sources = [
"mojom/graph_executor.mojom",
"mojom/machine_learning_service.mojom",
"mojom/model.mojom",
"mojom/tensor.mojom",
"mojom/text_classifier.mojom",
"mojom/time.mojom",
]
mojo_extra_args = [
"--typemap",
rebase_path("mojom/type_mappings.json"),
]
deps = [
":mojo_bindings_traits",
]
}
pkg_config("ml_common_pkg_deps") {
pkg_deps = [
"libbrillo",
"libchrome-${libbase_ver}",
"libmetrics-${libbase_ver}",
"libmojo-${libbase_ver}",
"zlib",
]
}
proto_library("ml_handwriting_proto") {
proto_in_dir = "${sysroot}/usr/include/chromeos/libhandwriting/proto"
proto_out_dir = "chrome/knowledge/handwriting/"
sources = [
"${proto_in_dir}/interface.proto",
"${proto_in_dir}/validate.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/tensorflow",
]
libs = [
"icui18n-chrome",
"icuuc-chrome",
"tensorflowlite",
"textclassifier",
]
pkg_deps = [ "protobuf" ]
deps = [
":ml_handwriting_proto",
":ml_mojo_bindings",
]
all_dependent_configs = [ ":ml_common_pkg_deps" ]
sources = [
"daemon.cc",
"graph_executor_impl.cc",
"handwriting.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",
]
}
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_handwriting_proto",
]
sources = [
"graph_executor_impl_test.cc",
"handwriting_test.cc",
"machine_learning_service_impl_test.cc",
"model_impl_test.cc",
"test_utils.cc",
"testrunner.cc",
"util_test.cc",
]
# TODO(charleszhao) this macro is only used in the unit test file
# "handwriting_test.cc". After the mojo API is implemented, maybe we should
# 1. Remove "handwriting_test.cc" and move all the unit test into mojo
# unit tests, like those in "machine_learning_service_impl_test.cc".
# 2. Use separate unit test files rather than "one test file+macro". And
# The following build config can be something like,
# if (use.ondevice_handwriting) {
# sources += "handwriting_supported_test.cc"
# } else {
# sources += "handwriting_unsupported_test.cc"
# }
if (use.ondevice_handwriting) {
defines = [ "ML_SUPPORT_HANDWRITING" ]
}
}
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",
]
}
}