blob: 4bf62528336b5b6c8ce6eb932c18dcb6912422da [file] [log] [blame]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -08001# 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("//build_overrides/build.gni")
Primiano Tucci02c11762019-08-30 00:57:59 +020016import("wasm_vars.gni")
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080017
Primiano Tucci7e05fc12019-08-27 17:29:47 +020018# Summary of our typical build configurations:
Primiano Tucci4c5efa42018-10-23 13:15:13 +010019
20# 1. Standalone builds
Primiano Tucci4c5efa42018-10-23 13:15:13 +010021# build_with_chromium = false
Primiano Tucci7e05fc12019-08-27 17:29:47 +020022# is_perfetto_build_generator = false
23# perfetto_build_standalone = true
24# perfetto_build_with_android = false
25# perfetto_build_with_embedder = false
Primiano Tucci4c5efa42018-10-23 13:15:13 +010026
27# 2. Android tree builds
Primiano Tucci7e05fc12019-08-27 17:29:47 +020028# build_with_chromium = false
29# is_perfetto_build_generator = true
Primiano Tucci4c5efa42018-10-23 13:15:13 +010030# perfetto_build_standalone = false
31# perfetto_build_with_android = true
32# perfetto_build_with_embedder = false
Primiano Tucci4c5efa42018-10-23 13:15:13 +010033
34# 3. Chromium tree builds
Primiano Tucci4c5efa42018-10-23 13:15:13 +010035# build_with_chromium = true
Primiano Tucci7e05fc12019-08-27 17:29:47 +020036# is_perfetto_build_generator = false
Primiano Tucci4c5efa42018-10-23 13:15:13 +010037# perfetto_build_standalone = false
38# perfetto_build_with_android = false
39# perfetto_build_with_embedder = true
Primiano Tucci7e05fc12019-08-27 17:29:47 +020040
41# 4. Builds in other embedder trees (e.g. V8 standalone)
Primiano Tucci4c5efa42018-10-23 13:15:13 +010042# build_with_chromium = false
Primiano Tucci7e05fc12019-08-27 17:29:47 +020043# is_perfetto_build_generator = false
44# perfetto_build_standalone = false
45# perfetto_build_with_android = false
46# perfetto_build_with_embedder = true
47
48# 5. Amalgamated sources (Client library)
49# build_with_chromium = false
50# is_perfetto_build_generator = true
51# perfetto_build_standalone = false
52# perfetto_build_with_android = false
53# perfetto_build_with_embedder = true
Primiano Tucci4c5efa42018-10-23 13:15:13 +010054
Primiano Tucci02c11762019-08-30 00:57:59 +020055# +----------------------------------------------------------------------------+
56# | Toolchain / environment related configuration |
57# +----------------------------------------------------------------------------+
58# This section contains a bunch of variables that are related with the toolchain
59# and the build environment. Only tools/gen_xxx should customize them.
60
Primiano Tucci4c5efa42018-10-23 13:15:13 +010061# Note that |build_with_chromium| is a global convention used by several
62# projects, set outside of our control.
63
Primiano Tucci7e05fc12019-08-27 17:29:47 +020064# Chromium sets this to true in its //build_overrides/build.gni.
Eric Seckler7faef112019-01-16 15:07:50 +000065if (!defined(build_with_chromium)) {
66 build_with_chromium = false
67}
68
Eric Seckler357966a2019-01-15 13:45:37 +000069declare_args() {
Primiano Tucci7e05fc12019-08-27 17:29:47 +020070 # The Android blueprint file generator set this to true (as well as
71 # is_perfetto_build_generator). This is just about being built in the
72 # Android tree (AOSP and internal) and is NOT related with the target OS.
73 # In standalone Android builds and Chromium Android builds, this is false.
74 perfetto_build_with_android = false
75
76 # All the tools/gen_* scripts set this to true. This is mainly used to locate
77 # .gni files from //gn rather than //build.
78 is_perfetto_build_generator = false
79
80 # This is for override via `gn args` (e.g. for tools/gen_xxx). Embedders
81 # based on GN (e.g. v8) should NOT set this and instead directly sets
82 # perfetto_build_with_embedder=true in their GN files.
83 is_perfetto_embedder = false
Eric Seckler357966a2019-01-15 13:45:37 +000084}
85
Primiano Tucci7e05fc12019-08-27 17:29:47 +020086# This can be overridden by embedders (e.g. v8) in their .gn(i) files. This must
87# be different from the GN args flag (is_perfetto_embedder) because of the way
88# GN works.
89if (!defined(perfetto_build_with_embedder)) {
90 perfetto_build_with_embedder = build_with_chromium || is_perfetto_embedder
91}
92
Primiano Tucci4c5efa42018-10-23 13:15:13 +010093perfetto_build_standalone =
94 !perfetto_build_with_android && !build_with_chromium &&
95 !perfetto_build_with_embedder
96
Primiano Tucci7e05fc12019-08-27 17:29:47 +020097# Only relevant for GN builds. Sets the path where perfetto lives. This is //
98# for standalone builds and //third_party/perfetto/ in embedders. The embedder
99# can ovverride it in its GN files.
100if (perfetto_build_standalone || is_perfetto_build_generator) {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800101 perfetto_root_path = "//"
Primiano Tucci02c11762019-08-30 00:57:59 +0200102 import("//gn/standalone/android.gni") # For android_api_level
103 import("//gn/standalone/sanitizers/vars.gni") # For is_fuzzer
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100104} else if (!defined(perfetto_root_path)) {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800105 perfetto_root_path = "//third_party/perfetto/"
Primiano Tucci02c11762019-08-30 00:57:59 +0200106 import("//build/config/android/config.gni") # For android_api_level
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800107}
Lalit Magantid0e76792018-02-12 14:25:01 +0000108
Primiano Tucci02c11762019-08-30 00:57:59 +0200109# Whether the ftrace producer and the service should be started
110# by the integration test or assumed to be running.
Lalit Magantid0e76792018-02-12 14:25:01 +0000111# If we're building in the Android tree, we expect that the testing infra
112# will start the binaries in the system image before the tests are run.
Primiano Tucci02c11762019-08-30 00:57:59 +0200113# In all other cases (i.e. when true), a temporary in-process instance will be
114# brought up by our own integrationtest harness.
115start_daemons_for_testing = !perfetto_build_with_android
116
117# +----------------------------------------------------------------------------+
118# | Tunable build variables for embedders |
119# +----------------------------------------------------------------------------+
120# The variables in this section allow embedders to enable/disable features
121# at the build-system level. This allows to opt-in into the various services
122# and tools.
123
124perfetto_force_dlog_default = ""
125if (build_with_chromium) {
126 perfetto_force_dlog_default = "off"
Lalit Magantid0e76792018-02-12 14:25:01 +0000127}
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100128
Primiano Tucci02c11762019-08-30 00:57:59 +0200129declare_args() {
130 # Platform-wide tracing executables (traced, traced_probes, perfetto_cmd).
131 enable_perfetto_platform_services =
132 perfetto_build_standalone || perfetto_build_with_android
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200133
Primiano Tucci02c11762019-08-30 00:57:59 +0200134 # Allow the embedder to use the IPC layer. In turn this allows to use the
135 # system backend in the client library.
136 # This includes building things that rely on POSIX sockets, this places
137 # limitations on the supported operating systems.
138 enable_perfetto_ipc = (is_android || is_linux || is_mac) &&
139 (perfetto_build_standalone ||
140 perfetto_build_with_android || build_with_chromium)
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200141
Primiano Tucci02c11762019-08-30 00:57:59 +0200142 # Makes the heap profiling daemon target reachable. It works only on Android,
143 # but is built on Linux as well for test/compiler coverage.
144 # On Android, it requires API level 26 due to libunwindstack.
145 enable_perfetto_heapprofd =
146 perfetto_build_with_android ||
147 (perfetto_build_standalone && is_clang &&
148 (is_linux || (is_android && android_api_level >= 26)))
149
150 # The Trace Processor: offline analytical engine to process traces and compute
151 # metrics using a SQL engine.
152 enable_perfetto_trace_processor =
153 perfetto_build_standalone || build_with_chromium ||
154 is_perfetto_build_generator
155
156 # Enables base::Watchdog. Is supported only on Linux-based platforms.
Primiano Tucci18c0cff2019-09-09 17:09:03 -0700157 # gn/BUILD.gn further restricts this to OS_LINUX || OS_ANDROID when generating
158 # the perfetto_build_flags.h header.
Primiano Tucci02c11762019-08-30 00:57:59 +0200159 enable_perfetto_watchdog =
Primiano Tucci18c0cff2019-09-09 17:09:03 -0700160 perfetto_build_with_android || perfetto_build_standalone
Primiano Tucci02c11762019-08-30 00:57:59 +0200161
162 # Misc host executable under tools/.
163 enable_perfetto_tools =
Primiano Tuccib7ebffd2019-09-09 07:42:35 -0700164 (perfetto_build_standalone && current_toolchain == host_toolchain) ||
165 perfetto_build_with_android
Primiano Tucci02c11762019-08-30 00:57:59 +0200166
167 # Allows to build the UI (TypeScript/ HTML / WASM)
168 enable_perfetto_ui = perfetto_build_standalone
169
170 enable_perfetto_unittests = perfetto_build_standalone ||
171 build_with_chromium || perfetto_build_with_android
172
173 enable_perfetto_integration_tests =
174 perfetto_build_standalone || perfetto_build_with_android
175
176 enable_perfetto_benchmarks = perfetto_build_standalone
177
178 enable_perfetto_fuzzers =
179 perfetto_build_standalone && defined(is_fuzzer) && is_fuzzer
180
181 # Enables the gen_git_revision tool that generates a .h that contains a macro
182 # with the current git revision. Works only in standalone GN checkouts.
183 # If disabled, the version string will be "unknown".
184 enable_perfetto_version_gen =
185 perfetto_build_standalone && !is_perfetto_build_generator
186
187 # Only for local development. When true the binaries (perfetto, traced, ...)
188 # are monolithic and don't use a common shared library. This is mainly to
189 # avoid LD_LIBRARY_PATH dances when testing locally.
190 monolithic_binaries = false
191
192 # Whether DLOG should be enabled on debug builds (""), all builds ("on"), or
193 # none ("off"). We disable it by default for embedders to avoid spamming their
194 # console.
195 perfetto_force_dlog = perfetto_force_dlog_default
196}
197
198declare_args() {
199 enable_perfetto_trace_processor_sqlite = enable_perfetto_trace_processor
200
201 # Enables the optional SQLite percentile module.
202 enable_perfetto_trace_processor_percentile =
203 enable_perfetto_trace_processor && perfetto_build_standalone
204
205 # Enables JSON support in the trace processor.
206 enable_perfetto_trace_processor_json =
207 enable_perfetto_trace_processor && !perfetto_build_with_android
208
209 # Enables the REPL interactive prompt in the trace processor.
210 enable_perfetto_trace_processor_linenoise =
211 perfetto_build_standalone && enable_perfetto_trace_processor &&
212 (is_linux || is_android || is_mac)
213}
214
215# +---------------------------------------------------------------------------+
216# | Cross-checks |
217# +---------------------------------------------------------------------------+
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100218
Primiano Tucci7c7f5f52019-01-15 21:47:04 +0000219# Exactly one between build_with_android, build_standalone and
220# build_with_embedder must be true.
221assert(perfetto_build_standalone || perfetto_build_with_android ||
222 perfetto_build_with_embedder)
223assert(!(perfetto_build_with_android && perfetto_build_standalone))
224assert(!(perfetto_build_with_embedder && perfetto_build_standalone))
225assert(!(perfetto_build_with_android && perfetto_build_with_embedder))
226
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100227# If |build_with_chromium| is true then also |perfetto_build_with_embedder|
228# must be true
229assert(!build_with_chromium || perfetto_build_with_embedder)
Stephen Nusko5da63f32019-04-25 17:06:26 +0100230
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200231# If |perfetto_build_with_android| is true then also
232# |is_perfetto_build_generator| must be true.
233assert(!perfetto_build_with_android || is_perfetto_build_generator)
Primiano Tucci2bf82842019-08-27 07:10:55 +0200234
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200235# The IPC layer based on UNIX sockets can't be built on Win.
Primiano Tucci02c11762019-08-30 00:57:59 +0200236assert(!enable_perfetto_ipc || !is_win)
Primiano Tucci7e05fc12019-08-27 17:29:47 +0200237
238# We should never end up in a state where is_perfetto_embedder=true but
239# perfetto_build_with_embedder=false.
240assert(!is_perfetto_embedder || perfetto_build_with_embedder)
Primiano Tucci02c11762019-08-30 00:57:59 +0200241
242# The monolithic binaries is not supported when building in the Android tree.
243assert(!monolithic_binaries || !perfetto_build_with_android)
244
245# Watchdog must be on in Android builds.
246assert(enable_perfetto_watchdog || !perfetto_build_with_android)
247
248assert(perfetto_force_dlog == "" || perfetto_force_dlog == "on" ||
249 perfetto_force_dlog == "off")