| # Copyright 2019 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/python.gni") |
| import("//testing/test.gni") |
| import("//third_party/protobuf/proto_library.gni") |
| |
| # Structured metrics is subcomponent of UMA that gathers and reports structured |
| # events with several attached metrics. |
| static_library("structured") { |
| sources = [ |
| "event_storage.cc", |
| "event_storage.h", |
| "key_data.cc", |
| "key_data.h", |
| "key_data_provider.cc", |
| "key_data_provider.h", |
| "key_data_provider_file.cc", |
| "key_data_provider_file.h", |
| "persistent_proto.cc", |
| "persistent_proto.h", |
| "reporting/structured_metrics_log_metrics.cc", |
| "reporting/structured_metrics_log_metrics.h", |
| "reporting/structured_metrics_reporting_service.cc", |
| "reporting/structured_metrics_reporting_service.h", |
| "structured_metrics_prefs.cc", |
| "structured_metrics_prefs.h", |
| "structured_metrics_provider.cc", |
| "structured_metrics_provider.h", |
| "structured_metrics_recorder.cc", |
| "structured_metrics_recorder.h", |
| "structured_metrics_scheduler.cc", |
| "structured_metrics_scheduler.h", |
| "structured_metrics_service.cc", |
| "structured_metrics_service.h", |
| ] |
| |
| public_deps = [ |
| ":common", |
| ":events", |
| ":storage", |
| "//third_party/metrics_proto", |
| ] |
| |
| deps = [ |
| ":structured_events", |
| ":structured_metrics_validator", |
| "//base", |
| "//components/metrics", |
| "//components/metrics/structured/mojom", |
| "//components/prefs", |
| "//crypto", |
| ] |
| } |
| |
| if (is_chromeos_ash) { |
| static_library("external_metrics") { |
| sources = [ |
| "external_metrics.cc", |
| "external_metrics.h", |
| ] |
| deps = [ |
| ":common", |
| ":storage", |
| ":structured_events", |
| "//base", |
| ] |
| } |
| } |
| |
| static_library("events") { |
| sources = [ |
| "delegating_events_processor.cc", |
| "delegating_events_processor.h", |
| "enums.h", |
| "event.cc", |
| "event.h", |
| "events_processor_interface.h", |
| "structured_metrics_client.cc", |
| "structured_metrics_client.h", |
| ] |
| deps = [ |
| "//base", |
| "//third_party/metrics_proto", |
| ] |
| } |
| |
| proto_library("storage") { |
| # These protos are only used internally, so make them visible only to |
| # subdirectories. |
| visibility = [ "./*" ] |
| proto_in_dir = "//" |
| generate_python = false |
| sources = [ "storage.proto" ] |
| |
| # This is required because metrics_proto/BUILD.gn sets proto_in_dir as ".", |
| # which means protos can't be referred to by absolute paths from within other |
| # protos. |
| import_dirs = [ "//third_party/metrics_proto" ] |
| proto_deps = [ "//third_party/metrics_proto" ] |
| link_deps = [ "//third_party/metrics_proto" ] |
| } |
| |
| # Sources used by all static libraries in this BUILD file. |
| source_set("common") { |
| sources = [ |
| "histogram_util.cc", |
| "histogram_util.h", |
| "recorder.cc", |
| "recorder.h", |
| ] |
| |
| public_deps = [ |
| ":events", |
| ":structured_metrics_features", |
| ] |
| |
| deps = [ |
| ":storage", |
| ":structured_metrics_validator", |
| "//base", |
| "//components/prefs", |
| "//third_party/metrics_proto", |
| ] |
| } |
| |
| static_library("structured_metrics_features") { |
| sources = [ |
| "structured_metrics_features.cc", |
| "structured_metrics_features.h", |
| ] |
| |
| public_deps = [ "//base" ] |
| } |
| |
| action("gen_structured_events") { |
| script = "//tools/metrics/structured/gen_events.py" |
| |
| # Re-generate the outputs if the codegen code changes: |
| inputs = [ |
| "//tools/metrics/structured/codegen.py", |
| "//tools/metrics/structured/gen_events.py", |
| "//tools/metrics/structured/model.py", |
| "//tools/metrics/structured/model_util.py", |
| "//tools/metrics/structured/templates_events.py", |
| ] |
| sources = [ "//tools/metrics/structured/sync/structured.xml" ] |
| |
| outdir = "$target_gen_dir" |
| |
| outputs = [ |
| outdir + "/structured_events.cc", |
| outdir + "/structured_events.h", |
| ] |
| |
| args = [ |
| "--input", |
| rebase_path(sources[0], root_build_dir), |
| "--output", |
| rebase_path(outdir, root_build_dir), |
| ] |
| } |
| |
| # TODO(b/309122738): Generate the events by platform. |
| static_library("structured_events") { |
| sources = get_target_outputs(":gen_structured_events") |
| |
| deps = [ |
| ":common", |
| ":gen_structured_events", |
| "//base", |
| ] |
| } |
| |
| action("gen_structured_metrics_validator") { |
| script = "//tools/metrics/structured/gen_validator.py" |
| |
| # Re-generate the outputs if the codegen code changes: |
| inputs = [ |
| "//tools/metrics/structured/codegen.py", |
| "//tools/metrics/structured/gen_validator.py", |
| "//tools/metrics/structured/model.py", |
| "//tools/metrics/structured/model_util.py", |
| "//tools/metrics/structured/templates_validator.py", |
| ] |
| sources = [ "//tools/metrics/structured/sync/structured.xml" ] |
| |
| outdir = "$target_gen_dir" |
| |
| outputs = [ |
| outdir + "/structured_metrics_validator.cc", |
| outdir + "/structured_metrics_validator.h", |
| ] |
| |
| args = [ |
| "--input", |
| rebase_path(sources[0], root_build_dir), |
| "--output", |
| rebase_path(outdir, root_build_dir), |
| ] |
| } |
| |
| static_library("structured_metrics_validator") { |
| sources = get_target_outputs(":gen_structured_metrics_validator") + [ |
| "event_validator.cc", |
| "event_validator.h", |
| "project_validator.cc", |
| "project_validator.h", |
| ] |
| |
| deps = [ |
| ":events", |
| ":gen_structured_metrics_validator", |
| "//base", |
| ] |
| } |
| |
| static_library("test_support") { |
| testonly = true |
| sources = [ |
| "test/test_event_storage.cc", |
| "test/test_event_storage.h", |
| "test/test_key_data_provider.cc", |
| "test/test_key_data_provider.h", |
| "test/test_structured_metrics_provider.cc", |
| "test/test_structured_metrics_provider.h", |
| ] |
| deps = [ |
| ":structured", |
| ":structured_metrics_validator", |
| "//base", |
| "//base/test:test_support", |
| "//components/metrics:metrics", |
| ] |
| } |
| |
| source_set("unit_tests") { |
| testonly = true |
| sources = [ |
| "key_data_unittest.cc", |
| "persistent_proto_unittest.cc", |
| "structured_metrics_provider_unittest.cc", |
| "structured_metrics_recorder_unittest.cc", |
| "structured_metrics_service_unittest.cc", |
| ] |
| |
| deps = [ |
| ":events", |
| ":storage", |
| ":structured", |
| ":structured_events", |
| ":structured_metrics_validator", |
| ":test_support", |
| "//base", |
| "//base/test:test_support", |
| "//components/metrics", |
| "//components/metrics:test_support", |
| "//components/prefs", |
| "//components/prefs:test_support", |
| "//testing/gtest", |
| ] |
| |
| if (is_chromeos_ash) { |
| sources += [ "external_metrics_unittest.cc" ] |
| |
| deps += [ ":external_metrics" ] |
| } |
| } |
| |
| # Convenience testing target |
| test("structured_metrics_unittests") { |
| deps = [ |
| ":unit_tests", |
| "//components/metrics/structured/mojom:unit_tests", |
| "//components/test:run_all_unittests", |
| ] |
| } |