blob: ebf198ccbe3ed6a0311ecf55f8a6f1d5d262cc19 [file] [log] [blame]
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build_overrides/build.gni")
import("../../gn/fuzzer.gni")
import("../../gn/perfetto.gni")
import("../../gn/test.gni")
# Full version of the client API. Supports both the in-process backend and the
# system backend (on posix systems and if enabled by the enable_perfetto_ipc).
# The backends are designed to be dead-code-eliminated via linker's gc-section
# when not use. See comments in Tracing::Initialize() in tracing.h.
group("client_api") {
public_deps = [
":client_api_without_backends",
":in_process_backend",
"../../gn:default_deps",
"../../include/perfetto/tracing",
"../../include/perfetto/tracing/core",
]
if (enable_perfetto_ipc) {
public_deps += [ ":system_backend" ]
} else {
public_deps += [ ":system_backend_fake" ]
}
}
# This target checks that the client API builds without backends. This is to
# check that no references to the backends are leaked from the implementation
# internals. In turn, this allows to dead-code-eliminate unused backends when
# using linker's gc-sections (or similar mechanism).
if (perfetto_build_standalone) {
shared_library("client_api_no_backends_compile_test") {
deps = [
":client_api_without_backends",
":platform_fake",
"../../gn:default_deps",
]
}
}
# Separate target because the embedder might not want this.
source_set("platform_impl") {
deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
"../base",
]
sources = [
"platform_posix.cc",
"platform_windows.cc",
]
}
# Fake platform that allows buiding the client lib on all OSes. You can only use
# those parts of the client lib that do not use the platform.
source_set("platform_fake") {
deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
]
sources = [ "platform_fake.cc" ]
}
# Code that both public headers and other non-public sources (e.g.
# src/tracing/core) need to depend on. It cannot be in the root :tracing target
# otherwise there would be a cyclic dependency because public itself needs to
# depend on tracing.
source_set("common") {
deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
]
sources = [ "trace_writer_base.cc" ]
}
# Base target for the client API. On its own doesn't provide any backend other
# than the unsupported one.
source_set("client_api_without_backends") {
deps = [
"../../include/perfetto/tracing/core",
"../../protos/perfetto/common:zero",
"../../protos/perfetto/config:cpp",
"../../protos/perfetto/config/interceptors:zero",
"../../protos/perfetto/config/track_event:cpp",
"../base",
"core",
]
public_deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
]
sources = [
"console_interceptor.cc",
"data_source.cc",
"debug_annotation.cc",
"event_context.cc",
"interceptor.cc",
"internal/checked_scope.cc",
"internal/interceptor_trace_writer.cc",
"internal/tracing_backend_fake.cc",
"internal/tracing_muxer_fake.cc",
"internal/tracing_muxer_fake.h",
"internal/tracing_muxer_impl.cc",
"internal/tracing_muxer_impl.h",
"internal/track_event_internal.cc",
"internal/track_event_interned_fields.cc",
"platform.cc",
"traced_value.cc",
"tracing.cc",
"tracing_policy.cc",
"track.cc",
"track_event_category_registry.cc",
"track_event_legacy.cc",
"track_event_state_tracker.cc",
"virtual_destructors.cc",
]
assert_no_deps = [ "core:service" ]
if (enable_perfetto_ipc) {
assert_no_deps += [
"../ipc:common",
"ipc/common",
]
}
}
perfetto_unittest_source_set("unittests") {
testonly = true
deps = [
"../../protos/perfetto/trace:lite",
"../../protos/perfetto/trace/track_event:lite",
"../base",
"../base:test_support",
"test:test_support",
]
sources = []
# TODO(primiano): remove the build_with_chromium conditional once the root
# //BUILD.gn:libperfetto (in chromium) stops adding tracing:platform_fake.
# The problem is the following: in chrome builds we end up with duplicate
# symbol definitions in the test because both platorm (impl and fake) are
# present: impl added here and fake coming from chromium's base (full path:
# perfetto_unittests -> //(chromium)base:test_support -> //(chromium)base
# -> libperfetto -> platform_fake.
if (!build_with_chromium) {
deps += [
":client_api_without_backends",
":platform_impl",
]
sources += [
"traced_proto_unittest.cc",
"traced_value_unittest.cc",
]
}
}
# System backend: connects to an external "traced" instance via a UNIX socket.
# Requires the IPC layer and is supported only on posix systems.
if (enable_perfetto_ipc) {
source_set("system_backend") {
public_deps = [ "../../include/perfetto/tracing" ]
deps = [
":client_api_without_backends",
"../../gn:default_deps",
"../../include/perfetto/tracing/core",
"../base",
"ipc/consumer",
"ipc/producer",
"ipc/service",
]
sources = [ "internal/system_tracing_backend.cc" ]
}
} else {
source_set("system_backend_fake") {
public_deps = [ "../../include/perfetto/tracing" ]
deps = [
"../../gn:default_deps",
"../base",
]
sources = [ "internal/system_tracing_backend_fake.cc" ]
}
}
# In-process backend: starts the tracing service in-process on a dedicated
# thread. It depends only on having a valid "platform" target. It has a larger
# binary size cost because links in all the service code.
source_set("in_process_backend") {
public_deps = [ "../../include/perfetto/tracing" ]
deps = [
":client_api_without_backends",
"../../gn:default_deps",
"../../include/perfetto/tracing/core",
"../base",
"core:service",
]
sources = [ "internal/in_process_tracing_backend.cc" ]
}
if (enable_perfetto_benchmarks) {
source_set("benchmarks") {
testonly = true
deps = [
":platform_impl",
"../..:libperfetto_client_experimental",
"../../gn:benchmark",
"../../gn:default_deps",
]
sources = [ "api_benchmark.cc" ]
}
}