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") |
Florian Mayer | f98c9d6 | 2018-09-03 16:38:16 +0100 | [diff] [blame] | 16 | if (!build_with_chromium) { |
| 17 | import("//gn/standalone/android.gni") |
| 18 | } else { |
| 19 | import("//build/config/android/config.gni") |
| 20 | } |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 21 | |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 22 | # For use_libfuzzer. |
| 23 | if (!build_with_chromium) { |
| 24 | import("//gn/standalone/sanitizers/vars.gni") |
| 25 | } else { |
| 26 | import("//build/config/sanitizers/sanitizers.gni") |
| 27 | } |
| 28 | |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 29 | declare_args() { |
| 30 | # Only for local development. When true the binaries (perfetto, traced, ...) |
| 31 | # are monolithic and don't use a common shared library. This is mainly to |
| 32 | # avoid LD_LIBRARY_PATH dances when testing locally. |
| 33 | monolithic_binaries = false |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 34 | |
| 35 | # libunwindstack requires API level 26 or newer. |
Florian Mayer | a2fae26 | 2018-08-31 12:10:01 -0700 | [diff] [blame] | 36 | should_build_heapprofd = |
Primiano Tucci | 5313adf | 2018-09-09 15:10:59 +0100 | [diff] [blame] | 37 | !build_with_chromium && is_clang && (is_linux || is_android) && |
Florian Mayer | a2fae26 | 2018-08-31 12:10:01 -0700 | [diff] [blame] | 38 | (!is_android || android_api_level >= 26 || build_with_android) |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 39 | } |
| 40 | assert(!monolithic_binaries || !build_with_android) |
| 41 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 42 | group("all") { |
| 43 | testonly = true # allow to build also test targets |
| 44 | deps = [ |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 45 | ":perfetto_unittests", |
Primiano Tucci | 4f9b6d7 | 2017-12-05 20:59:16 +0000 | [diff] [blame] | 46 | "src/protozero/protoc_plugin($host_toolchain)", |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 47 | ] |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 48 | if (!build_with_chromium) { |
| 49 | deps += [ |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 50 | ":perfetto", |
| 51 | ":perfetto_benchmarks", |
| 52 | ":perfetto_integrationtests", |
| 53 | ":traced", |
| 54 | ":traced_probes", |
Primiano Tucci | c501080 | 2018-01-19 17:13:21 +0000 | [diff] [blame] | 55 | "protos/perfetto/config:merged_config", # For syntax-checking the proto. |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 56 | "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)", |
Hector Dearman | fcbafda | 2018-01-18 11:13:57 +0000 | [diff] [blame] | 57 | "test/configs", |
Oystein Eftevaag | 51e06e5 | 2018-01-18 11:28:49 -0800 | [diff] [blame] | 58 | "tools:protoc_helper", |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 59 | "tools/ftrace_proto_gen:ftrace_proto_gen", |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 60 | "tools/proto_to_cpp", |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 61 | ] |
Primiano Tucci | 21c19d8 | 2018-03-29 12:35:08 +0100 | [diff] [blame] | 62 | if (!build_with_android) { |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 63 | deps += [ |
| 64 | ":trace_processor", |
| 65 | "tools/trace_to_text", |
| 66 | ] |
Primiano Tucci | 21c19d8 | 2018-03-29 12:35:08 +0100 | [diff] [blame] | 67 | } |
Primiano Tucci | c96f71b | 2018-02-06 19:21:09 +0000 | [diff] [blame] | 68 | if (is_linux || is_android) { |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 69 | deps += [ "tools/skippy" ] |
Primiano Tucci | c96f71b | 2018-02-06 19:21:09 +0000 | [diff] [blame] | 70 | } |
Primiano Tucci | 1640ffa | 2018-05-14 18:25:33 +0100 | [diff] [blame] | 71 | if (is_linux) { |
| 72 | deps += [ "tools:pipestats" ] |
| 73 | } |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 74 | if (use_libfuzzer) { |
| 75 | deps += [ ":fuzzers" ] |
| 76 | } |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 77 | } |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 78 | } |
| 79 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 80 | # TODO(primiano): temporary workaround to: |
| 81 | # 1) Prevent that the UI gets build automatically when doing ninja -C out/xx . |
| 82 | # 2) Avoid breaking the chrome build, that right now depends on "all". |
| 83 | group("default") { |
| 84 | testonly = true # allow to build also test targets |
| 85 | deps = [ |
| 86 | ":all", |
| 87 | ] |
| 88 | } |
| 89 | |
| 90 | if (build_standalone) { |
| 91 | group("ui") { |
| 92 | deps = [ |
| 93 | "ui", |
| 94 | ] |
| 95 | } |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 96 | |
| 97 | # The trace processor shell executable. An interactive shell that allows to |
| 98 | # make queries on the trace using the terminal. |
| 99 | group("trace_processor") { |
| 100 | deps = [ |
| 101 | "src/trace_processor:trace_processor_shell", |
| 102 | ] |
| 103 | } |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 104 | } |
| 105 | |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 106 | executable("perfetto_unittests") { |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 107 | testonly = true |
| 108 | deps = [ |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 109 | "gn:default_deps", |
Florian Mayer | d8bd81b | 2018-01-25 12:49:15 +0000 | [diff] [blame] | 110 | "gn:gtest_main", |
Hector Dearman | 6cfec8a | 2018-03-14 16:54:09 +0000 | [diff] [blame] | 111 | "src/base:unittests", |
Bruce Dawson | c3e6763 | 2018-05-14 14:07:51 +0100 | [diff] [blame] | 112 | "src/protozero:unittests", |
Oystein Eftevaag | e5e84fb | 2018-06-01 17:34:56 -0700 | [diff] [blame] | 113 | "src/tracing:unittests", |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 114 | ] |
Primiano Tucci | 1640ffa | 2018-05-14 18:25:33 +0100 | [diff] [blame] | 115 | |
Primiano Tucci | 931284e | 2017-12-11 09:23:53 +0000 | [diff] [blame] | 116 | if (!build_with_chromium) { |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 117 | deps += [ |
| 118 | "src/ipc:unittests", |
| 119 | "src/perfetto_cmd:unittests", |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 120 | "src/traced/probes:unittests", |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 121 | "src/traced/probes/filesystem:unittests", |
Primiano Tucci | de82dae | 2018-06-04 16:17:49 +0200 | [diff] [blame] | 122 | "src/traced/probes/ftrace:unittests", |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 123 | "tools/ftrace_proto_gen:unittests", |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 124 | "tools/sanitizers_unittests", |
| 125 | ] |
Primiano Tucci | 931284e | 2017-12-11 09:23:53 +0000 | [diff] [blame] | 126 | } |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 127 | if (should_build_heapprofd) { |
| 128 | # Restrict to clang, as libunwindstack and its dependencies is never |
| 129 | # built using GCC in the Android tree. |
| 130 | deps += [ "src/profiling/memory:unittests" ] |
| 131 | } |
Hector Dearman | b6b029e | 2018-08-28 10:14:20 +0100 | [diff] [blame] | 132 | if (build_standalone && !is_android) { |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 133 | deps += [ "src/trace_processor:unittests" ] |
| 134 | } |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 135 | } |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 136 | |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 137 | if (!build_with_chromium) { |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 138 | executable("perfetto_benchmarks") { |
| 139 | testonly = true |
| 140 | deps = [ |
| 141 | "gn:default_deps", |
Primiano Tucci | de82dae | 2018-06-04 16:17:49 +0200 | [diff] [blame] | 142 | "src/traced/probes/ftrace:benchmarks", |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 143 | "src/tracing:tracing_benchmarks", |
Hector Dearman | bc8368e | 2018-01-25 17:34:11 +0000 | [diff] [blame] | 144 | "test:benchmark_main", |
Lalit Maganti | bfc3d3e | 2018-03-22 20:28:38 +0000 | [diff] [blame] | 145 | "test:end_to_end_benchmarks", |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 146 | ] |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 147 | } |
Primiano Tucci | 4e49c02 | 2017-12-21 18:22:44 +0100 | [diff] [blame] | 148 | |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 149 | executable("perfetto_integrationtests") { |
| 150 | testonly = true |
| 151 | deps = [ |
| 152 | "gn:default_deps", |
Florian Mayer | d8bd81b | 2018-01-25 12:49:15 +0000 | [diff] [blame] | 153 | "gn:gtest_main", |
Primiano Tucci | de82dae | 2018-06-04 16:17:49 +0200 | [diff] [blame] | 154 | "src/traced/probes/ftrace:integrationtests", |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 155 | "test:end_to_end_integrationtests", |
| 156 | ] |
Hector Dearman | 7f71d0e | 2018-08-09 11:26:10 +0100 | [diff] [blame] | 157 | if (build_standalone && !is_android) { |
| 158 | deps += [ "src/trace_processor:integrationtests" ] |
| 159 | } |
Lalit Maganti | 0b9a6ac | 2018-02-16 18:05:06 +0000 | [diff] [blame] | 160 | if (build_with_android) { |
| 161 | cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ] |
| 162 | } |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 163 | } |
| 164 | |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 165 | if (monolithic_binaries) { |
| 166 | libtraced_shared_target_type = "source_set" |
| 167 | } else { |
| 168 | libtraced_shared_target_type = "shared_library" |
| 169 | } |
| 170 | |
| 171 | target(libtraced_shared_target_type, "libtraced_shared") { |
Primiano Tucci | 4e49c02 | 2017-12-21 18:22:44 +0100 | [diff] [blame] | 172 | deps = [ |
| 173 | "gn:default_deps", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 174 | "src/traced/probes", |
| 175 | "src/traced/service", |
| 176 | ] |
| 177 | } |
| 178 | |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 179 | # The unprivileged trace daemon that listens for Producer and Consumer |
| 180 | # connections, handles the coordination of the tracing sessions and owns the |
| 181 | # log buffers. |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 182 | executable("traced") { |
| 183 | deps = [ |
| 184 | ":libtraced_shared", |
| 185 | "gn:default_deps", |
Primiano Tucci | c2eb510 | 2018-05-15 10:40:01 +0100 | [diff] [blame] | 186 | "include/perfetto/traced", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 187 | ] |
| 188 | sources = [ |
| 189 | "src/traced/service/main.cc", |
| 190 | ] |
| 191 | } |
| 192 | |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 193 | # The unprivileged daemon that is allowed to access tracefs (for ftrace). |
| 194 | # Registers as a Producer on the traced daemon. |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 195 | executable("traced_probes") { |
| 196 | deps = [ |
| 197 | ":libtraced_shared", |
| 198 | "gn:default_deps", |
Primiano Tucci | c2eb510 | 2018-05-15 10:40:01 +0100 | [diff] [blame] | 199 | "include/perfetto/traced", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 200 | ] |
| 201 | sources = [ |
| 202 | "src/traced/probes/main.cc", |
Primiano Tucci | 4e49c02 | 2017-12-21 18:22:44 +0100 | [diff] [blame] | 203 | ] |
| 204 | } |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 205 | |
| 206 | # The command line client for Perfetto. Allows to configure / start / stop |
| 207 | # tracing, acting as a Consumer. |
| 208 | executable("perfetto") { |
| 209 | deps = [ |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 210 | "gn:default_deps", |
Hector Dearman | c443a36 | 2018-02-28 16:03:56 +0000 | [diff] [blame] | 211 | "src/perfetto_cmd", |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 212 | ] |
| 213 | sources = [ |
Hector Dearman | c443a36 | 2018-02-28 16:03:56 +0000 | [diff] [blame] | 214 | "src/perfetto_cmd/main.cc", |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 215 | ] |
Lalit Maganti | 0b9a6ac | 2018-02-16 18:05:06 +0000 | [diff] [blame] | 216 | if (is_android) { |
| 217 | deps += [ "src/base:android_task_runner" ] |
| 218 | } |
Primiano Tucci | 6d84853 | 2018-01-17 10:32:33 +0000 | [diff] [blame] | 219 | if (build_with_android) { |
| 220 | cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ] |
Primiano Tucci | 6d84853 | 2018-01-17 10:32:33 +0000 | [diff] [blame] | 221 | libs = [ |
| 222 | "binder", |
| 223 | "services", |
| 224 | "utils", |
| 225 | ] |
| 226 | } |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 227 | } |
Primiano Tucci | 6aa7557 | 2018-03-21 05:33:14 -0700 | [diff] [blame] | 228 | |
Primiano Tucci | 21c19d8 | 2018-03-29 12:35:08 +0100 | [diff] [blame] | 229 | if (build_with_android) { |
| 230 | executable("trace_to_text") { |
| 231 | testonly = true |
| 232 | deps = [ |
| 233 | "gn:default_deps", |
| 234 | "tools/trace_to_text:lib", |
| 235 | ] |
| 236 | } |
Primiano Tucci | 21c19d8 | 2018-03-29 12:35:08 +0100 | [diff] [blame] | 237 | |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 238 | # This target exports perfetto trace protos in the Android build system, |
| 239 | # allowing both host and device targets to implement custom parsers based on |
| 240 | # our protos. |
| 241 | static_library("perfetto_trace_protos") { |
| 242 | deps = [ |
| 243 | "protos/perfetto/trace:lite", |
| 244 | ] |
| 245 | } |
Primiano Tucci | 6aa7557 | 2018-03-21 05:33:14 -0700 | [diff] [blame] | 246 | } |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | if (build_with_chromium) { |
| 250 | component("libperfetto") { |
Primiano Tucci | 20b760c | 2018-01-19 12:36:12 +0000 | [diff] [blame] | 251 | public_configs = [ "gn:public_config" ] |
Oystein Eftevaag | 5e8a4eb | 2018-01-09 11:41:58 -0800 | [diff] [blame] | 252 | deps = [ |
| 253 | "src/tracing", |
| 254 | ] |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 255 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 256 | configs += [ "//build/config/compiler:no_chromium_code" ] |
| 257 | public_deps = [ |
| 258 | "include/perfetto/tracing/core", |
Oystein Eftevaag | 6fcedac | 2018-07-02 12:02:55 -0700 | [diff] [blame] | 259 | "protos/perfetto/trace:zero", |
| 260 | "protos/perfetto/trace/chrome:zero", |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 261 | ] |
Oystein Eftevaag | 5e8a4eb | 2018-01-09 11:41:58 -0800 | [diff] [blame] | 262 | } |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 263 | } |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 264 | |
Oystein Eftevaag | 608d8f8 | 2018-05-23 09:59:01 -0700 | [diff] [blame] | 265 | if (use_libfuzzer && !build_with_chromium) { |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 266 | group("fuzzers") { |
| 267 | testonly = true |
| 268 | deps = [ |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 269 | "src/ipc:buffered_frame_deserializer_fuzzer", |
Primiano Tucci | de82dae | 2018-06-04 16:17:49 +0200 | [diff] [blame] | 270 | "src/traced/probes/ftrace:cpu_reader_fuzzer", |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 271 | "test:end_to_end_shared_memory_fuzzer", |
| 272 | ] |
| 273 | } |
| 274 | } |