Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [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 | |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 15 | import("gn/perfetto.gni") |
Eric Seckler | a6ba179 | 2019-01-02 12:51:00 +0000 | [diff] [blame] | 16 | import("gn/test.gni") |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 17 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 18 | # +----------------------------------------------------------------------------+ |
| 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 | |
| 31 | all_targets = [ "protos/perfetto/trace:perfetto_trace_protos" ] |
| 32 | |
| 33 | if (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 Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 40 | } |
| 41 | |
Eric Seckler | c622b8b | 2019-10-21 09:54:00 +0100 | [diff] [blame] | 42 | if (enable_perfetto_trace_processor && |
| 43 | enable_perfetto_trace_processor_metrics) { |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 44 | all_targets += [ "src/trace_processor:trace_processor_shell" ] |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 45 | } |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 46 | |
| 47 | if (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 | |
| 54 | if (perfetto_build_with_android) { |
| 55 | all_targets += [ "src/android_internal/:libperfetto_android_internal" ] |
| 56 | } |
| 57 | |
| 58 | if (enable_perfetto_tools) { |
| 59 | all_targets += [ "tools" ] |
| 60 | } |
| 61 | |
| 62 | if (enable_perfetto_unittests) { |
| 63 | import("gn/perfetto_unittests.gni") |
| 64 | test("perfetto_unittests") { |
| 65 | deps = perfetto_unittests_targets |
| 66 | } |
| 67 | all_targets += [ ":perfetto_unittests" ] |
| 68 | } |
| 69 | |
| 70 | if (enable_perfetto_integration_tests) { |
| 71 | import("gn/perfetto_integrationtests.gni") |
| 72 | test("perfetto_integrationtests") { |
| 73 | deps = perfetto_integrationtests_targets |
| 74 | } |
| 75 | all_targets += [ |
| 76 | ":perfetto_integrationtests", |
| 77 | "test:client_api_example", |
| 78 | ] |
| 79 | } |
| 80 | |
| 81 | if (enable_perfetto_benchmarks) { |
| 82 | import("gn/perfetto_benchmarks.gni") |
| 83 | executable("perfetto_benchmarks") { |
| 84 | testonly = true |
| 85 | deps = perfetto_benchmarks_targets |
| 86 | } |
| 87 | all_targets += [ ":perfetto_benchmarks" ] |
| 88 | } |
| 89 | |
| 90 | if (enable_perfetto_fuzzers) { |
| 91 | import("gn/perfetto_fuzzers.gni") |
| 92 | group("fuzzers") { |
| 93 | testonly = true |
| 94 | deps = perfetto_fuzzers_targets |
| 95 | } |
| 96 | all_targets += [ ":fuzzers" ] |
| 97 | } |
| 98 | |
| 99 | # Less interesting stuff that makes sense only in the standalone build, mainly |
| 100 | # compile-time checks for the CI. |
| 101 | if (perfetto_build_standalone) { |
| 102 | all_targets += [ |
| 103 | "src/tracing:consumer_api_test", |
| 104 | "test/configs", |
| 105 | |
| 106 | # For syntax-checking the proto. |
| 107 | "protos/perfetto/config:merged_config", |
| 108 | "protos/perfetto/trace:merged_trace", # For syntax-checking the proto. |
| 109 | |
Primiano Tucci | 57dd66b | 2019-10-15 23:09:04 +0100 | [diff] [blame] | 110 | # For checking all generated xxx.gen.{cc,h} files without waiting for |
| 111 | # embedders to try to use them and fail. |
| 112 | "protos/perfetto/trace:cpp", |
| 113 | "protos/perfetto/config:cpp", |
| 114 | "protos/perfetto/common:cpp", |
| 115 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 116 | # The diff testing framework depends on these descriptors. |
Primiano Tucci | 687249c | 2019-10-03 15:58:38 +0100 | [diff] [blame] | 117 | "protos/perfetto/metrics:descriptor($host_toolchain)", |
| 118 | "protos/perfetto/trace:descriptor($host_toolchain)", |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 119 | |
| 120 | # Used in the when updating the ftrace protos |
| 121 | "protos/perfetto/trace/ftrace:descriptor", |
| 122 | ] |
| 123 | } |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 124 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 125 | group("all") { |
| 126 | testonly = true # allow to build also test targets |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 127 | deps = all_targets |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 128 | } |
| 129 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 130 | # This target is used when running ninja without any argument (by default would |
| 131 | # build all reachable targets). This is mainly used to prevent the UI being |
| 132 | # built when running ninja -C out/xxx. |
| 133 | # This has effect only in standalone builds, no effect on chromium builds. |
| 134 | # Chromium's "all" target depends on our "all" target above. However chromium's |
| 135 | # "default" target depends on any target that we cause to be discovered by |
| 136 | # depending on other GN files. |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 137 | group("default") { |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 138 | testonly = true |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 139 | deps = [ |
| 140 | ":all", |
| 141 | ] |
| 142 | } |
| 143 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 144 | # +----------------------------------------------------------------------------+ |
| 145 | # | Other definitions: root targets that don't belong to any other subdirectory| |
| 146 | # +----------------------------------------------------------------------------+ |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 147 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 148 | if (enable_perfetto_ui) { |
Mikhail Khokhlov | 8643d1c | 2019-06-04 12:02:47 +0100 | [diff] [blame] | 149 | group("ui") { |
| 150 | deps = [ |
| 151 | "ui", |
| 152 | ] |
| 153 | } |
| 154 | } |
| 155 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 156 | # In Android builds, we build the code of traced and traced_probes in one shared |
| 157 | # library that exposes one xxx_main() for each. The executables themselves are |
| 158 | # tiny shells that just invoke their own entry point into the library. |
| 159 | # This is done merely for saving binary size, because the three binaries happen |
| 160 | # to share a lot of code. |
| 161 | # When setting monolithic_binaries=true (only supported in standalone builds) |
| 162 | # it builds more conventional executables, where each binary has the full |
| 163 | # implementation and no shared library dependency. This is to make dev cycles |
| 164 | # on Android faster, avoiding all the LD_LIBRARY_PATH boilerplate. |
| 165 | # libperfetto.so is also used for stuff that is exposed to the rest of the |
| 166 | # Android tree. |
| 167 | if (enable_perfetto_platform_services) { |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 168 | if (monolithic_binaries) { |
Primiano Tucci | 098f095 | 2019-09-03 10:21:20 +0100 | [diff] [blame] | 169 | libperfetto_target_type = "static_library" |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 170 | } else { |
Primiano Tucci | bdb2a59 | 2018-10-11 15:59:29 +0100 | [diff] [blame] | 171 | libperfetto_target_type = "shared_library" |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Primiano Tucci | bdb2a59 | 2018-10-11 15:59:29 +0100 | [diff] [blame] | 174 | target(libperfetto_target_type, "libperfetto") { |
Primiano Tucci | 098f095 | 2019-09-03 10:21:20 +0100 | [diff] [blame] | 175 | if (libperfetto_target_type == "static_library") { |
| 176 | complete_static_lib = true |
| 177 | } |
Primiano Tucci | 4e49c02 | 2017-12-21 18:22:44 +0100 | [diff] [blame] | 178 | deps = [ |
| 179 | "gn:default_deps", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 180 | "src/traced/probes", |
| 181 | "src/traced/service", |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 182 | "src/tracing:consumer_api_deprecated", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 183 | ] |
| 184 | } |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 185 | } |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 186 | |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 187 | if (!build_with_chromium) { |
| 188 | # Client library target. |
| 189 | # Still in experimental stage and not API stable yet. |
| 190 | # See "libperfetto_client_example" (in Android.bp.extras) for an example |
| 191 | # on how to use the Perfetto Client API from the android tree. |
| 192 | static_library("libperfetto_client_experimental") { |
| 193 | complete_static_lib = true |
| 194 | deps = [ |
| 195 | "gn:default_deps", |
| 196 | "src/tracing", |
| 197 | "src/tracing:client_api", |
| 198 | "src/tracing:platform_posix", |
| 199 | ] |
| 200 | sources = [ |
| 201 | "include/perfetto/tracing.h", |
| 202 | ] |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 203 | } |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Primiano Tucci | 02c1176 | 2019-08-30 00:57:59 +0200 | [diff] [blame] | 206 | # TODO(primiano): there seem to be two "libperfetto" and one |
| 207 | # "libperfetto_client_experimental" targets defined within this BUILD.gn file. |
| 208 | # Rationalize them with eseckler@. For now seems this one is only used from |
| 209 | # chromium and the other one only from the Android tree. |
Primiano Tucci | 7e05fc1 | 2019-08-27 17:29:47 +0200 | [diff] [blame] | 210 | if (build_with_chromium) { |
| 211 | component("libperfetto") { |
Primiano Tucci | 20b760c | 2018-01-19 12:36:12 +0000 | [diff] [blame] | 212 | public_configs = [ "gn:public_config" ] |
Oystein Eftevaag | 5e8a4eb | 2018-01-09 11:41:58 -0800 | [diff] [blame] | 213 | deps = [ |
Eric Seckler | 239f5fa | 2019-11-13 18:03:18 +0000 | [diff] [blame] | 214 | "src/trace_processor:export_json", |
| 215 | "src/trace_processor:storage", |
Oystein Eftevaag | 5e8a4eb | 2018-01-09 11:41:58 -0800 | [diff] [blame] | 216 | "src/tracing", |
| 217 | ] |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 218 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 219 | configs += [ "//build/config/compiler:no_chromium_code" ] |
| 220 | public_deps = [ |
Eric Seckler | 239f5fa | 2019-11-13 18:03:18 +0000 | [diff] [blame] | 221 | "include/perfetto/ext/trace_processor:export_json", |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 222 | "include/perfetto/ext/tracing/core", |
Eric Seckler | 239f5fa | 2019-11-13 18:03:18 +0000 | [diff] [blame] | 223 | "include/perfetto/trace_processor:storage", |
Nicolò Mazzucato | c108446 | 2019-09-24 16:26:06 +0100 | [diff] [blame] | 224 | "protos/perfetto/common:zero", |
Oystein Eftevaag | 6fcedac | 2018-07-02 12:02:55 -0700 | [diff] [blame] | 225 | "protos/perfetto/trace:zero", |
| 226 | "protos/perfetto/trace/chrome:zero", |
Eric Seckler | d3139b4 | 2019-02-26 13:43:59 +0000 | [diff] [blame] | 227 | "protos/perfetto/trace/interned_data:zero", |
Oystein Eftevaag | ae11620 | 2019-07-11 09:48:42 -0700 | [diff] [blame] | 228 | "protos/perfetto/trace/profiling:zero", |
Eric Seckler | d3139b4 | 2019-02-26 13:43:59 +0000 | [diff] [blame] | 229 | "protos/perfetto/trace/track_event:zero", |
Eric Seckler | b0ea760 | 2019-11-13 18:41:52 +0000 | [diff] [blame] | 230 | "src/tracing:sliced_protobuf_input_stream", |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 231 | ] |
Oystein Eftevaag | 5e8a4eb | 2018-01-09 11:41:58 -0800 | [diff] [blame] | 232 | } |
Eric Seckler | a7870e6 | 2019-11-01 10:11:58 +0000 | [diff] [blame] | 233 | if (enable_perfetto_trace_processor_sqlite) { |
| 234 | component("libtrace_processor") { |
| 235 | public_configs = [ "gn:public_config" ] |
| 236 | deps = [ |
| 237 | "src/trace_processor:lib", |
| 238 | ] |
| 239 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 240 | configs += [ "//build/config/compiler:no_chromium_code" ] |
| 241 | public_deps = [ |
| 242 | "include/perfetto/trace_processor", |
| 243 | ] |
| 244 | } |
| 245 | } |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 246 | } |