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