| # 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("//components/metrics/structured/buildflags/buildflags.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. |
| source_set("structured") { |
| sources = [ |
| "key_data_prefs_delegate.cc", |
| "key_data_prefs_delegate.h", |
| "key_data_provider_file.cc", |
| "key_data_provider_file.h", |
| "key_data_provider_prefs.cc", |
| "key_data_provider_prefs.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_recorder.cc", |
| "structured_metrics_recorder.h", |
| "structured_metrics_scheduler.cc", |
| "structured_metrics_scheduler.h", |
| "structured_metrics_service.cc", |
| "structured_metrics_service.h", |
| ] |
| |
| if (is_chromeos) { |
| sources += [ |
| "flushed_map.cc", |
| "flushed_map.h", |
| "storage_manager.cc", |
| "storage_manager.h", |
| ] |
| } |
| |
| public_deps = [ |
| ":common", |
| ":events", |
| ":proto", |
| "//components/metrics/structured/buildflags", |
| "//components/metrics/structured/lib:proto", |
| "//third_party/metrics_proto", |
| ] |
| |
| deps = [ |
| ":structured_events", |
| ":structured_metrics_validator", |
| "//base", |
| "//components/metrics", |
| "//components/metrics/structured/lib", |
| "//components/metrics/structured/lib:proto", |
| "//components/metrics/structured/mojom", |
| "//components/prefs", |
| "//crypto", |
| "//third_party/protobuf:protobuf_lite", |
| ] |
| } |
| |
| if (is_chromeos) { |
| source_set("external_metrics") { |
| sources = [ |
| "external_metrics.cc", |
| "external_metrics.h", |
| ] |
| deps = [ |
| ":common", |
| ":proto", |
| ":structured_events", |
| "//base", |
| ] |
| } |
| } |
| |
| component("events") { |
| output_name = "metrics_structured" |
| defines = [ "IS_METRICS_STRUCTURED_IMPL" ] |
| |
| sources = [ |
| "enums.h", |
| "event.cc", |
| "event.h", |
| "structured_metrics_client.cc", |
| "structured_metrics_client.h", |
| ] |
| deps = [ |
| "//base", |
| "//build:buildflag_header_h", |
| ] |
| } |
| |
| proto_library("proto") { |
| # These protos are only used internally, so make them visible only to |
| # subdirectories. |
| visibility = [ "./*" ] |
| proto_in_dir = "//" |
| generate_python = false |
| sources = [ "proto/event_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" ] |
| deps = [ "//third_party/metrics_proto" ] |
| } |
| |
| # Sources used by all source sets in this BUILD file. |
| source_set("common") { |
| sources = [ |
| "delegating_events_processor.cc", |
| "delegating_events_processor.h", |
| "events_processor_interface.h", |
| "histogram_util.cc", |
| "histogram_util.h", |
| "recorder.cc", |
| "recorder.h", |
| ] |
| |
| public_deps = [ |
| ":events", |
| ":structured_metrics_features", |
| ] |
| |
| deps = [ |
| ":proto", |
| ":structured_metrics_validator", |
| "//base", |
| "//components/metrics/structured/lib", |
| "//components/prefs", |
| "//third_party/metrics_proto", |
| ] |
| } |
| |
| source_set("structured_metrics_features") { |
| sources = [ |
| "structured_metrics_features.cc", |
| "structured_metrics_features.h", |
| ] |
| |
| public_deps = [ "//base" ] |
| } |
| |
| action("gen_structured_events_cpp") { |
| script = "//tools/metrics/structured/gen_events.py" |
| |
| # Re-generate the outputs if the codegen code changes: |
| inputs = [ |
| "//tools/metrics/structured/code_generator_cpp.py", |
| "//tools/metrics/structured/code_generator.py", |
| "//tools/metrics/structured/codegen_util.py", |
| "//tools/metrics/structured/gen_events.py", |
| "//tools/metrics/structured/sync/model.py", |
| "//tools/metrics/structured/sync/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), |
| "--target", |
| "chromium", |
| ] |
| } |
| |
| action("gen_structured_events_ts") { |
| script = "//tools/metrics/structured/gen_events.py" |
| |
| # Re-generate the outputs if the codegen code changes: |
| inputs = [ |
| "//tools/metrics/structured/code_generator_ts.py", |
| "//tools/metrics/structured/code_generator.py", |
| "//tools/metrics/structured/codegen_util.py", |
| "//tools/metrics/structured/gen_events.py", |
| "//tools/metrics/structured/sync/model.py", |
| "//tools/metrics/structured/sync/model_util.py", |
| "//tools/metrics/structured/templates_events.py", |
| ] |
| sources = [ "//tools/metrics/structured/sync/structured.xml" ] |
| |
| outdir = "$target_gen_dir" |
| |
| outputs = [ outdir + "/structured_events.ts" ] |
| |
| args = [ |
| "--input", |
| rebase_path(sources[0], root_build_dir), |
| "--output", |
| rebase_path(outdir, root_build_dir), |
| "--target", |
| "webui", |
| ] |
| } |
| |
| # TODO(b/309122738): Generate the events by platform. |
| source_set("structured_events") { |
| sources = get_target_outputs(":gen_structured_events_cpp") |
| |
| public_deps = [ |
| ":events", |
| "//components/metrics/structured/buildflags", |
| ] |
| |
| deps = [ |
| ":gen_structured_events_cpp", |
| "//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/code_generator_cpp.py", |
| "//tools/metrics/structured/codegen_util.py", |
| "//tools/metrics/structured/gen_validator.py", |
| "//tools/metrics/structured/sync/model.py", |
| "//tools/metrics/structured/sync/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), |
| ] |
| |
| if (is_chromeos) { |
| sources += [ "//tools/metrics/structured/sync/structured_chromiumos.xml" ] |
| |
| args += [ |
| "--cros_input", |
| rebase_path(sources[1], root_build_dir), |
| ] |
| } |
| } |
| |
| source_set("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", |
| "//third_party/metrics_proto", |
| ] |
| } |
| |
| source_set("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", |
| "test/test_structured_metrics_recorder.cc", |
| "test/test_structured_metrics_recorder.h", |
| ] |
| |
| deps = [ |
| ":structured", |
| ":structured_metrics_validator", |
| "//base", |
| "//base/test:test_support", |
| "//components/metrics", |
| "//components/metrics/structured/lib", |
| ] |
| } |
| |
| source_set("unit_tests") { |
| testonly = true |
| sources = [ |
| "key_data_prefs_delegate_unittest.cc", |
| "structured_metrics_recorder_unittest.cc", |
| "structured_metrics_service_unittest.cc", |
| ] |
| |
| if (is_chromeos) { |
| sources += [ "flushed_map_unittest.cc" ] |
| } |
| |
| deps = [ |
| ":events", |
| ":proto", |
| ":structured", |
| ":structured_events", |
| ":structured_metrics_validator", |
| ":test_support", |
| "//base", |
| "//base/test:test_support", |
| "//components/metrics", |
| "//components/metrics:test_support", |
| "//components/metrics/structured/lib", |
| "//components/metrics/structured/lib:proto", |
| "//components/prefs", |
| "//components/prefs:test_support", |
| "//testing/gtest", |
| ] |
| |
| if (is_chromeos) { |
| sources += [ "external_metrics_unittest.cc" ] |
| |
| deps += [ ":external_metrics" ] |
| } |
| } |
| |
| # Convenience testing target |
| test("structured_metrics_unittests") { |
| deps = [ |
| ":unit_tests", |
| "//components/metrics/structured/lib:unit_tests", |
| "//components/metrics/structured/mojom:unit_tests", |
| "//components/test:run_all_unittests", |
| ] |
| } |