Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 1 | # 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 | |
| 15 | import("//build_overrides/build.gni") |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 16 | import("wasm_vars.gni") |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 17 | |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 18 | # Summary of our typical build configurations: |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 19 | |
| 20 | # 1. Standalone builds |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 21 | # build_with_chromium = false |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 22 | # is_perfetto_build_generator = false |
| 23 | # perfetto_build_standalone = true |
| 24 | # perfetto_build_with_android = false |
| 25 | # perfetto_build_with_embedder = false |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 26 | |
| 27 | # 2. Android tree builds |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 28 | # build_with_chromium = false |
| 29 | # is_perfetto_build_generator = true |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 30 | # perfetto_build_standalone = false |
| 31 | # perfetto_build_with_android = true |
| 32 | # perfetto_build_with_embedder = false |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 33 | |
| 34 | # 3. Chromium tree builds |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 35 | # build_with_chromium = true |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 36 | # is_perfetto_build_generator = false |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 37 | # perfetto_build_standalone = false |
| 38 | # perfetto_build_with_android = false |
| 39 | # perfetto_build_with_embedder = true |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 40 | |
| 41 | # 4. Builds in other embedder trees (e.g. V8 standalone) |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 42 | # build_with_chromium = false |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 43 | # 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 Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 54 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 55 | # +----------------------------------------------------------------------------+ |
| 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 Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 61 | # Note that |build_with_chromium| is a global convention used by several |
| 62 | # projects, set outside of our control. |
| 63 | |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 64 | # Chromium sets this to true in its //build_overrides/build.gni. |
Eric Seckler | 7faef11 | 2019-01-16 15:07:50 +0000 | [diff] [blame] | 65 | if (!defined(build_with_chromium)) { |
| 66 | build_with_chromium = false |
| 67 | } |
| 68 | |
Eric Seckler | 357966a | 2019-01-15 13:45:37 +0000 | [diff] [blame] | 69 | declare_args() { |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 70 | # 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 Seckler | 357966a | 2019-01-15 13:45:37 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 86 | # 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. |
| 89 | if (!defined(perfetto_build_with_embedder)) { |
| 90 | perfetto_build_with_embedder = build_with_chromium || is_perfetto_embedder |
| 91 | } |
| 92 | |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 93 | perfetto_build_standalone = |
| 94 | !perfetto_build_with_android && !build_with_chromium && |
| 95 | !perfetto_build_with_embedder |
| 96 | |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 97 | # 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. |
| 100 | if (perfetto_build_standalone || is_perfetto_build_generator) { |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 101 | perfetto_root_path = "//" |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 102 | import("//gn/standalone/android.gni") # For android_api_level |
| 103 | import("//gn/standalone/sanitizers/vars.gni") # For is_fuzzer |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 104 | } else if (!defined(perfetto_root_path)) { |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 105 | perfetto_root_path = "//third_party/perfetto/" |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 106 | import("//build/config/android/config.gni") # For android_api_level |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 107 | } |
Lalit Maganti | d0e7679 | 2018-02-12 14:25:01 +0000 | [diff] [blame] | 108 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 109 | # Whether the ftrace producer and the service should be started |
| 110 | # by the integration test or assumed to be running. |
Lalit Maganti | d0e7679 | 2018-02-12 14:25:01 +0000 | [diff] [blame] | 111 | # 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 Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 113 | # In all other cases (i.e. when true), a temporary in-process instance will be |
| 114 | # brought up by our own integrationtest harness. |
| 115 | start_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 | |
| 124 | perfetto_force_dlog_default = "" |
| 125 | if (build_with_chromium) { |
| 126 | perfetto_force_dlog_default = "off" |
Lalit Maganti | d0e7679 | 2018-02-12 14:25:01 +0000 | [diff] [blame] | 127 | } |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 128 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 129 | declare_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 Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 133 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 134 | # 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 Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 141 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 142 | # 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 Tucci | 18c0cff | 2019-09-09 17:09:03 -0700 | [diff] [blame^] | 157 | # gn/BUILD.gn further restricts this to OS_LINUX || OS_ANDROID when generating |
| 158 | # the perfetto_build_flags.h header. |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 159 | enable_perfetto_watchdog = |
Primiano Tucci | 18c0cff | 2019-09-09 17:09:03 -0700 | [diff] [blame^] | 160 | perfetto_build_with_android || perfetto_build_standalone |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 161 | |
| 162 | # Misc host executable under tools/. |
| 163 | enable_perfetto_tools = |
Primiano Tucci | b7ebffd | 2019-09-09 07:42:35 -0700 | [diff] [blame] | 164 | (perfetto_build_standalone && current_toolchain == host_toolchain) || |
| 165 | perfetto_build_with_android |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 166 | |
| 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 | |
| 198 | declare_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 Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 218 | |
Primiano Tucci | 7c7f5f5 | 2019-01-15 21:47:04 +0000 | [diff] [blame] | 219 | # Exactly one between build_with_android, build_standalone and |
| 220 | # build_with_embedder must be true. |
| 221 | assert(perfetto_build_standalone || perfetto_build_with_android || |
| 222 | perfetto_build_with_embedder) |
| 223 | assert(!(perfetto_build_with_android && perfetto_build_standalone)) |
| 224 | assert(!(perfetto_build_with_embedder && perfetto_build_standalone)) |
| 225 | assert(!(perfetto_build_with_android && perfetto_build_with_embedder)) |
| 226 | |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 227 | # If |build_with_chromium| is true then also |perfetto_build_with_embedder| |
| 228 | # must be true |
| 229 | assert(!build_with_chromium || perfetto_build_with_embedder) |
Stephen Nusko | 5da63f3 | 2019-04-25 17:06:26 +0100 | [diff] [blame] | 230 | |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 231 | # If |perfetto_build_with_android| is true then also |
| 232 | # |is_perfetto_build_generator| must be true. |
| 233 | assert(!perfetto_build_with_android || is_perfetto_build_generator) |
Primiano Tucci | 2bf8284 | 2019-08-27 07:10:55 +0200 | [diff] [blame] | 234 | |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 235 | # The IPC layer based on UNIX sockets can't be built on Win. |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 236 | assert(!enable_perfetto_ipc || !is_win) |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 237 | |
| 238 | # We should never end up in a state where is_perfetto_embedder=true but |
| 239 | # perfetto_build_with_embedder=false. |
| 240 | assert(!is_perfetto_embedder || perfetto_build_with_embedder) |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 241 | |
| 242 | # The monolithic binaries is not supported when building in the Android tree. |
| 243 | assert(!monolithic_binaries || !perfetto_build_with_android) |
| 244 | |
| 245 | # Watchdog must be on in Android builds. |
| 246 | assert(enable_perfetto_watchdog || !perfetto_build_with_android) |
| 247 | |
| 248 | assert(perfetto_force_dlog == "" || perfetto_force_dlog == "on" || |
| 249 | perfetto_force_dlog == "off") |