chromium/services/metrics/public/cpp/BUILD.gn

# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//mojo/public/tools/bindings/mojom.gni")

component("metrics_cpp") {
  sources = [
    "delegating_ukm_recorder.cc",
    "delegating_ukm_recorder.h",
    "metrics_export.h",
    "metrics_utils.cc",
    "metrics_utils.h",
    "mojo_ukm_recorder.cc",
    "mojo_ukm_recorder.h",
    "ukm_entry_builder.cc",
    "ukm_entry_builder.h",
    "ukm_entry_builder_base.cc",
    "ukm_entry_builder_base.h",
    "ukm_recorder.cc",
    "ukm_recorder.h",
    "ukm_recorder_client_interface_registry.cc",
    "ukm_recorder_client_interface_registry.h",
    "ukm_recorder_impl_utils.cc",
    "ukm_recorder_impl_utils.h",
    "ukm_source.cc",
    "ukm_source.h",
    "ukm_source_id.cc",
    "ukm_source_id.h",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  defines = [ "METRICS_IMPLEMENTATION" ]

  public_deps = [
    "//base",
    "//net",
    "//services/metrics/public/mojom",
    "//url",
  ]

  deps = [
    "//mojo/public/cpp/bindings",
    "//third_party/metrics_proto",
  ]
}

source_set("tests") {
  testonly = true

  sources = [
    "metrics_utils_unittest.cc",
    "ukm_entry_builder_unittest.cc",
    "ukm_source_id_unittest.cc",
  ]

  deps = [
    ":metrics_cpp",
    "//base",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

action("gen_ukm_builders") {
  script = "//tools/metrics/ukm/gen_builders.py"

  # Re-generate the outputs if the codegen code changes:
  inputs = [
    "//tools/metrics/ukm/builders_template.py",
    "//tools/metrics/ukm/decode_template.py",
    "//tools/metrics/ukm/codegen.py",
  ]
  sources = [ "//tools/metrics/ukm/ukm.xml" ]

  outdir = "$target_gen_dir"

  outputs = [
    outdir + "/ukm_builders.cc",
    outdir + "/ukm_builders.h",
    outdir + "/ukm_decode.cc",
    outdir + "/ukm_decode.h",
  ]

  args = [
    "--input",
    rebase_path(sources[0], root_build_dir),
    "--output",
    rebase_path(outdir, root_build_dir),
  ]
}

static_library("ukm_builders") {
  sources = get_target_outputs(":gen_ukm_builders")

  deps = [
    ":gen_ukm_builders",
    ":metrics_cpp",
    "//base",
  ]
}