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 | |
| 18 | if (perfetto_build_standalone || perfetto_build_with_android) { |
Florian Mayer | f98c9d6 | 2018-09-03 16:38:16 +0100 | [diff] [blame] | 19 | import("//gn/standalone/android.gni") |
| 20 | } else { |
| 21 | import("//build/config/android/config.gni") |
| 22 | } |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 23 | |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 24 | # For use_libfuzzer. |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 25 | if (perfetto_build_standalone || perfetto_build_with_android) { |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 26 | import("//gn/standalone/sanitizers/vars.gni") |
| 27 | } else { |
| 28 | import("//build/config/sanitizers/sanitizers.gni") |
| 29 | } |
| 30 | |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 31 | declare_args() { |
| 32 | # Only for local development. When true the binaries (perfetto, traced, ...) |
| 33 | # are monolithic and don't use a common shared library. This is mainly to |
| 34 | # avoid LD_LIBRARY_PATH dances when testing locally. |
| 35 | monolithic_binaries = false |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 36 | |
| 37 | # libunwindstack requires API level 26 or newer. |
Florian Mayer | a2fae26 | 2018-08-31 12:10:01 -0700 | [diff] [blame] | 38 | should_build_heapprofd = |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 39 | (perfetto_build_standalone || perfetto_build_with_android) && is_clang && |
| 40 | (is_linux || is_android) && |
| 41 | (!is_android || android_api_level >= 26 || perfetto_build_with_android) |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 42 | } |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 43 | assert(!monolithic_binaries || !perfetto_build_with_android) |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 44 | |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 45 | group("all") { |
| 46 | testonly = true # allow to build also test targets |
| 47 | deps = [ |
Eric Seckler | a6ba179 | 2019-01-02 12:51:00 +0000 | [diff] [blame] | 48 | ":perfetto_unittests", |
Primiano Tucci | 764c504 | 2019-06-22 18:28:45 +0100 | [diff] [blame] | 49 | "src/protozero/protoc_plugin:protozero_plugin($host_toolchain)", |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 50 | ] |
Lalit Maganti | edace41 | 2019-06-18 13:28:28 +0100 | [diff] [blame] | 51 | if (perfetto_build_standalone || perfetto_build_with_android || |
| 52 | build_with_chromium) { |
| 53 | deps += [ ":trace_processor_shell" ] |
Mikhail Khokhlov | 8643d1c | 2019-06-04 12:02:47 +0100 | [diff] [blame] | 54 | } |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 55 | if (perfetto_build_standalone || perfetto_build_with_android) { |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 56 | deps += [ |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 57 | ":perfetto", |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 58 | ":perfetto_integrationtests", |
| 59 | ":traced", |
| 60 | ":traced_probes", |
Hector Dearman | 696ff77 | 2019-04-23 18:38:53 +0100 | [diff] [blame] | 61 | ":trigger_perfetto", |
Primiano Tucci | c501080 | 2018-01-19 17:13:21 +0000 | [diff] [blame] | 62 | "protos/perfetto/config:merged_config", # For syntax-checking the proto. |
Hector Dearman | e92c674 | 2018-11-22 21:42:39 +0000 | [diff] [blame] | 63 | "protos/perfetto/trace:merged_trace", # For syntax-checking the proto. |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 64 | "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)", |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 65 | "src/tracing:client_api", |
Primiano Tucci | dd5ebc9 | 2019-07-25 01:09:37 +0100 | [diff] [blame] | 66 | "test:client_api_example", |
Oystein Eftevaag | 51e06e5 | 2018-01-18 11:28:49 -0800 | [diff] [blame] | 67 | "tools:protoc_helper", |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 68 | ] |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 69 | if (perfetto_build_standalone) { |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 70 | deps += [ |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 71 | ":perfetto_benchmarks", |
Florian Mayer | c50bcc9 | 2019-02-07 11:43:30 +0000 | [diff] [blame] | 72 | "src/profiling/memory:ring_buffer", |
Primiano Tucci | 3cd3132 | 2018-10-11 20:06:56 +0100 | [diff] [blame] | 73 | "src/tracing:consumer_api_test", |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 74 | "test/configs", |
| 75 | "tools/ftrace_proto_gen:ftrace_proto_gen", |
| 76 | "tools/proto_to_cpp", |
Hector Dearman | 7fead1c | 2019-06-25 00:47:38 +0100 | [diff] [blame] | 77 | "tools/protoprofile", |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 78 | "tools/trace_to_text", |
Hector Dearman | 499cd60 | 2018-11-20 13:02:31 +0000 | [diff] [blame] | 79 | "tools/trace_to_text:trace_to_text_lite_host($host_toolchain)", |
Lalit Maganti | f9799c6 | 2019-05-28 20:01:08 +0100 | [diff] [blame] | 80 | |
| 81 | # The diff testing framework depends on these descriptors. |
| 82 | "protos/perfetto/metrics:descriptor", |
| 83 | "protos/perfetto/trace:descriptor", |
Hector Dearman | 7a9ffa7 | 2019-08-13 16:00:10 +0100 | [diff] [blame] | 84 | |
| 85 | # Used in the when updating the ftrace protos |
| 86 | "protos/perfetto/trace/ftrace:descriptor", |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 87 | ] |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 88 | if (is_linux || is_android) { |
Ryan Savitski | db7f1ae | 2019-04-10 17:28:28 +0100 | [diff] [blame] | 89 | deps += [ "tools/busy_threads" ] |
Ryan Savitski | 488e122 | 2019-06-26 21:28:42 +0100 | [diff] [blame] | 90 | deps += [ "tools/cpu_utilization" ] |
Lalit Maganti | 787418f | 2019-04-11 14:14:23 +0100 | [diff] [blame] | 91 | deps += [ "tools/dump_ftrace_stats" ] |
Ryan Savitski | 488e122 | 2019-06-26 21:28:42 +0100 | [diff] [blame] | 92 | deps += [ "tools/skippy" ] |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 93 | } |
Florian Mayer | 2e48071 | 2018-12-07 16:25:41 +0000 | [diff] [blame] | 94 | if (is_fuzzer) { |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 95 | deps += [ ":fuzzers" ] |
| 96 | } |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 97 | } |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 98 | } |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 99 | } |
| 100 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 101 | # TODO(primiano): temporary workaround to: |
| 102 | # 1) Prevent that the UI gets build automatically when doing ninja -C out/xx . |
| 103 | # 2) Avoid breaking the chrome build, that right now depends on "all". |
| 104 | group("default") { |
| 105 | testonly = true # allow to build also test targets |
| 106 | deps = [ |
| 107 | ":all", |
| 108 | ] |
| 109 | } |
| 110 | |
Mikhail Khokhlov | 8643d1c | 2019-06-04 12:02:47 +0100 | [diff] [blame] | 111 | # The trace processor shell executable. An interactive shell that allows to |
| 112 | # make queries on the trace using the terminal. |
Lalit Maganti | edace41 | 2019-06-18 13:28:28 +0100 | [diff] [blame] | 113 | if (perfetto_build_standalone || perfetto_build_with_android || |
| 114 | build_with_chromium) { |
| 115 | executable("trace_processor_shell") { |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 116 | deps = [ |
Lalit Maganti | edace41 | 2019-06-18 13:28:28 +0100 | [diff] [blame] | 117 | "gn:default_deps", |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 118 | "src/trace_processor:trace_processor_shell", |
| 119 | ] |
Lalit Maganti | ca4d514 | 2019-05-28 13:25:47 +0100 | [diff] [blame] | 120 | testonly = true # We need this for proto full. |
Primiano Tucci | 5968caf | 2018-08-06 10:31:46 +0100 | [diff] [blame] | 121 | } |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 122 | } |
| 123 | |
Mikhail Khokhlov | 8643d1c | 2019-06-04 12:02:47 +0100 | [diff] [blame] | 124 | if (perfetto_build_standalone) { |
| 125 | group("ui") { |
| 126 | deps = [ |
| 127 | "ui", |
| 128 | ] |
| 129 | } |
| 130 | } |
| 131 | |
Eric Seckler | a6ba179 | 2019-01-02 12:51:00 +0000 | [diff] [blame] | 132 | test("perfetto_unittests") { |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 133 | deps = [ |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 134 | "gn:default_deps", |
Florian Mayer | d8bd81b | 2018-01-25 12:49:15 +0000 | [diff] [blame] | 135 | "gn:gtest_main", |
Hector Dearman | 6cfec8a | 2018-03-14 16:54:09 +0000 | [diff] [blame] | 136 | "src/base:unittests", |
Bruce Dawson | c3e6763 | 2018-05-14 14:07:51 +0100 | [diff] [blame] | 137 | "src/protozero:unittests", |
Oystein Eftevaag | e5e84fb | 2018-06-01 17:34:56 -0700 | [diff] [blame] | 138 | "src/tracing:unittests", |
Primiano Tucci | ae2879e | 2017-09-27 11:02:09 +0900 | [diff] [blame] | 139 | ] |
Primiano Tucci | 1640ffa | 2018-05-14 18:25:33 +0100 | [diff] [blame] | 140 | |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 141 | if (perfetto_build_standalone || perfetto_build_with_android) { |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 142 | deps += [ |
| 143 | "src/ipc:unittests", |
| 144 | "src/perfetto_cmd:unittests", |
Florian Mayer | c50bcc9 | 2019-02-07 11:43:30 +0000 | [diff] [blame] | 145 | "src/profiling/memory:ring_buffer_unittests", |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 146 | "src/traced/probes:unittests", |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 147 | "src/traced/probes/filesystem:unittests", |
Primiano Tucci | de82dae | 2018-06-04 16:17:49 +0200 | [diff] [blame] | 148 | "src/traced/probes/ftrace:unittests", |
Eric Seckler | 2107774 | 2019-03-18 09:07:54 +0000 | [diff] [blame] | 149 | "src/traced/service:unittests", |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 150 | "tools/ftrace_proto_gen:unittests", |
Oystein Eftevaag | 067fd5b | 2018-03-27 12:39:30 -0700 | [diff] [blame] | 151 | "tools/sanitizers_unittests", |
| 152 | ] |
Primiano Tucci | 931284e | 2017-12-11 09:23:53 +0000 | [diff] [blame] | 153 | } |
Florian Mayer | b64d6b1 | 2018-08-30 10:46:30 -0700 | [diff] [blame] | 154 | if (should_build_heapprofd) { |
| 155 | # Restrict to clang, as libunwindstack and its dependencies is never |
| 156 | # built using GCC in the Android tree. |
| 157 | deps += [ "src/profiling/memory:unittests" ] |
| 158 | } |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 159 | if (perfetto_build_standalone && !is_android) { |
Lalit Maganti | 5f3a018 | 2019-05-07 16:40:36 +0100 | [diff] [blame] | 160 | deps += [ |
| 161 | "src/trace_processor:unittests", |
| 162 | "src/trace_processor/metrics:unittests", |
| 163 | ] |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 164 | } |
Primiano Tucci | b03ba36 | 2017-12-06 09:47:41 +0000 | [diff] [blame] | 165 | } |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame] | 166 | |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 167 | if (perfetto_build_standalone || perfetto_build_with_android) { |
Eric Seckler | a6ba179 | 2019-01-02 12:51:00 +0000 | [diff] [blame] | 168 | test("perfetto_integrationtests") { |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 169 | deps = [ |
| 170 | "gn:default_deps", |
Florian Mayer | d8bd81b | 2018-01-25 12:49:15 +0000 | [diff] [blame] | 171 | "gn:gtest_main", |
Primiano Tucci | de82dae | 2018-06-04 16:17:49 +0200 | [diff] [blame] | 172 | "src/traced/probes/ftrace:integrationtests", |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 173 | "src/tracing:client_api_integrationtests", |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 174 | "test:end_to_end_integrationtests", |
| 175 | ] |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 176 | if (perfetto_build_standalone && !is_android) { |
Hector Dearman | 7f71d0e | 2018-08-09 11:26:10 +0100 | [diff] [blame] | 177 | deps += [ "src/trace_processor:integrationtests" ] |
| 178 | } |
Florian Mayer | 4280249 | 2018-12-13 11:00:16 +0000 | [diff] [blame] | 179 | |
| 180 | # TODO(fmayer): Fix in process daemons. |
Florian Mayer | 087d37f | 2019-05-23 12:59:08 +0100 | [diff] [blame] | 181 | if (should_build_heapprofd) { |
Florian Mayer | 4280249 | 2018-12-13 11:00:16 +0000 | [diff] [blame] | 182 | deps += [ "src/profiling/memory:end_to_end_tests" ] |
| 183 | } |
Lalit Maganti | 79f2d7b | 2018-01-23 18:27:33 +0000 | [diff] [blame] | 184 | } |
| 185 | |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 186 | if (monolithic_binaries) { |
Primiano Tucci | bdb2a59 | 2018-10-11 15:59:29 +0100 | [diff] [blame] | 187 | libperfetto_target_type = "source_set" |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 188 | } else { |
Primiano Tucci | bdb2a59 | 2018-10-11 15:59:29 +0100 | [diff] [blame] | 189 | libperfetto_target_type = "shared_library" |
Primiano Tucci | f3837d5 | 2018-01-10 21:12:41 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Primiano Tucci | bdb2a59 | 2018-10-11 15:59:29 +0100 | [diff] [blame] | 192 | target(libperfetto_target_type, "libperfetto") { |
Primiano Tucci | 4e49c02 | 2017-12-21 18:22:44 +0100 | [diff] [blame] | 193 | deps = [ |
| 194 | "gn:default_deps", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 195 | "src/traced/probes", |
| 196 | "src/traced/service", |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 197 | "src/tracing:consumer_api_deprecated", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 198 | ] |
| 199 | } |
| 200 | |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 201 | # The unprivileged trace daemon that listens for Producer and Consumer |
| 202 | # connections, handles the coordination of the tracing sessions and owns the |
| 203 | # log buffers. |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 204 | executable("traced") { |
| 205 | deps = [ |
Primiano Tucci | bdb2a59 | 2018-10-11 15:59:29 +0100 | [diff] [blame] | 206 | ":libperfetto", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 207 | "gn:default_deps", |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 208 | "include/perfetto/ext/traced", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 209 | ] |
| 210 | sources = [ |
| 211 | "src/traced/service/main.cc", |
| 212 | ] |
| 213 | } |
| 214 | |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 215 | # The unprivileged daemon that is allowed to access tracefs (for ftrace). |
| 216 | # Registers as a Producer on the traced daemon. |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 217 | executable("traced_probes") { |
| 218 | deps = [ |
Primiano Tucci | bdb2a59 | 2018-10-11 15:59:29 +0100 | [diff] [blame] | 219 | ":libperfetto", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 220 | "gn:default_deps", |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 221 | "include/perfetto/ext/traced", |
Primiano Tucci | 6067e73 | 2018-01-08 16:19:40 +0000 | [diff] [blame] | 222 | ] |
| 223 | sources = [ |
| 224 | "src/traced/probes/main.cc", |
Primiano Tucci | 4e49c02 | 2017-12-21 18:22:44 +0100 | [diff] [blame] | 225 | ] |
| 226 | } |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 227 | |
| 228 | # The command line client for Perfetto. Allows to configure / start / stop |
| 229 | # tracing, acting as a Consumer. |
| 230 | executable("perfetto") { |
| 231 | deps = [ |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 232 | "gn:default_deps", |
Hector Dearman | c443a36 | 2018-02-28 16:03:56 +0000 | [diff] [blame] | 233 | "src/perfetto_cmd", |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 234 | ] |
| 235 | sources = [ |
Hector Dearman | c443a36 | 2018-02-28 16:03:56 +0000 | [diff] [blame] | 236 | "src/perfetto_cmd/main.cc", |
Primiano Tucci | 3b72910 | 2018-01-08 18:16:36 +0000 | [diff] [blame] | 237 | ] |
| 238 | } |
Primiano Tucci | 6aa7557 | 2018-03-21 05:33:14 -0700 | [diff] [blame] | 239 | |
Hector Dearman | 696ff77 | 2019-04-23 18:38:53 +0100 | [diff] [blame] | 240 | # Tool to finalize long running traces. |
| 241 | # This connects to traced as a producer and sends the triggers passed on the |
| 242 | # commandline. This is a subset of what the perfetto binary can do but we |
| 243 | # need a separate binary for programs that cannot (for good reason) use the |
| 244 | # additional functionality (for example starting traces via consumer socket) |
| 245 | # due to selinux rules. |
| 246 | executable("trigger_perfetto") { |
| 247 | deps = [ |
| 248 | "gn:default_deps", |
| 249 | "src/perfetto_cmd:trigger_perfetto_cmd", |
| 250 | ] |
| 251 | sources = [ |
| 252 | "src/perfetto_cmd/trigger_perfetto_main.cc", |
| 253 | ] |
| 254 | } |
| 255 | |
Primiano Tucci | 658e2d6 | 2019-06-14 10:03:32 +0100 | [diff] [blame] | 256 | # Client library target for the Android tree. |
| 257 | # Still in experimental stage and not API stable yet. |
| 258 | # See "libperfetto_client_example" (in Android.bp.extras) for an example |
| 259 | # on how to use the Perfetto Client API from the android tree. |
| 260 | static_library("libperfetto_client_experimental") { |
| 261 | complete_static_lib = true |
| 262 | deps = [ |
| 263 | "gn:default_deps", |
| 264 | "src/tracing", |
| 265 | "src/tracing:client_api", |
| 266 | "src/tracing:platform_posix", |
| 267 | ] |
| 268 | sources = [ |
| 269 | "include/perfetto/tracing.h", |
| 270 | ] |
| 271 | } |
| 272 | |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 273 | if (perfetto_build_with_android) { |
Primiano Tucci | 21c19d8 | 2018-03-29 12:35:08 +0100 | [diff] [blame] | 274 | executable("trace_to_text") { |
| 275 | testonly = true |
| 276 | deps = [ |
| 277 | "gn:default_deps", |
Primiano Tucci | 20dc8f7 | 2018-10-23 12:28:29 +0100 | [diff] [blame] | 278 | "tools/trace_to_text:full", |
Primiano Tucci | 21c19d8 | 2018-03-29 12:35:08 +0100 | [diff] [blame] | 279 | ] |
| 280 | } |
Primiano Tucci | 21c19d8 | 2018-03-29 12:35:08 +0100 | [diff] [blame] | 281 | |
Primiano Tucci | 808d6df | 2018-03-31 13:24:18 +0100 | [diff] [blame] | 282 | # This target exports perfetto trace protos in the Android build system, |
| 283 | # allowing both host and device targets to implement custom parsers based on |
| 284 | # our protos. |
| 285 | static_library("perfetto_trace_protos") { |
| 286 | deps = [ |
| 287 | "protos/perfetto/trace:lite", |
| 288 | ] |
| 289 | } |
Primiano Tucci | 676f0cc | 2018-12-03 20:03:26 +0100 | [diff] [blame] | 290 | |
| 291 | shared_library("libperfetto_android_internal") { |
| 292 | deps = [ |
| 293 | "gn:default_deps", |
| 294 | "src/android_internal", |
| 295 | ] |
| 296 | } |
| 297 | } # if (perfetto_build_with_android) |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 298 | } # if (perfetto_build_standalone || perfetto_build_with_android) |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 299 | |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 300 | if (perfetto_build_with_embedder) { |
| 301 | if (build_with_chromium) { |
Eric Seckler | 8f5299c | 2019-08-09 14:47:30 +0100 | [diff] [blame] | 302 | lib_target_type = "component" |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 303 | } else { |
Eric Seckler | 8f5299c | 2019-08-09 14:47:30 +0100 | [diff] [blame] | 304 | lib_target_type = "source_set" |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 305 | } |
Eric Seckler | 8f5299c | 2019-08-09 14:47:30 +0100 | [diff] [blame] | 306 | target(lib_target_type, "libperfetto") { |
Primiano Tucci | 20b760c | 2018-01-19 12:36:12 +0000 | [diff] [blame] | 307 | public_configs = [ "gn:public_config" ] |
Oystein Eftevaag | 5e8a4eb | 2018-01-09 11:41:58 -0800 | [diff] [blame] | 308 | deps = [ |
| 309 | "src/tracing", |
| 310 | ] |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 311 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 312 | configs += [ "//build/config/compiler:no_chromium_code" ] |
| 313 | public_deps = [ |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 314 | "include/perfetto/ext/tracing/core", |
Oystein Eftevaag | 6fcedac | 2018-07-02 12:02:55 -0700 | [diff] [blame] | 315 | "protos/perfetto/trace:zero", |
| 316 | "protos/perfetto/trace/chrome:zero", |
Eric Seckler | d3139b4 | 2019-02-26 13:43:59 +0000 | [diff] [blame] | 317 | "protos/perfetto/trace/interned_data:zero", |
Oystein Eftevaag | ae11620 | 2019-07-11 09:48:42 -0700 | [diff] [blame] | 318 | "protos/perfetto/trace/profiling:zero", |
Eric Seckler | d3139b4 | 2019-02-26 13:43:59 +0000 | [diff] [blame] | 319 | "protos/perfetto/trace/track_event:zero", |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 320 | ] |
Oystein Eftevaag | 5e8a4eb | 2018-01-09 11:41:58 -0800 | [diff] [blame] | 321 | } |
Eric Seckler | 8f5299c | 2019-08-09 14:47:30 +0100 | [diff] [blame] | 322 | target(lib_target_type, "libtrace_processor") { |
| 323 | public_configs = [ "gn:public_config" ] |
| 324 | deps = [ |
| 325 | "src/trace_processor:lib", |
| 326 | ] |
| 327 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 328 | configs += [ "//build/config/compiler:no_chromium_code" ] |
| 329 | public_deps = [ |
| 330 | "include/perfetto/trace_processor", |
| 331 | ] |
| 332 | } |
Oystein Eftevaag | a812a94 | 2018-03-23 11:52:32 -0700 | [diff] [blame] | 333 | } |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 334 | |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 335 | if (perfetto_build_standalone) { |
| 336 | executable("perfetto_benchmarks") { |
| 337 | testonly = true |
| 338 | deps = [ |
| 339 | "gn:default_deps", |
| 340 | "src/traced/probes/ftrace:benchmarks", |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 341 | "test:benchmark_main", |
| 342 | "test:end_to_end_benchmarks", |
| 343 | ] |
| 344 | } |
| 345 | |
Primiano Tucci | 59d6ace | 2018-09-26 22:24:20 +0100 | [diff] [blame] | 346 | group("fuzzers") { |
| 347 | testonly = true |
| 348 | deps = [ |
| 349 | "src/ipc:buffered_frame_deserializer_fuzzer", |
Florian Mayer | 4a1ee94 | 2019-02-07 15:51:16 +0000 | [diff] [blame] | 350 | "src/profiling/memory:shared_ring_buffer_fuzzer", |
Florian Mayer | 0038918 | 2019-04-08 16:43:21 +0100 | [diff] [blame] | 351 | "src/profiling/memory:shared_ring_buffer_write_fuzzer", |
Florian Mayer | c365e36 | 2018-10-24 13:21:17 +0100 | [diff] [blame] | 352 | "src/profiling/memory:unwinding_fuzzer", |
Primiano Tucci | c167887 | 2019-03-20 11:30:54 +0000 | [diff] [blame] | 353 | "src/protozero:protozero_decoder_fuzzer", |
Hector Dearman | 59bc02d | 2019-02-21 17:28:11 +0000 | [diff] [blame] | 354 | "src/trace_processor:trace_processor_fuzzer", |
Primiano Tucci | 59d6ace | 2018-09-26 22:24:20 +0100 | [diff] [blame] | 355 | "src/traced/probes/ftrace:cpu_reader_fuzzer", |
| 356 | "test:end_to_end_shared_memory_fuzzer", |
Stephen Nusko | 9554513 | 2019-07-09 15:00:54 +0100 | [diff] [blame] | 357 | "test:producer_socket_fuzzer", |
Primiano Tucci | 59d6ace | 2018-09-26 22:24:20 +0100 | [diff] [blame] | 358 | ] |
| 359 | } |
Primiano Tucci | a195971 | 2018-05-17 11:01:56 +0100 | [diff] [blame] | 360 | } |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 361 | |
Ryan Savitski | e65beca | 2019-01-29 18:29:13 +0000 | [diff] [blame] | 362 | # WARNING: this builds correctly only when using the generated Android.bp. |
| 363 | # |
| 364 | # This library gets loaded into (and executes in) arbitrary android processes. |
| 365 | # Logging must be non-allocating. This is achieved by defining |
| 366 | # PERFETTO_ANDROID_ASYNC_SAFE_LOG, which needs to be set for all perfetto code |
| 367 | # being compiled for this library. When generating Android.bp, the |cflags| |
| 368 | # entry on this target is sufficient (as all sources are flattened into a |
| 369 | # single bp target). However this is not correctly reflected in the gn |
| 370 | # structure (which is a tree of targets) as the dependencies would not pick |
| 371 | # up the flag (and thus use the wrong logging macro). |
| 372 | # |
| 373 | # This is deemed acceptable as, at the time of writing, there is no interest in |
| 374 | # building this library standalone. |
Primiano Tucci | 4c5efa4 | 2018-10-23 13:15:13 +0100 | [diff] [blame] | 375 | if (perfetto_build_with_android) { |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 376 | # TODO(fmayer): Investigate shared library for common pieces. |
| 377 | shared_library("heapprofd_client") { |
Ryan Savitski | a3da9be | 2019-01-30 17:45:53 +0000 | [diff] [blame] | 378 | configs -= [ "//gn/standalone:android_liblog" ] |
Ryan Savitski | e65beca | 2019-01-29 18:29:13 +0000 | [diff] [blame] | 379 | cflags = [ "-DPERFETTO_ANDROID_ASYNC_SAFE_LOG" ] |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 380 | deps = [ |
| 381 | "src/profiling/memory:malloc_hooks", |
| 382 | ] |
| 383 | } |
Florian Mayer | 8e7eac4 | 2018-11-05 16:04:11 +0000 | [diff] [blame] | 384 | } |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 385 | |
Florian Mayer | 8e7eac4 | 2018-11-05 16:04:11 +0000 | [diff] [blame] | 386 | if (should_build_heapprofd) { |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 387 | executable("heapprofd") { |
| 388 | deps = [ |
| 389 | "gn:default_deps", |
Florian Mayer | 4afdd64 | 2018-11-13 11:11:04 +0000 | [diff] [blame] | 390 | "protos/perfetto/trace:zero", |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 391 | "src/base", |
| 392 | "src/base:unix_socket", |
| 393 | "src/profiling/memory:daemon", |
| 394 | "src/profiling/memory:wire_protocol", |
Florian Mayer | 8e7eac4 | 2018-11-05 16:04:11 +0000 | [diff] [blame] | 395 | "src/tracing:ipc", |
Florian Mayer | b6a921f | 2018-10-18 18:55:23 +0100 | [diff] [blame] | 396 | ] |
| 397 | sources = [ |
| 398 | "src/profiling/memory/main.cc", |
| 399 | ] |
| 400 | } |
| 401 | } |
Florian Mayer | 67be965 | 2019-05-31 16:17:11 +0100 | [diff] [blame] | 402 | |
Eric Seckler | 4d7ccd9 | 2019-06-04 15:50:16 +0100 | [diff] [blame] | 403 | if (perfetto_build_standalone) { |
| 404 | executable("idle_alloc") { |
| 405 | sources = [ |
| 406 | "tools/idle_alloc.cc", |
| 407 | ] |
| 408 | } |
Florian Mayer | 67be965 | 2019-05-31 16:17:11 +0100 | [diff] [blame] | 409 | } |