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