blob: 12396fbd68ac2a99c192de5065395d656580ec43 [file] [log] [blame]
# Copyright 2017 The Fuchsia 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("//build/config.gni")
import("//build/package.gni")
import("//third_party/cobalt/metrics_registry.gni")
import("//third_party/protobuf/proto_library.gni")
declare_args() {
# Selects the Cobalt environment to send data to. Choices:
# "LOCAL" - record log data locally to a file
# "DEVEL" - the non-prod environment for use in testing
# "PROD" - the production environment
cobalt_environment = "PROD"
}
# Generates the global_metrics_registry.pb file.
metrics_registry("global_metrics_registry") {
global = true
}
# Include the global_metrics_registry.pb in the config data for Cobalt.
config_data("cobalt_registry") {
for_pkg = "cobalt"
deps = [ ":global_metrics_registry" ]
sources = [ "$target_gen_dir/global_metrics_registry.pb" ]
outputs = [ "global_metrics_registry.pb" ]
}
source_set("lib") {
sources = [
"activity_listener_impl.cc",
"activity_listener_impl.h",
"cobalt_app.cc",
"cobalt_app.h",
"cobalt_controller_impl.cc",
"cobalt_controller_impl.h",
"configuration_data.cc",
"configuration_data.h",
"logger_factory_impl.cc",
"logger_factory_impl.h",
"logger_impl.cc",
"logger_impl.h",
"metric_event_logger_factory_impl.cc",
"metric_event_logger_factory_impl.h",
"metric_event_logger_impl.cc",
"metric_event_logger_impl.h",
"process_lifecycle_impl.h",
"system_data_updater_impl.cc",
"system_data_updater_impl.h",
"timer_manager.cc",
"timer_manager.h",
"user_consent_watcher.cc",
"user_consent_watcher.h",
"utils.cc",
"utils.h",
]
public_deps = [
"//garnet/public/lib/fostr/fidl/fuchsia.settings",
"//sdk/fidl/fuchsia.cobalt",
"//sdk/fidl/fuchsia.metrics",
"//sdk/fidl/fuchsia.process.lifecycle",
"//sdk/fidl/fuchsia.ui.activity",
"//sdk/lib/sys/cpp",
"//sdk/lib/sys/inspect/cpp",
"//sdk/lib/syslog/cpp",
"//src/cobalt/bin/utils:clock",
"//src/cobalt/bin/utils:fuchsia_http_client",
"//src/connectivity/wlan/lib/mlme/cpp:mlme",
"//src/lib/backoff",
"//src/lib/fsl",
"//src/lib/fxl",
"//src/lib/json_parser",
"//third_party/cobalt/src/lib/util:file_util",
"//third_party/cobalt/src/lib/util:pem_util",
"//third_party/cobalt/src/lib/util:posix_file_system",
"//third_party/cobalt/src/logger",
"//third_party/cobalt/src/public:activity_listener_interface",
"//third_party/cobalt/src/public:cobalt_config",
"//third_party/cobalt/src/public:cobalt_service",
"//third_party/cobalt/src/public:cobalt_service_interface",
"//third_party/cobalt/src/system_data",
"//third_party/cobalt/src/system_data:configuration_data",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
}
executable("app") {
output_name = "cobalt"
sources = [ "cobalt_main.cc" ]
deps = [
":lib",
"//sdk/fidl/fuchsia.scheduler",
"//sdk/fidl/fuchsia.sysinfo",
"//zircon/system/ulib/trace",
"//zircon/system/ulib/trace-provider:trace-provider-with-fdio",
]
}
# In the default config, Cobalt will upload all metrics (including max_release_stage=DEBUG metrics)
config_data("config") {
for_pkg = "cobalt"
sources = [ "configs/default_config.json" ]
outputs = [ "config.json" ]
}
# In the "user" config, Cobalt will behave like it will on an end-user device, meaning it will only
# upload metrics marked with max_release_stage=GA.
config_data("user_config") {
for_pkg = "cobalt"
sources = [ "configs/user_config.json" ]
outputs = [ "config.json" ]
}
# In the "userdebug" config, Cobalt will behave like it will on an end-user device, except that it
# will upload DEBUG metrics.
config_data("userdebug_config") {
for_pkg = "cobalt"
sources = [ "configs/userdebug_config.json" ]
outputs = [ "config.json" ]
}
package("cobalt") {
deps = [ ":app" ]
binaries = [
{
name = "cobalt"
},
]
meta = [
{
path = rebase_path("meta/cobalt.cmx")
dest = "cobalt.cmx"
},
]
resources = [
{
# Environment selection for cobalt.
if (cobalt_environment == "PROD") {
path = "configs/prod_environment"
} else if (cobalt_environment == "DEVEL") {
path = "configs/devel_environment"
} else if (cobalt_environment == "LOCAL") {
path = "configs/local_environment"
} else {
assert(false, "Unknown cobalt_environment: $cobalt_environment")
}
dest = "cobalt_environment"
},
{
# Cobalt 1.0 analyzer public key for devel environment.
path = rebase_path("//third_party/cobalt/keys/analyzer_public.cobalt_key")
dest = "keys/analyzer_devel_public"
},
{
# Cobalt 1.0 shuffler public key for devel environment.
path = rebase_path("//third_party/cobalt/keys/shuffler_public.cobalt_key")
dest = "keys/shuffler_devel_public"
},
{
# Cobalt 1.0 analyzer public key for prod environment.
path = rebase_path(
"//third_party/cobalt/keys/analyzer_prod_public.cobalt_key")
dest = "keys/analyzer_prod_public"
},
{
# Cobalt 1.0 shuffler public key for prod environment.
path = rebase_path(
"//third_party/cobalt/keys/shuffler_prod_public.cobalt_key")
dest = "keys/shuffler_prod_public"
},
]
}
metrics_registry("testapp_metrics_registry") {
# This must match the ID of the test_app2 Cobalt project as specified in:
# third_party/cobalt_config/projects.yaml
project_id = 657579885
namespace = "testapp_registry"
generate_cc = true
generate_binarypb = true
}
executable("cobalt_app_unittests") {
testonly = true
sources = [
"activity_listener_impl_test.cc",
"cobalt_app_test.cc",
"cobalt_controller_impl_test.cc",
"configuration_data_test.cc",
"logger_impl_test.cc",
"metric_event_logger_impl_test.cc",
"system_data_updater_impl_test.cc",
"timer_manager_test.cc",
"user_consent_watcher_test.cc",
]
deps = [
":lib",
":testapp_metrics_registry_cc",
"//garnet/public/lib/gtest",
"//sdk/fidl/fuchsia.cobalt",
"//sdk/lib/sys/cpp/testing:unit",
"//sdk/lib/sys/cpp/testing:unit",
"//src/cobalt/bin/testing:fake_clock_lib",
"//src/cobalt/bin/testing:fake_http_loader",
"//src/lib/cobalt/cpp:cobalt_event_builder",
"//src/lib/cobalt/cpp:metric_event_builder",
"//src/lib/fsl",
"//src/lib/fxl/test:gtest_main",
"//third_party/cobalt/src/logger:fake_logger",
"//third_party/cobalt/src/logger:logger_test_utils",
"//third_party/cobalt/src/public/testing:fake_cobalt_service",
"//third_party/googletest:gmock",
]
}