blob: 278a678f598821d686650ecc71c36f98c78e4bfd [file] [log] [blame]
Primiano Tucciae2879e2017-09-27 11:02:09 +09001# 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
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080015import("gn/perfetto.gni")
Eric Secklera6ba1792019-01-02 12:51:00 +000016import("gn/test.gni")
Primiano Tucci4c5efa42018-10-23 13:15:13 +010017
Primiano Tucci02c11762019-08-30 00:57:59 +020018# +----------------------------------------------------------------------------+
19# | "all" targets definition: defines targets reachable by the various configs |
20# +----------------------------------------------------------------------------+
21# There is a subtletly here related with chromium and other GN embedders.
22# When adding a dependency some_dir/:target_name, some_dir/BUILD.gn is
23# "discovered". As a side effect any *other* target defined in some_dir/BUILD.gn
24# (and its transitive dependencies) becomes implicitly part of the "default"
25# target, the one invoked running ninja -C out/xxx without further args.
26# Because of this, care must be taken to wrap dependencies to targets in other
27# build files with if (enable_xxx) flags. Accidentally including a harmless
28# target that happens to be defined in the same BUILD.gn that contains targets
29# incompatible with the chromium build will cause build/roll failures.
30
31all_targets = [ "protos/perfetto/trace:perfetto_trace_protos" ]
32
33if (enable_perfetto_platform_services) {
34 all_targets += [
35 "src/perfetto_cmd:perfetto",
36 "src/perfetto_cmd:trigger_perfetto",
37 "src/traced/service:traced",
Primiano Tucci02c11762019-08-30 00:57:59 +020038 ]
Primiano Tuccia7f5a8e2021-01-02 17:10:50 +010039 if (enable_perfetto_traced_probes) {
40 all_targets += [ "src/traced/probes:traced_probes" ]
41 }
Primiano Tuccia1959712018-05-17 11:01:56 +010042}
43
Mikhail Khokhlov0f7e68d2020-01-16 15:39:27 +000044if (enable_perfetto_trace_processor && enable_perfetto_trace_processor_sqlite) {
Primiano Tucci02c11762019-08-30 00:57:59 +020045 all_targets += [ "src/trace_processor:trace_processor_shell" ]
Primiano Tuccif3837d52018-01-10 21:12:41 +000046}
Primiano Tucci02c11762019-08-30 00:57:59 +020047
48if (enable_perfetto_heapprofd) {
Florian Mayer7b759782020-10-09 14:01:30 +010049 all_targets += [
50 "src/profiling/memory:heapprofd",
Florian Mayer7c52b262021-01-13 12:44:53 +000051 "src/profiling/memory:heapprofd_glibc_preload",
Florian Mayer7b759782020-10-09 14:01:30 +010052 ]
Primiano Tucci02c11762019-08-30 00:57:59 +020053 if (perfetto_build_with_android) {
Florian Mayer23f79372020-06-16 14:37:06 +020054 all_targets += [
55 "src/profiling/memory:heapprofd_client",
56 "src/profiling/memory:heapprofd_client_api",
57 ]
Primiano Tucci02c11762019-08-30 00:57:59 +020058 }
59}
60
Ryan Savitskia76b3cc2019-11-20 16:25:24 +000061if (enable_perfetto_traced_perf) {
62 all_targets += [ "src/profiling/perf:traced_perf" ]
63}
64
Primiano Tucci02c11762019-08-30 00:57:59 +020065if (perfetto_build_with_android) {
Primiano Tucci94ca9a92021-01-14 11:16:15 +010066 all_targets += [ "src/android_internal:libperfetto_android_internal" ]
Primiano Tucci02c11762019-08-30 00:57:59 +020067}
68
69if (enable_perfetto_tools) {
70 all_targets += [ "tools" ]
71}
72
73if (enable_perfetto_unittests) {
74 import("gn/perfetto_unittests.gni")
75 test("perfetto_unittests") {
76 deps = perfetto_unittests_targets
77 }
78 all_targets += [ ":perfetto_unittests" ]
79}
80
81if (enable_perfetto_integration_tests) {
82 import("gn/perfetto_integrationtests.gni")
83 test("perfetto_integrationtests") {
84 deps = perfetto_integrationtests_targets
85 }
86 all_targets += [
87 ":perfetto_integrationtests",
88 "test:client_api_example",
Primiano Tucciff68cac2020-08-06 18:13:17 +020089 "test/stress_test",
Primiano Tucci02c11762019-08-30 00:57:59 +020090 ]
91}
92
Mikhail Khokhlov90f09f62019-12-17 12:53:51 +000093if (enable_perfetto_trace_processor_json) {
Stephen Nuskoaca77482020-01-10 15:47:06 +000094 test("trace_processor_minimal_smoke_tests") {
Mikhail Khokhlov90f09f62019-12-17 12:53:51 +000095 testonly = true
96 deps = [
97 "gn:default_deps",
98 "src/trace_processor:storage_minimal_smoke_tests",
99 ]
100 }
101 all_targets += [ ":trace_processor_minimal_smoke_tests" ]
102}
103
Primiano Tucci02c11762019-08-30 00:57:59 +0200104if (enable_perfetto_benchmarks) {
105 import("gn/perfetto_benchmarks.gni")
106 executable("perfetto_benchmarks") {
107 testonly = true
108 deps = perfetto_benchmarks_targets
109 }
110 all_targets += [ ":perfetto_benchmarks" ]
111}
112
113if (enable_perfetto_fuzzers) {
114 import("gn/perfetto_fuzzers.gni")
115 group("fuzzers") {
116 testonly = true
117 deps = perfetto_fuzzers_targets
118 }
119 all_targets += [ ":fuzzers" ]
120}
121
122# Less interesting stuff that makes sense only in the standalone build, mainly
123# compile-time checks for the CI.
124if (perfetto_build_standalone) {
125 all_targets += [
Primiano Tucci02c11762019-08-30 00:57:59 +0200126 "test/configs",
127
128 # For syntax-checking the proto.
129 "protos/perfetto/config:merged_config",
130 "protos/perfetto/trace:merged_trace", # For syntax-checking the proto.
131
Primiano Tucci57dd66b2019-10-15 23:09:04 +0100132 # For checking all generated xxx.gen.{cc,h} files without waiting for
133 # embedders to try to use them and fail.
Primiano Tucci57dd66b2019-10-15 23:09:04 +0100134 "protos/perfetto/config:cpp",
135 "protos/perfetto/common:cpp",
136
Primiano Tucci02c11762019-08-30 00:57:59 +0200137 # The diff testing framework depends on these descriptors.
Andrew Shulaev94d1bf22021-01-15 15:30:42 +0000138 "protos/perfetto/metrics:descriptor",
139 "protos/perfetto/trace:descriptor",
140 "protos/perfetto/trace:test_extensions_descriptor",
Primiano Tucci02c11762019-08-30 00:57:59 +0200141
142 # Used in the when updating the ftrace protos
143 "protos/perfetto/trace/ftrace:descriptor",
Primiano Tucci55b4d912020-01-28 11:17:51 +0000144
145 # Checks that the "fake" backend implementations build.
146 "src/tracing:client_api_no_backends_compile_test",
Primiano Tucci02c11762019-08-30 00:57:59 +0200147 ]
Primiano Tucci42433ab2020-11-30 18:42:01 +0100148 if (is_linux || is_android) {
149 all_targets += [ "src/tracing/consumer_api_deprecated:consumer_api_test" ]
150 }
Primiano Tucci02c11762019-08-30 00:57:59 +0200151}
Primiano Tuccif3837d52018-01-10 21:12:41 +0000152
Primiano Tuccifbf4a732019-12-11 00:32:15 +0000153# The CTS code is built (but not ran) also in standalone builds. This is to
154# catch refactoring breakages earlier without having to wait for treehugger.
155if (is_android && (perfetto_build_standalone || perfetto_build_with_android)) {
156 all_targets += [ "test/cts:perfetto_cts_deps" ]
157}
158
Primiano Tucciae2879e2017-09-27 11:02:09 +0900159group("all") {
160 testonly = true # allow to build also test targets
Primiano Tucci02c11762019-08-30 00:57:59 +0200161 deps = all_targets
Primiano Tucciae2879e2017-09-27 11:02:09 +0900162}
163
Primiano Tucci02c11762019-08-30 00:57:59 +0200164# This target is used when running ninja without any argument (by default would
165# build all reachable targets). This is mainly used to prevent the UI being
166# built when running ninja -C out/xxx.
167# This has effect only in standalone builds, no effect on chromium builds.
168# Chromium's "all" target depends on our "all" target above. However chromium's
169# "default" target depends on any target that we cause to be discovered by
170# depending on other GN files.
Primiano Tucci3faad742018-05-16 19:30:48 +0100171group("default") {
Primiano Tucci02c11762019-08-30 00:57:59 +0200172 testonly = true
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000173 deps = [ ":all" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100174}
175
Primiano Tucci02c11762019-08-30 00:57:59 +0200176# +----------------------------------------------------------------------------+
177# | Other definitions: root targets that don't belong to any other subdirectory|
178# +----------------------------------------------------------------------------+
Primiano Tucci3faad742018-05-16 19:30:48 +0100179
Primiano Tucci02c11762019-08-30 00:57:59 +0200180if (enable_perfetto_ui) {
Mikhail Khokhlov8643d1c2019-06-04 12:02:47 +0100181 group("ui") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000182 deps = [ "ui" ]
Mikhail Khokhlov8643d1c2019-06-04 12:02:47 +0100183 }
Primiano Tuccie70df3f2020-05-21 19:48:08 +0100184
185 group("site") {
186 deps = [ "infra/perfetto.dev:site" ]
187 }
Mikhail Khokhlov8643d1c2019-06-04 12:02:47 +0100188}
189
Primiano Tucci02c11762019-08-30 00:57:59 +0200190# In Android builds, we build the code of traced and traced_probes in one shared
191# library that exposes one xxx_main() for each. The executables themselves are
192# tiny shells that just invoke their own entry point into the library.
193# This is done merely for saving binary size, because the three binaries happen
194# to share a lot of code.
195# When setting monolithic_binaries=true (only supported in standalone builds)
196# it builds more conventional executables, where each binary has the full
197# implementation and no shared library dependency. This is to make dev cycles
198# on Android faster, avoiding all the LD_LIBRARY_PATH boilerplate.
199# libperfetto.so is also used for stuff that is exposed to the rest of the
200# Android tree.
201if (enable_perfetto_platform_services) {
Primiano Tuccif3837d52018-01-10 21:12:41 +0000202 if (monolithic_binaries) {
Primiano Tucci098f0952019-09-03 10:21:20 +0100203 libperfetto_target_type = "static_library"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000204 } else {
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100205 libperfetto_target_type = "shared_library"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000206 }
207
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100208 target(libperfetto_target_type, "libperfetto") {
Primiano Tucci098f0952019-09-03 10:21:20 +0100209 if (libperfetto_target_type == "static_library") {
210 complete_static_lib = true
211 }
Primiano Tucci4e49c022017-12-21 18:22:44 +0100212 deps = [
213 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000214 "src/traced/service",
215 ]
Primiano Tuccia7f5a8e2021-01-02 17:10:50 +0100216 if (enable_perfetto_traced_probes) {
217 deps += [ "src/traced/probes" ]
218 }
219 if (is_linux || is_android || is_mac) {
220 # TODO(primiano): this is here only for Android's iorapd. At some point
221 # we need to migrate iorapd to the Perfetto SDK.
222 deps += [ "src/tracing/consumer_api_deprecated" ]
223 }
Primiano Tucci6067e732018-01-08 16:19:40 +0000224 }
Primiano Tucci02c11762019-08-30 00:57:59 +0200225}
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700226
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200227if (!build_with_chromium) {
Primiano Tucci55b4d912020-01-28 11:17:51 +0000228 # Client library target exposed to the Android tree.
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200229 # Still in experimental stage and not API stable yet.
230 # See "libperfetto_client_example" (in Android.bp.extras) for an example
231 # on how to use the Perfetto Client API from the android tree.
232 static_library("libperfetto_client_experimental") {
233 complete_static_lib = true
Primiano Tuccifbf4a732019-12-11 00:32:15 +0000234 public_deps = [
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200235 "gn:default_deps",
Primiano Tucci3feec552020-02-04 11:14:42 +0000236 "src/tracing:client_api",
Primiano Tucci10c9e9e2021-01-08 13:04:40 +0100237 "src/tracing:platform_impl",
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200238 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000239 sources = [ "include/perfetto/tracing.h" ]
Primiano Tuccie8020f92019-11-26 13:24:01 +0000240 assert_no_deps = [ "//gn:protobuf_lite" ]
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100241 }
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200242}
243
Primiano Tucci02c11762019-08-30 00:57:59 +0200244# TODO(primiano): there seem to be two "libperfetto" and one
245# "libperfetto_client_experimental" targets defined within this BUILD.gn file.
246# Rationalize them with eseckler@. For now seems this one is only used from
247# chromium and the other one only from the Android tree.
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200248if (build_with_chromium) {
Eric Secklerc77dc1b2020-01-21 13:23:35 +0000249 component("libperfetto") {
250 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800251 deps = [
Sylwester Blaszczyk0430ce82020-08-07 16:00:51 +0200252 "src/trace_processor/importers/memory_tracker:graph_processor",
Eric Seckler48d1ab52020-01-23 09:56:29 +0000253 "src/tracing:client_api",
Primiano Tuccic4c063b2020-01-27 09:34:46 +0000254 "src/tracing/core",
Eric Seckler48d1ab52020-01-23 09:56:29 +0000255
256 # TODO(eseckler): Create a platform for chrome and hook it up somehow.
257 "src/tracing:platform_fake",
Eric Secklerc77dc1b2020-01-21 13:23:35 +0000258 ]
259 configs -= [ "//build/config/compiler:chromium_code" ]
260 configs += [ "//build/config/compiler:no_chromium_code" ]
261 public_deps = [
Sylwester Blaszczyk0430ce82020-08-07 16:00:51 +0200262 "include/perfetto/ext/trace_processor/importers/memory_tracker",
Primiano Tucci2c5488f2019-06-01 03:27:28 +0100263 "include/perfetto/ext/tracing/core",
Eric Seckler48d1ab52020-01-23 09:56:29 +0000264 "include/perfetto/tracing",
Nicolò Mazzucatoc1084462019-09-24 16:26:06 +0100265 "protos/perfetto/common:zero",
Oystein Eftevaag6fcedac2018-07-02 12:02:55 -0700266 "protos/perfetto/trace:zero",
267 "protos/perfetto/trace/chrome:zero",
Eric Secklerd3139b42019-02-26 13:43:59 +0000268 "protos/perfetto/trace/interned_data:zero",
Oystein Eftevaagae116202019-07-11 09:48:42 -0700269 "protos/perfetto/trace/profiling:zero",
Piotr Roguski1c96e672020-08-24 16:19:50 +0200270 "protos/perfetto/trace/ps:zero",
Eric Secklerd3139b42019-02-26 13:43:59 +0000271 "protos/perfetto/trace/track_event:zero",
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700272 ]
Stephen Nuskobfa6d632020-01-21 14:10:56 +0000273 if (enable_perfetto_ipc) {
Eric Seckler05355e02020-01-27 15:29:50 +0000274 deps += [
275 "src/tracing/ipc/producer",
276 "src/tracing/ipc/service",
277 ]
Stephen Nuskobfa6d632020-01-21 14:10:56 +0000278 public_deps += [ "include/perfetto/ext/tracing/ipc:ipc" ]
279 }
Eric Seckler60eff7d2020-05-20 13:03:07 +0100280 if (!is_nacl && !is_ios) {
281 deps += [
282 "src/trace_processor:export_json",
283 "src/trace_processor:storage_minimal",
284 ]
285 public_deps += [
286 "include/perfetto/ext/trace_processor:export_json",
287 "include/perfetto/trace_processor:storage",
288 ]
289 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800290 }
Mikhail Khokhlov2bcfb352019-12-20 10:19:58 +0000291 component("libtrace_processor") {
292 public_configs = [ "gn:public_config" ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000293 deps = [ "src/trace_processor:lib" ]
Mikhail Khokhlov2bcfb352019-12-20 10:19:58 +0000294 configs -= [ "//build/config/compiler:chromium_code" ]
295 configs += [ "//build/config/compiler:no_chromium_code" ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000296 public_deps = [ "include/perfetto/trace_processor" ]
Eric Secklera7870e62019-11-01 10:11:58 +0000297 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700298}