blob: 235411755371a65c4272003847714765aeab38d4 [file] [log] [blame]
# Copyright 2020 The ChromiumOS Authors
# 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 = [
":federated_service",
":install_dbus_config_file",
":install_dbus_service_activation_config",
":install_minijail_conf",
":install_seccomp_policy",
":install_upstart_conf",
]
if (use.test) {
deps += [
":components_test",
":federated_service_test",
]
}
if (use.fuzzer) {
deps += [ ":federated_service_impl_fuzzer" ]
}
}
pkg_config("federated_common_pkg_deps") {
pkg_deps = [
"absl",
"libbrillo",
"libchrome",
"libdlcservice-client",
"libmetrics",
"libmojo",
"libsession_manager-client",
"libshill-client",
"libshill-dbus-client",
"sqlite3",
"system_api",
]
}
generate_mojom_bindings("federated_mojo_bindings") {
mojo_root = "${platform2_root}"
sources = [
"mojom/example.mojom",
"mojom/federated_service.mojom",
"mojom/tables.mojom",
]
}
proto_library("tf_example_proto") {
proto_in_dir = "./protos"
proto_out_dir = "federated/protos/"
sources = [
"${proto_in_dir}/example.proto",
"${proto_in_dir}/feature.proto",
]
}
proto_library("cros_fcp_proto") {
proto_in_dir = "${sysroot}/usr/include/fcp"
proto_out_dir = "federated/protos/"
sources = [
"${proto_in_dir}/cros_events.proto",
"${proto_in_dir}/cros_example_selector_criteria.proto",
]
}
static_library("federated_common") {
sources = [
"daemon.cc",
"device_status/device_status_monitor.cc",
"device_status/memory_pressure_training_condition.cc",
"device_status/network_status_training_condition.cc",
"device_status/power_supply_training_condition.cc",
"device_status/shill_proxy_impl.cc",
"example_database.cc",
"federated_client.cc",
"federated_library.cc",
"federated_metadata.cc",
"federated_service_impl.cc",
"metrics.cc",
"scheduler.cc",
"session_manager_proxy.cc",
"storage_manager.cc",
"utils.cc",
]
defines = [ "USE_LOCAL_FEDERATED_SERVER=${use.local_federated_server}" ]
all_dependent_configs = [ ":federated_common_pkg_deps" ]
pkg_deps = [
"protobuf",
"re2",
]
deps = [
":cros_fcp_proto",
":federated_mojo_bindings",
":tf_example_proto",
]
}
executable("federated_service") {
sources = [ "main.cc" ]
install_path = "bin"
deps = [ ":federated_common" ]
}
install_config("install_upstart_conf") {
sources = [ "init/federated-service.conf" ]
install_path = "upstart"
}
install_config("install_minijail_conf") {
sources = [ "minijail/federated-service.conf" ]
install_path = "minijail_conf"
}
install_config("install_seccomp_policy") {
sources =
[ "seccomp/federated_service-seccomp-" + getenv("ARCH") + ".policy" ]
install_path = "seccomp_policy"
outputs = [ "federated_service-seccomp.policy" ]
}
install_config("install_dbus_config_file") {
sources = [ "dbus/org.chromium.Federated.conf" ]
install_path = "dbus_system_d"
}
install_config("install_dbus_service_activation_config") {
sources = [ "dbus/org.chromium.Federated.service" ]
install_path = "dbus_system_services"
}
if (use.test) {
pkg_config("libchrome_test_config") {
pkg_deps = [
"libchrome-test",
"libsession_manager-client-test",
"libshill-client-test",
]
}
static_library("test_utils") {
sources = [ "test_utils.cc" ]
configs += [ ":libchrome_test_config" ]
deps = [ ":federated_common" ]
}
# This test requires mojo setup.
executable("federated_service_test") {
sources = [
"federated_service_impl_test.cc",
"mojo_testrunner.cc",
]
configs += [
"//common-mk:test",
":libchrome_test_config",
]
run_test = true
deps = [ ":test_utils" ]
}
executable("components_test") {
sources = [
"device_status/device_status_monitor_test.cc",
"device_status/fake_shill_proxy.cc",
"device_status/memory_pressure_training_condition_test.cc",
"device_status/network_status_training_condition_test.cc",
"device_status/power_supply_training_condition_test.cc",
"example_database_test.cc",
"mock_example_database.cc",
"session_manager_proxy_test.cc",
"storage_manager_test.cc",
"utils_test.cc",
]
configs += [
"//common-mk:test",
":libchrome_test_config",
]
run_test = true
deps = [
":test_utils",
"//common-mk/testrunner",
]
}
}
# Fuzzer target.
if (use.fuzzer) {
executable("federated_service_impl_fuzzer") {
sources = [ "fuzzers/federated_service_impl_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer:common_fuzzer",
"//common-mk:test",
]
deps = [ ":federated_common" ]
pkg_deps = [ "libchrome-test" ]
}
}