blob: 6e2753d5c8915a6461780076e7ade4a464e78f6a [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",
38 "src/traced/probes:traced_probes",
39 ]
Primiano Tuccia1959712018-05-17 11:01:56 +010040}
41
Eric Secklerc622b8b2019-10-21 09:54:00 +010042if (enable_perfetto_trace_processor &&
43 enable_perfetto_trace_processor_metrics) {
Primiano Tucci02c11762019-08-30 00:57:59 +020044 all_targets += [ "src/trace_processor:trace_processor_shell" ]
Primiano Tuccif3837d52018-01-10 21:12:41 +000045}
Primiano Tucci02c11762019-08-30 00:57:59 +020046
47if (enable_perfetto_heapprofd) {
48 all_targets += [ "src/profiling/memory:heapprofd" ]
49 if (perfetto_build_with_android) {
50 all_targets += [ "src/profiling/memory:heapprofd_client" ]
51 }
52}
53
Ryan Savitskia76b3cc2019-11-20 16:25:24 +000054if (enable_perfetto_traced_perf) {
55 all_targets += [ "src/profiling/perf:traced_perf" ]
56}
57
Primiano Tucci02c11762019-08-30 00:57:59 +020058if (perfetto_build_with_android) {
59 all_targets += [ "src/android_internal/:libperfetto_android_internal" ]
60}
61
62if (enable_perfetto_tools) {
63 all_targets += [ "tools" ]
64}
65
66if (enable_perfetto_unittests) {
67 import("gn/perfetto_unittests.gni")
68 test("perfetto_unittests") {
69 deps = perfetto_unittests_targets
70 }
71 all_targets += [ ":perfetto_unittests" ]
72}
73
74if (enable_perfetto_integration_tests) {
75 import("gn/perfetto_integrationtests.gni")
76 test("perfetto_integrationtests") {
77 deps = perfetto_integrationtests_targets
78 }
79 all_targets += [
80 ":perfetto_integrationtests",
81 "test:client_api_example",
82 ]
83}
84
85if (enable_perfetto_benchmarks) {
86 import("gn/perfetto_benchmarks.gni")
87 executable("perfetto_benchmarks") {
88 testonly = true
89 deps = perfetto_benchmarks_targets
90 }
91 all_targets += [ ":perfetto_benchmarks" ]
92}
93
94if (enable_perfetto_fuzzers) {
95 import("gn/perfetto_fuzzers.gni")
96 group("fuzzers") {
97 testonly = true
98 deps = perfetto_fuzzers_targets
99 }
100 all_targets += [ ":fuzzers" ]
101}
102
103# Less interesting stuff that makes sense only in the standalone build, mainly
104# compile-time checks for the CI.
105if (perfetto_build_standalone) {
106 all_targets += [
107 "src/tracing:consumer_api_test",
108 "test/configs",
109
110 # For syntax-checking the proto.
111 "protos/perfetto/config:merged_config",
112 "protos/perfetto/trace:merged_trace", # For syntax-checking the proto.
113
Primiano Tucci57dd66b2019-10-15 23:09:04 +0100114 # For checking all generated xxx.gen.{cc,h} files without waiting for
115 # embedders to try to use them and fail.
116 "protos/perfetto/trace:cpp",
117 "protos/perfetto/config:cpp",
118 "protos/perfetto/common:cpp",
119
Primiano Tucci02c11762019-08-30 00:57:59 +0200120 # The diff testing framework depends on these descriptors.
Primiano Tucci687249c2019-10-03 15:58:38 +0100121 "protos/perfetto/metrics:descriptor($host_toolchain)",
122 "protos/perfetto/trace:descriptor($host_toolchain)",
Primiano Tucci02c11762019-08-30 00:57:59 +0200123
124 # Used in the when updating the ftrace protos
125 "protos/perfetto/trace/ftrace:descriptor",
126 ]
127}
Primiano Tuccif3837d52018-01-10 21:12:41 +0000128
Primiano Tucciae2879e2017-09-27 11:02:09 +0900129group("all") {
130 testonly = true # allow to build also test targets
Primiano Tucci02c11762019-08-30 00:57:59 +0200131 deps = all_targets
Primiano Tucciae2879e2017-09-27 11:02:09 +0900132}
133
Primiano Tucci02c11762019-08-30 00:57:59 +0200134# This target is used when running ninja without any argument (by default would
135# build all reachable targets). This is mainly used to prevent the UI being
136# built when running ninja -C out/xxx.
137# This has effect only in standalone builds, no effect on chromium builds.
138# Chromium's "all" target depends on our "all" target above. However chromium's
139# "default" target depends on any target that we cause to be discovered by
140# depending on other GN files.
Primiano Tucci3faad742018-05-16 19:30:48 +0100141group("default") {
Primiano Tucci02c11762019-08-30 00:57:59 +0200142 testonly = true
Primiano Tucci3faad742018-05-16 19:30:48 +0100143 deps = [
144 ":all",
145 ]
146}
147
Primiano Tucci02c11762019-08-30 00:57:59 +0200148# +----------------------------------------------------------------------------+
149# | Other definitions: root targets that don't belong to any other subdirectory|
150# +----------------------------------------------------------------------------+
Primiano Tucci3faad742018-05-16 19:30:48 +0100151
Primiano Tucci02c11762019-08-30 00:57:59 +0200152if (enable_perfetto_ui) {
Mikhail Khokhlov8643d1c2019-06-04 12:02:47 +0100153 group("ui") {
154 deps = [
155 "ui",
156 ]
157 }
158}
159
Primiano Tucci02c11762019-08-30 00:57:59 +0200160# In Android builds, we build the code of traced and traced_probes in one shared
161# library that exposes one xxx_main() for each. The executables themselves are
162# tiny shells that just invoke their own entry point into the library.
163# This is done merely for saving binary size, because the three binaries happen
164# to share a lot of code.
165# When setting monolithic_binaries=true (only supported in standalone builds)
166# it builds more conventional executables, where each binary has the full
167# implementation and no shared library dependency. This is to make dev cycles
168# on Android faster, avoiding all the LD_LIBRARY_PATH boilerplate.
169# libperfetto.so is also used for stuff that is exposed to the rest of the
170# Android tree.
171if (enable_perfetto_platform_services) {
Primiano Tuccif3837d52018-01-10 21:12:41 +0000172 if (monolithic_binaries) {
Primiano Tucci098f0952019-09-03 10:21:20 +0100173 libperfetto_target_type = "static_library"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000174 } else {
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100175 libperfetto_target_type = "shared_library"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000176 }
177
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100178 target(libperfetto_target_type, "libperfetto") {
Primiano Tucci098f0952019-09-03 10:21:20 +0100179 if (libperfetto_target_type == "static_library") {
180 complete_static_lib = true
181 }
Primiano Tucci4e49c022017-12-21 18:22:44 +0100182 deps = [
183 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000184 "src/traced/probes",
185 "src/traced/service",
Primiano Tucci2c5488f2019-06-01 03:27:28 +0100186 "src/tracing:consumer_api_deprecated",
Primiano Tucci6067e732018-01-08 16:19:40 +0000187 ]
188 }
Primiano Tucci02c11762019-08-30 00:57:59 +0200189}
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700190
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200191if (!build_with_chromium) {
192 # Client library target.
193 # Still in experimental stage and not API stable yet.
194 # See "libperfetto_client_example" (in Android.bp.extras) for an example
195 # on how to use the Perfetto Client API from the android tree.
196 static_library("libperfetto_client_experimental") {
197 complete_static_lib = true
198 deps = [
199 "gn:default_deps",
200 "src/tracing",
201 "src/tracing:client_api",
202 "src/tracing:platform_posix",
203 ]
204 sources = [
205 "include/perfetto/tracing.h",
206 ]
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100207 }
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200208}
209
Primiano Tucci02c11762019-08-30 00:57:59 +0200210# TODO(primiano): there seem to be two "libperfetto" and one
211# "libperfetto_client_experimental" targets defined within this BUILD.gn file.
212# Rationalize them with eseckler@. For now seems this one is only used from
213# chromium and the other one only from the Android tree.
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200214if (build_with_chromium) {
215 component("libperfetto") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000216 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800217 deps = [
Eric Seckler239f5fa2019-11-13 18:03:18 +0000218 "src/trace_processor:export_json",
219 "src/trace_processor:storage",
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800220 "src/tracing",
221 ]
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700222 configs -= [ "//build/config/compiler:chromium_code" ]
223 configs += [ "//build/config/compiler:no_chromium_code" ]
224 public_deps = [
Eric Seckler239f5fa2019-11-13 18:03:18 +0000225 "include/perfetto/ext/trace_processor:export_json",
Primiano Tucci2c5488f2019-06-01 03:27:28 +0100226 "include/perfetto/ext/tracing/core",
Eric Seckler239f5fa2019-11-13 18:03:18 +0000227 "include/perfetto/trace_processor:storage",
Nicolò Mazzucatoc1084462019-09-24 16:26:06 +0100228 "protos/perfetto/common:zero",
Oystein Eftevaag6fcedac2018-07-02 12:02:55 -0700229 "protos/perfetto/trace:zero",
230 "protos/perfetto/trace/chrome:zero",
Eric Secklerd3139b42019-02-26 13:43:59 +0000231 "protos/perfetto/trace/interned_data:zero",
Oystein Eftevaagae116202019-07-11 09:48:42 -0700232 "protos/perfetto/trace/profiling:zero",
Eric Secklerd3139b42019-02-26 13:43:59 +0000233 "protos/perfetto/trace/track_event:zero",
Eric Secklerb0ea7602019-11-13 18:41:52 +0000234 "src/tracing:sliced_protobuf_input_stream",
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700235 ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800236 }
Eric Secklera7870e62019-11-01 10:11:58 +0000237 if (enable_perfetto_trace_processor_sqlite) {
238 component("libtrace_processor") {
239 public_configs = [ "gn:public_config" ]
240 deps = [
241 "src/trace_processor:lib",
242 ]
243 configs -= [ "//build/config/compiler:chromium_code" ]
244 configs += [ "//build/config/compiler:no_chromium_code" ]
245 public_deps = [
246 "include/perfetto/trace_processor",
247 ]
248 }
249 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700250}