• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import("//build_overrides/build.gni")
16import("../../gn/fuzzer.gni")
17import("../../gn/perfetto.gni")
18import("../../gn/test.gni")
19
20# Full version of the client API. Supports both the in-process backend and the
21# system backend (on posix systems and if enabled by the enable_perfetto_ipc).
22# The backends are designed to be dead-code-eliminated via linker's gc-section
23# when not use. See comments in Tracing::Initialize() in tracing.h.
24group("client_api") {
25  public_deps = [
26    ":client_api_without_backends",
27    ":in_process_backend",
28    "../../gn:default_deps",
29    "../../include/perfetto/tracing",
30    "../../include/perfetto/tracing/core",
31  ]
32  if (enable_perfetto_ipc) {
33    public_deps += [ ":system_backend" ]
34  }
35}
36
37# This target checks that the client API builds without backends. This is to
38# check that no references to the backends are leaked from the implementation
39# internals. In turn, this allows to dead-code-eliminate unused backends when
40# using linker's gc-sections (or similar mechanism).
41if (perfetto_build_standalone) {
42  shared_library("client_api_no_backends_compile_test") {
43    deps = [
44      ":client_api_without_backends",
45      ":platform_fake",
46      "../../gn:default_deps",
47    ]
48  }
49}
50
51# Separate target because the embedder might not want this (e.g. on Windows).
52if (is_linux || is_mac || is_android) {
53  source_set("platform_posix") {
54    deps = [
55      "../../gn:default_deps",
56      "../../include/perfetto/tracing",
57      "../base",
58    ]
59    sources = [ "platform_posix.cc" ]
60  }
61}
62
63# Fake platform that allows buiding the client lib on all OSes. You can only use
64# those parts of the client lib that do not use the platform.
65source_set("platform_fake") {
66  deps = [
67    "../../gn:default_deps",
68    "../../include/perfetto/tracing",
69  ]
70  sources = [ "platform_fake.cc" ]
71}
72
73# Code that both public headers and other non-public sources (e.g.
74# src/tracing/core) need to depend on. It cannot be in the root :tracing target
75# otherwise there would be a cyclic dependency because public itself needs to
76# depend on tracing.
77source_set("common") {
78  deps = [
79    "../../gn:default_deps",
80    "../../include/perfetto/tracing",
81  ]
82  sources = [ "trace_writer_base.cc" ]
83}
84
85# Base target for the client API. On its own doesn't provide any backend.
86source_set("client_api_without_backends") {
87  deps = [
88    "../../include/perfetto/tracing/core",
89    "../../protos/perfetto/common:zero",
90    "../../protos/perfetto/config:cpp",
91    "../../protos/perfetto/config/track_event:cpp",
92    "../base",
93    "core",
94  ]
95  public_deps = [
96    "../../gn:default_deps",
97    "../../include/perfetto/tracing",
98  ]
99  sources = [
100    "data_source.cc",
101    "debug_annotation.cc",
102    "event_context.cc",
103    "internal/tracing_muxer_impl.cc",
104    "internal/tracing_muxer_impl.h",
105    "internal/track_event_internal.cc",
106    "platform.cc",
107    "tracing.cc",
108    "track.cc",
109    "track_event_category_registry.cc",
110    "track_event_legacy.cc",
111    "virtual_destructors.cc",
112  ]
113  assert_no_deps = [ "core:service" ]
114  if (enable_perfetto_ipc) {
115    assert_no_deps += [
116      "../ipc:common",
117      "ipc/common",
118    ]
119  }
120}
121
122# System backend: connects to an external "traced" instance via a UNIX socket.
123# Requires the IPC layer and is supported only on posix systems.
124if (enable_perfetto_ipc) {
125  source_set("system_backend") {
126    public_deps = [ "../../include/perfetto/tracing" ]
127    deps = [
128      ":client_api_without_backends",
129      "../../gn:default_deps",
130      "../../include/perfetto/tracing/core",
131      "../base",
132      "ipc/consumer",
133      "ipc/producer",
134      "ipc/service",
135    ]
136    sources = [ "internal/system_tracing_backend.cc" ]
137  }
138}
139
140# In-process backend: starts the tracing service in-process on a dedicated
141# thread. It depends only on having a valid "platform" target. It has a larger
142# binary size cost because links in all the service code.
143source_set("in_process_backend") {
144  public_deps = [ "../../include/perfetto/tracing" ]
145  deps = [
146    ":client_api_without_backends",
147    "../../gn:default_deps",
148    "../../include/perfetto/tracing/core",
149    "../base",
150    "core:service",
151  ]
152  sources = [ "internal/in_process_tracing_backend.cc" ]
153}
154
155if (enable_perfetto_benchmarks) {
156  source_set("benchmarks") {
157    testonly = true
158    deps = [
159      ":platform_posix",
160      "../..:libperfetto_client_experimental",
161      "../../../../../gn:benchmark",
162      "../../../../../gn:default_deps",
163    ]
164    sources = [ "api_benchmark.cc" ]
165  }
166}
167