blob: 26ba77e777a609c31cb1fca1dc19dce0cc0d28b0 [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/components.gni")
import("//build/config.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
# false - use the default environment supplied by assembly
cobalt_environment = false
}
if (cobalt_environment != false && cobalt_environment != "PROD" &&
cobalt_environment != "DEVEL" && cobalt_environment != "LOCAL") {
assert(false, "Unknown cobalt_environment: $cobalt_environment")
}
# Generates the global_metrics_registry.pb file.
metrics_registry("global_metrics_registry") {
global = true
# Remove test projects from the registry.
exclude_projects = [
"1:7",
"1:657579885",
"1:929352809",
]
}
# 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 = [
"aggregate_and_upload_impl.cc",
"aggregate_and_upload_impl.h",
"cobalt_app.cc",
"cobalt_app.h",
"cobalt_controller_impl.cc",
"cobalt_controller_impl.h",
"configuration_data.cc",
"configuration_data.h",
"current_channel_provider.cc",
"current_channel_provider.h",
"diagnostics_impl.cc",
"diagnostics_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",
"user_consent_watcher.cc",
"user_consent_watcher.h",
"utils.cc",
"utils.h",
]
public_deps = [
"//sdk/fidl/fuchsia.buildinfo:fuchsia.buildinfo_hlcpp",
"//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt_hlcpp",
"//sdk/fidl/fuchsia.metrics:fuchsia.metrics_hlcpp",
"//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_hlcpp",
"//sdk/fidl/fuchsia.update.channel:fuchsia.update.channel_cpp",
"//sdk/lib/inspect/component/cpp",
"//sdk/lib/sys/cpp",
"//sdk/lib/syslog/cpp",
"//src/cobalt/bin/utils:clock",
"//src/cobalt/bin/utils:fuchsia_http_client",
"//src/lib/backoff",
"//src/lib/fostr/fidl/fuchsia.settings",
"//src/lib/fsl",
"//src/lib/fxl:fxl_cli",
"//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:cobalt_config",
"//third_party/cobalt/src/public:cobalt_service",
"//third_party/cobalt/src/public:cobalt_service_interface",
"//third_party/cobalt/src/public:diagnostics_interface",
"//third_party/cobalt/src/public/lib:report_spec",
"//third_party/cobalt/src/public/lib:status",
"//third_party/cobalt/src/public/lib/statusor",
"//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",
]
deps = [
"//sdk/lib/component/incoming/cpp:cpp",
"//sdk/lib/fit-promise",
]
}
executable("app") {
output_name = "cobalt"
sources = [ "cobalt_main.cc" ]
deps = [
":lib",
"//sdk/fidl/fuchsia.sysinfo:fuchsia.sysinfo_hlcpp",
"//sdk/fidl/fuchsia.time:fuchsia.time_hlcpp",
"//sdk/lib/scheduler/cpp",
"//sdk/lib/zbi-format",
"//zircon/system/ulib/trace",
"//zircon/system/ulib/trace-provider",
]
}
# TODO(https://fxbug.dev/42073789) Remove transitional labels
group("config") {
}
group("user_config") {
}
group("userdebug_config") {
}
fuchsia_component("component-v2") {
component_name = "cobalt"
manifest = "meta/cobalt.cml"
deps = [ ":app" ]
}
resource("cobalt_environment") {
# Environment selection for cobalt.
if (cobalt_environment == false || 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("cobalt_devel_environment") {
testonly = true
sources = [ "configs/devel_environment" ]
outputs = [ "data/cobalt_environment" ]
}
resource("analyzer_devel_public") {
# Cobalt 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 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 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 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",
":component-v2",
":shuffler_devel_public",
":shuffler_prod_public",
]
if (cobalt_environment != false) {
deps += [ ":cobalt_environment" ]
}
}
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 = [
"aggregate_and_upload_impl_test.cc",
"cobalt_app_test.cc",
"cobalt_controller_impl_test.cc",
"configuration_data_test.cc",
"current_channel_provider_test.cc",
"diagnostics_impl_test.cc",
"metric_event_logger_impl_test.cc",
"system_data_updater_impl_test.cc",
"user_consent_watcher_test.cc",
]
deps = [
":lib",
":testapp_metrics_registry_cc",
"//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt_hlcpp",
"//sdk/lib/inspect/component/cpp",
"//sdk/lib/inspect/testing/cpp",
"//sdk/lib/sys/cpp/testing:unit",
"//src/cobalt/bin/testing:fake_clock_lib",
"//src/cobalt/bin/testing:fake_http_loader",
"//src/lib/cobalt/cpp:metric_event_builder",
"//src/lib/fsl",
"//src/lib/fxl/test:gtest_main",
"//src/lib/testing/loop_fixture",
"//src/lib/testing/predicates",
"//third_party/cobalt/src/logger:fake_logger",
"//third_party/cobalt/src/logger:logger_test_utils",
"//third_party/cobalt/src/public/lib:report_spec",
"//third_party/cobalt/src/public/testing:fake_cobalt_service",
"//third_party/googletest:gmock",
]
}