chromium/components/tracing/BUILD.gn

# Copyright 2014 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_overrides/build.gni")
import("//testing/test.gni")

if (is_android) {
  component("graphics_provider") {
    sources = [
      "common/graphics_memory_dump_provider_android.cc",
      "common/graphics_memory_dump_provider_android.h",
      "tracing_export.h",
    ]

    defines = [ "TRACING_IMPLEMENTATION" ]

    deps = [ "//base" ]
  }
}

component("startup_tracing") {
  sources = [
    "common/background_tracing_state_manager.cc",
    "common/background_tracing_state_manager.h",
    "common/pref_names.cc",
    "common/pref_names.h",
    "common/trace_to_console.cc",
    "common/trace_to_console.h",
    "common/tracing_switches.cc",
    "common/tracing_switches.h",
    "tracing_export.h",
  ]

  if (is_win) {
    sources += [
      "common/etw_export_win.cc",
      "common/etw_export_win.h",
      "common/etw_system_data_source_win.cc",
      "common/etw_system_data_source_win.h",
    ]
  }

  defines = [ "TRACING_IMPLEMENTATION" ]

  deps = [
    "//base",
    "//components/prefs",
    "//third_party/perfetto:libperfetto",
  ]
}

component("background_tracing_metrics_provider") {
  sources = [
    "common/background_tracing_metrics_provider.cc",
    "common/background_tracing_metrics_provider.h",
    "tracing_export.h",
  ]

  defines = [ "TRACING_IMPLEMENTATION" ]

  deps = [
    "//base",
    "//components/metrics:content",
    "//content/public/browser",
    "//third_party/metrics_proto:metrics_proto",
  ]
}

component("background_tracing_utils") {
  sources = [
    "common/background_tracing_utils.cc",
    "common/background_tracing_utils.h",
  ]

  defines = [ "IS_BACKGROUND_TRACING_UTILS_IMPL" ]

  deps = [
    "//base",
    "//content/public/browser",
    "//third_party/snappy:snappy",
  ]
}

source_set("unit_tests") {
  testonly = true

  deps = [
    "//base/test:test_support",
    "//testing/gmock:gmock",
    "//testing/gtest",
  ]

  sources = [
    "common/background_tracing_state_manager_unittest.cc",
    "common/background_tracing_utils_unittest.cc",
  ]
  if (is_android) {
    sources += [ "common/graphics_memory_dump_provider_android_unittest.cc" ]
    deps += [ ":graphics_provider" ]
  }

  if (is_win) {
    sources += [ "common/etw_system_data_source_win_unittest.cc" ]
  }
  deps += [
    ":background_tracing_utils",
    ":startup_tracing",
    "//components/metrics:metrics",
    "//components/prefs:test_support",
    "//content/public/browser",
    "//content/test:test_support",
  ]
}

test("tracing_perftests") {
  sources = [
    "test/perf_test_helpers.cc",
    "test/perf_test_helpers.h",
    "test/trace_event_perftest.cc",
  ]
  deps = [
    "//base:base",
    "//base/test:test_support",
    "//base/test:test_support_perf",
    "//testing/gtest",
    "//testing/perf",
  ]

  data_deps = [
    # Needed for isolate script to execute.
    "//testing:run_perf_test",
  ]

  if (is_android) {
    deps += [ "//testing/android/native_test:native_test_native_code" ]
  }
}