forked from google/perfetto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.gn
334 lines (301 loc) · 11.1 KB
/
BUILD.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# 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("gn/perfetto.gni")
import("gn/test.gni")
# +----------------------------------------------------------------------------+
# | "all" targets definition: defines targets reachable by the various configs |
# +----------------------------------------------------------------------------+
# There is a subtletly here related with chromium and other GN embedders.
# When adding a dependency some_dir/:target_name, some_dir/BUILD.gn is
# "discovered". As a side effect any *other* target defined in some_dir/BUILD.gn
# (and its transitive dependencies) becomes implicitly part of the "default"
# target, the one invoked running ninja -C out/xxx without further args.
# Because of this, care must be taken to wrap dependencies to targets in other
# build files with if (enable_xxx) flags. Accidentally including a harmless
# target that happens to be defined in the same BUILD.gn that contains targets
# incompatible with the chromium build will cause build/roll failures.
all_targets = [ "protos/perfetto/trace:perfetto_trace_protos" ]
if (enable_perfetto_platform_services) {
all_targets += [
"src/perfetto_cmd:perfetto",
"src/perfetto_cmd:trigger_perfetto",
"src/traced/service:traced",
]
if (enable_perfetto_traced_probes) {
all_targets += [ "src/traced/probes:traced_probes" ]
}
if (enable_perfetto_traced_relay) {
all_targets += [ "src/traced_relay:traced_relay" ]
}
}
if (enable_perfetto_trace_processor && enable_perfetto_trace_processor_sqlite) {
all_targets += [ "src/bigtrace" ]
all_targets += [ "src/trace_processor:trace_processor_shell" ]
}
if (enable_perfetto_traceconv) {
all_targets += [ "src/traceconv" ]
if (is_cross_compiling) {
# In many cross-compilation scenarios (typically Android) developers expect
# the host version of traceconv to be available somewhere in out/, so
# they can convert Android traces on their dev machine. Also
# tools/gen_android_bp explicitly depends on the host version for the
# cc_binary_host("traceconv") target in Android.bp.
# Note that when cross-compiling the host executable will be available in
# out/xxx/gcc_like_host/traceconv NOT just out/xxx/traceconv.
all_targets += [ "src/traceconv($host_toolchain)" ]
}
}
if (enable_perfetto_heapprofd) {
all_targets += [ "src/profiling/memory:heapprofd" ]
if (is_linux && !is_android) {
all_targets += [ "src/profiling/memory:heapprofd_glibc_preload" ]
}
if (perfetto_build_with_android) {
all_targets += [
"src/profiling/memory:heapprofd_client",
"src/profiling/memory:heapprofd_client_api",
]
}
}
if (enable_perfetto_traced_perf) {
all_targets += [ "src/profiling/perf:traced_perf" ]
}
if (perfetto_build_with_android) {
all_targets += [ "src/android_internal:libperfetto_android_internal" ]
}
if (enable_perfetto_tools) {
all_targets += [ "src/tools" ]
# Windows does not have an IPC implementation.
if (!is_win) {
all_targets += [ "src/websocket_bridge" ]
}
}
if (enable_perfetto_unittests) {
import("gn/perfetto_unittests.gni")
test("perfetto_unittests") {
if (is_fuchsia) {
additional_manifest_fragments =
[ "//build/config/fuchsia/test/network.shard.test-cml" ]
}
deps = perfetto_unittests_targets
}
all_targets += [ ":perfetto_unittests" ]
}
if (enable_perfetto_integration_tests) {
import("gn/perfetto_integrationtests.gni")
test("perfetto_integrationtests") {
deps = perfetto_integrationtests_targets
}
all_targets += [
":perfetto_integrationtests",
"examples/sdk:sdk_example",
"test:client_api_example",
"test/stress_test",
]
if (!is_win && !is_mac) {
all_targets += [
"examples/shared_lib:example_shlib_data_source",
"examples/shared_lib:example_shlib_track_event",
]
}
}
if (enable_perfetto_trace_processor_json) {
test("trace_processor_minimal_smoke_tests") {
testonly = true
deps = [
"gn:default_deps",
"src/trace_processor:storage_minimal_smoke_tests",
]
}
all_targets += [ ":trace_processor_minimal_smoke_tests" ]
}
if (enable_perfetto_benchmarks) {
import("gn/perfetto_benchmarks.gni")
executable("perfetto_benchmarks") {
testonly = true
deps = perfetto_benchmarks_targets
}
all_targets += [ ":perfetto_benchmarks" ]
}
if (enable_perfetto_fuzzers) {
import("gn/perfetto_fuzzers.gni")
group("fuzzers") {
testonly = true
deps = perfetto_fuzzers_targets
}
all_targets += [ ":fuzzers" ]
}
# Less interesting stuff that makes sense only in the standalone build, mainly
# compile-time checks for the CI.
if (perfetto_build_standalone) {
all_targets += [
"test/configs",
# Used to evaluate the Python folder for Bazel script generation.
"python:trace_processor_py",
# For syntax-checking the protos.
"protos/perfetto/trace:merged_trace_lite",
# For checking all generated xxx.gen.{cc,h} files without waiting for
# embedders to try to use them and fail.
"protos/perfetto/config:cpp",
"protos/perfetto/common:cpp",
# Used in the when updating the ftrace protos
"protos/perfetto/trace/ftrace:descriptor",
# Checks that the "fake" backend implementations build.
"src/tracing:client_api_no_backends_compile_test",
]
if (is_linux || is_android || is_mac) {
all_targets += [ "src/tracebox" ]
}
}
# The CTS code is built (but not ran) also in standalone builds. This is to
# catch refactoring breakages earlier without having to wait for treehugger.
if (is_android && (perfetto_build_standalone || perfetto_build_with_android)) {
all_targets += [ "test/cts:perfetto_cts_deps" ]
all_targets += [ "test/vts:perfetto_vts_deps" ]
}
group("all") {
testonly = true # allow to build also test targets
deps = all_targets
}
# This target is used when running ninja without any argument (by default would
# build all reachable targets). This is mainly used to prevent the UI being
# built when running ninja -C out/xxx.
# This has effect only in standalone builds, no effect on chromium builds.
# Chromium's "all" target depends on our "all" target above. However chromium's
# "default" target depends on any target that we cause to be discovered by
# depending on other GN files.
group("default") {
testonly = true
deps = [ ":all" ]
}
# +----------------------------------------------------------------------------+
# | Other definitions: root targets that don't belong to any other subdirectory|
# +----------------------------------------------------------------------------+
if (enable_perfetto_ui) {
group("ui") {
deps = [ "ui" ]
}
}
if (enable_perfetto_site) {
group("site") {
deps = [ "infra/perfetto.dev:site" ]
}
}
# In Android builds, we build the code of traced and traced_probes in one shared
# library that exposes one xxx_main() for each. The executables themselves are
# tiny shells that just invoke their own entry point into the library.
# This is done merely for saving binary size, because the three binaries happen
# to share a lot of code.
# When setting monolithic_binaries=true (only supported in standalone builds)
# it builds more conventional executables, where each binary has the full
# implementation and no shared library dependency. This is to make dev cycles
# on Android faster, avoiding all the LD_LIBRARY_PATH boilerplate.
# libperfetto.so is also used for stuff that is exposed to the rest of the
# Android tree.
if (enable_perfetto_platform_services) {
if (monolithic_binaries) {
libperfetto_target_type = "static_library"
} else {
libperfetto_target_type = "shared_library"
}
target(libperfetto_target_type, "libperfetto") {
if (libperfetto_target_type == "static_library") {
complete_static_lib = true
}
deps = [
"gn:default_deps",
"src/traced/service",
]
if (enable_perfetto_traced_probes) {
deps += [ "src/traced/probes" ]
}
}
}
if (!build_with_chromium) {
# Client library target exposed to the Android tree.
# Still in experimental stage and not API stable yet.
# See "libperfetto_client_example" (in Android.bp.extras) for an example
# on how to use the Perfetto Client API from the android tree.
static_library("libperfetto_client_experimental") {
complete_static_lib = true
public_deps = [
"gn:default_deps",
"src/tracing:client_api",
"src/tracing:platform_impl",
]
sources = [ "include/perfetto/tracing.h" ]
assert_no_deps = [ "//gn:protobuf_lite" ]
}
}
# TODO(primiano): there seem to be two "libperfetto" and one
# "libperfetto_client_experimental" targets defined within this BUILD.gn file.
# Rationalize them with eseckler@. For now seems this one is only used from
# chromium and the other one only from the Android tree.
if (build_with_chromium) {
component("libperfetto") {
public_configs = [ "gn:public_config" ]
deps = [
"src/trace_processor/importers/memory_tracker:graph_processor",
"src/tracing:client_api",
"src/tracing:platform_impl",
"src/tracing/core",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_deps = [
"include/perfetto/ext/trace_processor/importers/memory_tracker",
"include/perfetto/ext/tracing/core",
"include/perfetto/tracing",
"protos/perfetto/common:zero",
"protos/perfetto/trace:zero",
"protos/perfetto/trace/chrome:zero",
"protos/perfetto/trace/interned_data:zero",
"protos/perfetto/trace/profiling:zero",
"protos/perfetto/trace/ps:zero",
"protos/perfetto/trace/track_event:zero",
]
if (enable_perfetto_ipc) {
deps += [
"src/tracing/ipc/producer",
"src/tracing/ipc/service",
]
public_deps += [ "include/perfetto/ext/tracing/ipc:ipc" ]
}
if (!is_nacl) {
deps += [
"src/trace_processor:export_json",
"src/trace_processor:storage_minimal",
]
public_deps += [
"include/perfetto/ext/trace_processor:export_json",
"include/perfetto/trace_processor:storage",
]
}
}
component("libtrace_processor") {
public_configs = [ "gn:public_config" ]
deps = [ "src/trace_processor:lib" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_deps = [ "include/perfetto/trace_processor" ]
}
component("perfetto_test_support") {
testonly = true
public_configs = [ "gn:public_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_deps = [ "include/perfetto/test:test_support" ]
deps = [ "src/tracing/test:test_support" ]
}
}