summaryrefslogtreecommitdiff
path: root/chromium/components/metrics/structured/BUILD.gn
blob: 0408de8e3a50ab6603c0ad787f864a63e4fc8de4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Copyright 2019 The Chromium 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/python.gni")
import("//testing/test.gni")

# Structured metrics is subcomponent of UMA that gathers and reports structured
# events with several attached metrics.
static_library("structured") {
  sources = [
    "event_base.cc",
    "event_base.h",
    "histogram_util.cc",
    "histogram_util.h",
    "key_data.cc",
    "key_data.h",
    "recorder.cc",
    "recorder.h",
    "structured_metrics_provider.cc",
    "structured_metrics_provider.h",
  ]

  public_deps = [ "//third_party/metrics_proto" ]

  deps = [
    ":structured_events",
    "//base",
    "//components/metrics",
    "//components/prefs",
    "//crypto",
  ]
}

# TODO(crbug.com/1112471): Get this to run cleanly under Python 3.
python2_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/compile_time_validation.py",
    "//tools/metrics/structured/events_template.py",
    "//tools/metrics/structured/gen_events.py",
  ]
  sources = [ "//tools/metrics/structured/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),
  ]
}

static_library("structured_events") {
  sources = get_target_outputs(":gen_structured_events")

  deps = [
    ":gen_structured_events",
    "//base",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "key_data_unittest.cc",
    "structured_metrics_provider_unittest.cc",
  ]

  deps = [
    ":structured",
    ":structured_events",
    "//base",
    "//base/test:test_support",
    "//components/prefs",
    "//testing/gtest",
  ]
}

# Convenience testing target
test("structured_metrics_unittests") {
  deps = [
    ":unit_tests",
    "//base",
    "//base/test:test_support",
    "//components/test:run_all_unittests",
  ]
}