blob: 61d6d9d2d2ce23d43a4cc8d5e0cc91e48dfc528b [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
Primiano Tucci02c11762019-08-30 00:57:59 +020042if (enable_perfetto_trace_processor) {
43 all_targets += [ "src/trace_processor:trace_processor_shell" ]
Primiano Tuccif3837d52018-01-10 21:12:41 +000044}
Primiano Tucci02c11762019-08-30 00:57:59 +020045
46if (enable_perfetto_heapprofd) {
47 all_targets += [ "src/profiling/memory:heapprofd" ]
48 if (perfetto_build_with_android) {
49 all_targets += [ "src/profiling/memory:heapprofd_client" ]
50 }
51}
52
53if (perfetto_build_with_android) {
54 all_targets += [ "src/android_internal/:libperfetto_android_internal" ]
55}
56
57if (enable_perfetto_tools) {
58 all_targets += [ "tools" ]
59}
60
61if (enable_perfetto_unittests) {
62 import("gn/perfetto_unittests.gni")
63 test("perfetto_unittests") {
64 deps = perfetto_unittests_targets
65 }
66 all_targets += [ ":perfetto_unittests" ]
67}
68
69if (enable_perfetto_integration_tests) {
70 import("gn/perfetto_integrationtests.gni")
71 test("perfetto_integrationtests") {
72 deps = perfetto_integrationtests_targets
73 }
74 all_targets += [
75 ":perfetto_integrationtests",
76 "test:client_api_example",
77 ]
78}
79
80if (enable_perfetto_benchmarks) {
81 import("gn/perfetto_benchmarks.gni")
82 executable("perfetto_benchmarks") {
83 testonly = true
84 deps = perfetto_benchmarks_targets
85 }
86 all_targets += [ ":perfetto_benchmarks" ]
87}
88
89if (enable_perfetto_fuzzers) {
90 import("gn/perfetto_fuzzers.gni")
91 group("fuzzers") {
92 testonly = true
93 deps = perfetto_fuzzers_targets
94 }
95 all_targets += [ ":fuzzers" ]
96}
97
98# Less interesting stuff that makes sense only in the standalone build, mainly
99# compile-time checks for the CI.
100if (perfetto_build_standalone) {
101 all_targets += [
102 "src/tracing:consumer_api_test",
103 "test/configs",
104
105 # For syntax-checking the proto.
106 "protos/perfetto/config:merged_config",
107 "protos/perfetto/trace:merged_trace", # For syntax-checking the proto.
108
109 # The diff testing framework depends on these descriptors.
110 "protos/perfetto/metrics:descriptor",
111 "protos/perfetto/trace:descriptor",
112
113 # Used in the when updating the ftrace protos
114 "protos/perfetto/trace/ftrace:descriptor",
115 ]
116}
Primiano Tuccif3837d52018-01-10 21:12:41 +0000117
Primiano Tucciae2879e2017-09-27 11:02:09 +0900118group("all") {
119 testonly = true # allow to build also test targets
Primiano Tucci02c11762019-08-30 00:57:59 +0200120 deps = all_targets
Primiano Tucciae2879e2017-09-27 11:02:09 +0900121}
122
Primiano Tucci02c11762019-08-30 00:57:59 +0200123# This target is used when running ninja without any argument (by default would
124# build all reachable targets). This is mainly used to prevent the UI being
125# built when running ninja -C out/xxx.
126# This has effect only in standalone builds, no effect on chromium builds.
127# Chromium's "all" target depends on our "all" target above. However chromium's
128# "default" target depends on any target that we cause to be discovered by
129# depending on other GN files.
Primiano Tucci3faad742018-05-16 19:30:48 +0100130group("default") {
Primiano Tucci02c11762019-08-30 00:57:59 +0200131 testonly = true
Primiano Tucci3faad742018-05-16 19:30:48 +0100132 deps = [
133 ":all",
134 ]
135}
136
Primiano Tucci02c11762019-08-30 00:57:59 +0200137# +----------------------------------------------------------------------------+
138# | Other definitions: root targets that don't belong to any other subdirectory|
139# +----------------------------------------------------------------------------+
Primiano Tucci3faad742018-05-16 19:30:48 +0100140
Primiano Tucci02c11762019-08-30 00:57:59 +0200141if (enable_perfetto_ui) {
Mikhail Khokhlov8643d1c2019-06-04 12:02:47 +0100142 group("ui") {
143 deps = [
144 "ui",
145 ]
146 }
147}
148
Primiano Tucci02c11762019-08-30 00:57:59 +0200149# In Android builds, we build the code of traced and traced_probes in one shared
150# library that exposes one xxx_main() for each. The executables themselves are
151# tiny shells that just invoke their own entry point into the library.
152# This is done merely for saving binary size, because the three binaries happen
153# to share a lot of code.
154# When setting monolithic_binaries=true (only supported in standalone builds)
155# it builds more conventional executables, where each binary has the full
156# implementation and no shared library dependency. This is to make dev cycles
157# on Android faster, avoiding all the LD_LIBRARY_PATH boilerplate.
158# libperfetto.so is also used for stuff that is exposed to the rest of the
159# Android tree.
160if (enable_perfetto_platform_services) {
Primiano Tuccif3837d52018-01-10 21:12:41 +0000161 if (monolithic_binaries) {
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100162 libperfetto_target_type = "source_set"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000163 } else {
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100164 libperfetto_target_type = "shared_library"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000165 }
166
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100167 target(libperfetto_target_type, "libperfetto") {
Primiano Tucci4e49c022017-12-21 18:22:44 +0100168 deps = [
169 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000170 "src/traced/probes",
171 "src/traced/service",
Primiano Tucci2c5488f2019-06-01 03:27:28 +0100172 "src/tracing:consumer_api_deprecated",
Primiano Tucci6067e732018-01-08 16:19:40 +0000173 ]
174 }
Primiano Tucci02c11762019-08-30 00:57:59 +0200175}
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700176
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200177if (!build_with_chromium) {
178 # Client library target.
179 # Still in experimental stage and not API stable yet.
180 # See "libperfetto_client_example" (in Android.bp.extras) for an example
181 # on how to use the Perfetto Client API from the android tree.
182 static_library("libperfetto_client_experimental") {
183 complete_static_lib = true
184 deps = [
185 "gn:default_deps",
186 "src/tracing",
187 "src/tracing:client_api",
188 "src/tracing:platform_posix",
189 ]
190 sources = [
191 "include/perfetto/tracing.h",
192 ]
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100193 }
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200194}
195
Primiano Tucci02c11762019-08-30 00:57:59 +0200196# TODO(primiano): there seem to be two "libperfetto" and one
197# "libperfetto_client_experimental" targets defined within this BUILD.gn file.
198# Rationalize them with eseckler@. For now seems this one is only used from
199# chromium and the other one only from the Android tree.
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200200if (build_with_chromium) {
201 component("libperfetto") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000202 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800203 deps = [
204 "src/tracing",
205 ]
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700206 configs -= [ "//build/config/compiler:chromium_code" ]
207 configs += [ "//build/config/compiler:no_chromium_code" ]
208 public_deps = [
Primiano Tucci2c5488f2019-06-01 03:27:28 +0100209 "include/perfetto/ext/tracing/core",
Oystein Eftevaag6fcedac2018-07-02 12:02:55 -0700210 "protos/perfetto/trace:zero",
211 "protos/perfetto/trace/chrome:zero",
Eric Secklerd3139b42019-02-26 13:43:59 +0000212 "protos/perfetto/trace/interned_data:zero",
Oystein Eftevaagae116202019-07-11 09:48:42 -0700213 "protos/perfetto/trace/profiling:zero",
Eric Secklerd3139b42019-02-26 13:43:59 +0000214 "protos/perfetto/trace/track_event:zero",
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700215 ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800216 }
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200217 component("libtrace_processor") {
Eric Seckler8f5299c2019-08-09 14:47:30 +0100218 public_configs = [ "gn:public_config" ]
219 deps = [
220 "src/trace_processor:lib",
221 ]
222 configs -= [ "//build/config/compiler:chromium_code" ]
223 configs += [ "//build/config/compiler:no_chromium_code" ]
224 public_deps = [
225 "include/perfetto/trace_processor",
226 ]
227 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700228}