• 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("../../gn/fuzzer.gni")
16import("../../gn/perfetto.gni")
17import("../../gn/test.gni")
18
19# Full version of the client API. Supports both the in-process backend and the
20# system backend (on posix systems and if enabled by the enable_perfetto_ipc).
21# The backends are designed to be dead-code-eliminated via linker's gc-section
22# when not use. See comments in Tracing::Initialize() in tracing.h.
23group("client_api") {
24  public_deps = [
25    ":client_api_without_backends",
26    ":in_process_backend",
27    "../../gn:default_deps",
28    "../../include/perfetto/tracing",
29    "../../include/perfetto/tracing/core",
30  ]
31  if (enable_perfetto_ipc) {
32    public_deps += [ ":system_backend" ]
33  } else {
34    public_deps += [ ":system_backend_fake" ]
35  }
36}
37
38# This target checks that the client API builds without backends. This is to
39# check that no references to the backends are leaked from the implementation
40# internals. In turn, this allows to dead-code-eliminate unused backends when
41# using linker's gc-sections (or similar mechanism).
42if (perfetto_build_standalone) {
43  shared_library("client_api_no_backends_compile_test") {
44    deps = [
45      ":client_api_without_backends",
46      "../../gn:default_deps",
47    ]
48  }
49}
50
51# Some .gn build files outside of this repo (v8, webrtc) still reference this
52# target.
53source_set("platform_impl") {
54  deps = [ "../../gn:default_deps" ]
55  sources = []
56}
57
58# Code that both public headers and other non-public sources (e.g.
59# src/tracing/core) need to depend on. It cannot be in the root :tracing target
60# otherwise there would be a cyclic dependency because public itself needs to
61# depend on tracing.
62source_set("common") {
63  deps = [
64    "../../gn:default_deps",
65    "../../include/perfetto/tracing",
66  ]
67  sources = [ "trace_writer_base.cc" ]
68}
69
70# Base target for the client API. On its own doesn't provide any backend other
71# than the unsupported one.
72source_set("client_api_without_backends") {
73  deps = [
74    "../../include/perfetto/tracing/core",
75    "../../protos/perfetto/common:zero",
76    "../../protos/perfetto/config:cpp",
77    "../../protos/perfetto/config/interceptors:cpp",
78    "../../protos/perfetto/config/track_event:cpp",
79    "../base",
80    "core",
81  ]
82  public_deps = [
83    "../../gn:default_deps",
84    "../../include/perfetto/tracing",
85  ]
86  sources = [
87    "console_interceptor.cc",
88    "data_source.cc",
89    "debug_annotation.cc",
90    "event_context.cc",
91    "interceptor.cc",
92    "internal/checked_scope.cc",
93    "internal/interceptor_trace_writer.cc",
94    "internal/tracing_backend_fake.cc",
95    "internal/tracing_muxer_fake.cc",
96    "internal/tracing_muxer_fake.h",
97    "internal/tracing_muxer_impl.cc",
98    "internal/tracing_muxer_impl.h",
99    "internal/track_event_internal.cc",
100    "internal/track_event_interned_fields.cc",
101    "platform.cc",
102    "platform_posix.cc",
103    "platform_windows.cc",
104    "traced_value.cc",
105    "tracing.cc",
106    "tracing_policy.cc",
107    "track.cc",
108    "track_event_category_registry.cc",
109    "track_event_legacy.cc",
110    "track_event_state_tracker.cc",
111    "virtual_destructors.cc",
112  ]
113  assert_no_deps = [ "service" ]
114  if (enable_perfetto_ipc) {
115    assert_no_deps += [
116      "../ipc:common",
117      "ipc/common",
118    ]
119  }
120}
121
122# Separate target because the embedder might not want this.
123source_set("integrationtests") {
124  testonly = true
125  deps = [
126    "../../gn:default_deps",
127    "../../gn:gtest_and_gmock",
128    "../../include/perfetto/ext/tracing/ipc",
129    "../../include/perfetto/tracing",
130    "../../protos/perfetto/trace:cpp",
131    "../base",
132    "../base:test_support",
133  ]
134  sources = [ "internal/tracing_muxer_impl_integrationtest.cc" ]
135}
136
137perfetto_unittest_source_set("unittests") {
138  testonly = true
139  deps = [
140    ":client_api_without_backends",
141    "../../gn:default_deps",
142    "../../gn:gtest_and_gmock",
143    "../../protos/perfetto/trace:lite",
144    "../../protos/perfetto/trace/track_event:lite",
145    "../base",
146    "../base:test_support",
147    "test:test_support",
148  ]
149
150  sources = []
151
152  # TODO(lalitm): this tests appear to be failing on Chromium for unknown
153  # reasons. Figure out why and reenable them.
154  if (!build_with_chromium) {
155    sources += [
156      "internal/interceptor_trace_writer_unittest.cc",
157      "traced_proto_unittest.cc",
158      "traced_value_unittest.cc",
159    ]
160  }
161}
162
163# System backend: connects to an external "traced" instance via a UNIX socket.
164# Requires the IPC layer and is supported only on posix systems.
165if (enable_perfetto_ipc) {
166  source_set("system_backend") {
167    public_deps = [ "../../include/perfetto/tracing" ]
168    deps = [
169      ":client_api_without_backends",
170      "../../gn:default_deps",
171      "../../include/perfetto/tracing/core",
172      "../base",
173      "ipc:common",
174      "ipc/producer",
175      "ipc/service",
176    ]
177    if (enable_perfetto_system_consumer) {
178      deps += [ "ipc/consumer" ]
179    }
180    sources = [ "internal/system_tracing_backend.cc" ]
181  }
182} else {
183  source_set("system_backend_fake") {
184    public_deps = [ "../../include/perfetto/tracing" ]
185    deps = [
186      "../../gn:default_deps",
187      "../base",
188    ]
189    sources = [ "internal/system_tracing_backend_fake.cc" ]
190  }
191}
192
193# In-process backend: starts the tracing service in-process on a dedicated
194# thread. It depends only on having a valid "platform" target. It has a larger
195# binary size cost because links in all the service code.
196source_set("in_process_backend") {
197  public_deps = [ "../../include/perfetto/tracing" ]
198  deps = [
199    ":client_api_without_backends",
200    "../../gn:default_deps",
201    "../../include/perfetto/tracing/core",
202    "../base",
203    "core",
204    "service",
205  ]
206  sources = [ "internal/in_process_tracing_backend.cc" ]
207}
208
209if (enable_perfetto_benchmarks) {
210  source_set("benchmarks") {
211    testonly = true
212    deps = [
213      "../..:libperfetto_client_experimental",
214      "../../gn:benchmark",
215      "../../gn:default_deps",
216    ]
217    sources = [ "api_benchmark.cc" ]
218  }
219}
220