| # 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("//src/sys/build/components.gni") |
| import("//third_party/cobalt/metrics_registry.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" ] |
| } |
| |
| fuchsia_component("component") { |
| component_name = "cobalt" |
| manifest = "meta/cobalt.cmx" |
| deps = [ ":app" ] |
| } |
| |
| resource("cobalt_environment") { |
| # Environment selection for cobalt. |
| if (cobalt_environment == "PROD") { |
| sources = [ "configs/prod_environment" ] |
| } else if (cobalt_environment == "DEVEL") { |
| sources = [ "configs/devel_environment" ] |
| } else if (cobalt_environment == "LOCAL") { |
| sources = [ "configs/local_environment" ] |
| } else { |
| assert(false, "Unknown cobalt_environment: $cobalt_environment") |
| } |
| outputs = [ "data/cobalt_environment" ] |
| } |
| |
| resource("analyzer_devel_public") { |
| # Cobalt 1.0 analyzer public key for devel environment. |
| sources = |
| [ rebase_path("//third_party/cobalt/keys/analyzer_public.cobalt_key") ] |
| outputs = [ "data/keys/analyzer_devel_public" ] |
| } |
| |
| resource("shuffler_devel_public") { |
| # Cobalt 1.0 shuffler public key for devel environment. |
| sources = |
| [ rebase_path("//third_party/cobalt/keys/shuffler_public.cobalt_key") ] |
| outputs = [ "data/keys/shuffler_devel_public" ] |
| } |
| |
| resource("analyzer_prod_public") { |
| # Cobalt 1.0 analyzer public key for prod environment. |
| sources = [ rebase_path( |
| "//third_party/cobalt/keys/analyzer_prod_public.cobalt_key") ] |
| outputs = [ "data/keys/analyzer_prod_public" ] |
| } |
| |
| resource("shuffler_prod_public") { |
| # Cobalt 1.0 shuffler public key for prod environment. |
| sources = [ rebase_path( |
| "//third_party/cobalt/keys/shuffler_prod_public.cobalt_key") ] |
| outputs = [ "data/keys/shuffler_prod_public" ] |
| } |
| |
| fuchsia_package("cobalt") { |
| deps = [ |
| ":analyzer_devel_public", |
| ":analyzer_prod_public", |
| ":cobalt_environment", |
| ":component", |
| ":shuffler_devel_public", |
| ":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", |
| ] |
| } |