blob: 011e15833ebc753b7c8505e6f6b3d97b565aa536 [file] [log] [blame]
Primiano Tucciae2879e2017-09-27 11:02:09 +09001# 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 Eftevaagdd727e42017-12-05 08:49:55 -080015import("gn/perfetto.gni")
Florian Mayerf98c9d62018-09-03 16:38:16 +010016if (!build_with_chromium) {
17 import("//gn/standalone/android.gni")
18} else {
19 import("//build/config/android/config.gni")
20}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080021
Primiano Tuccia1959712018-05-17 11:01:56 +010022# For use_libfuzzer.
23if (!build_with_chromium) {
24 import("//gn/standalone/sanitizers/vars.gni")
25} else {
26 import("//build/config/sanitizers/sanitizers.gni")
27}
28
Primiano Tuccif3837d52018-01-10 21:12:41 +000029declare_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 Mayerb64d6b12018-08-30 10:46:30 -070034
35 # libunwindstack requires API level 26 or newer.
Florian Mayera2fae262018-08-31 12:10:01 -070036 should_build_heapprofd =
Primiano Tucci5313adf2018-09-09 15:10:59 +010037 !build_with_chromium && is_clang && (is_linux || is_android) &&
Florian Mayera2fae262018-08-31 12:10:01 -070038 (!is_android || android_api_level >= 26 || build_with_android)
Primiano Tuccif3837d52018-01-10 21:12:41 +000039}
40assert(!monolithic_binaries || !build_with_android)
41
Primiano Tucciae2879e2017-09-27 11:02:09 +090042group("all") {
43 testonly = true # allow to build also test targets
44 deps = [
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000045 ":perfetto_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000046 "src/protozero/protoc_plugin($host_toolchain)",
Primiano Tucciae2879e2017-09-27 11:02:09 +090047 ]
Primiano Tuccib03ba362017-12-06 09:47:41 +000048 if (!build_with_chromium) {
49 deps += [
Primiano Tucci808d6df2018-03-31 13:24:18 +010050 ":perfetto",
51 ":perfetto_benchmarks",
52 ":perfetto_integrationtests",
53 ":traced",
54 ":traced_probes",
Primiano Tuccic5010802018-01-19 17:13:21 +000055 "protos/perfetto/config:merged_config", # For syntax-checking the proto.
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070056 "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)",
Hector Dearmanfcbafda2018-01-18 11:13:57 +000057 "test/configs",
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080058 "tools:protoc_helper",
Primiano Tucci808d6df2018-03-31 13:24:18 +010059 "tools/ftrace_proto_gen:ftrace_proto_gen",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070060 "tools/proto_to_cpp",
Primiano Tuccib03ba362017-12-06 09:47:41 +000061 ]
Primiano Tucci21c19d82018-03-29 12:35:08 +010062 if (!build_with_android) {
Primiano Tucci5968caf2018-08-06 10:31:46 +010063 deps += [
64 ":trace_processor",
65 "tools/trace_to_text",
66 ]
Primiano Tucci21c19d82018-03-29 12:35:08 +010067 }
Primiano Tuccic96f71b2018-02-06 19:21:09 +000068 if (is_linux || is_android) {
Primiano Tucci808d6df2018-03-31 13:24:18 +010069 deps += [ "tools/skippy" ]
Primiano Tuccic96f71b2018-02-06 19:21:09 +000070 }
Primiano Tucci1640ffa2018-05-14 18:25:33 +010071 if (is_linux) {
72 deps += [ "tools:pipestats" ]
73 }
Primiano Tuccia1959712018-05-17 11:01:56 +010074 if (use_libfuzzer) {
75 deps += [ ":fuzzers" ]
76 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000077 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090078}
79
Primiano Tucci3faad742018-05-16 19:30:48 +010080# 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".
83group("default") {
84 testonly = true # allow to build also test targets
85 deps = [
86 ":all",
87 ]
88}
89
90if (build_standalone) {
91 group("ui") {
92 deps = [
93 "ui",
94 ]
95 }
Primiano Tucci5968caf2018-08-06 10:31:46 +010096
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 Tucci3faad742018-05-16 19:30:48 +0100104}
105
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000106executable("perfetto_unittests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +0900107 testonly = true
108 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +0000109 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +0000110 "gn:gtest_main",
Hector Dearman6cfec8a2018-03-14 16:54:09 +0000111 "src/base:unittests",
Bruce Dawsonc3e67632018-05-14 14:07:51 +0100112 "src/protozero:unittests",
Oystein Eftevaage5e84fb2018-06-01 17:34:56 -0700113 "src/tracing:unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +0900114 ]
Primiano Tucci1640ffa2018-05-14 18:25:33 +0100115
Primiano Tucci931284e2017-12-11 09:23:53 +0000116 if (!build_with_chromium) {
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -0700117 deps += [
118 "src/ipc:unittests",
119 "src/perfetto_cmd:unittests",
Primiano Tucci808d6df2018-03-31 13:24:18 +0100120 "src/traced/probes:unittests",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -0700121 "src/traced/probes/filesystem:unittests",
Primiano Tuccide82dae2018-06-04 16:17:49 +0200122 "src/traced/probes/ftrace:unittests",
Primiano Tucci808d6df2018-03-31 13:24:18 +0100123 "tools/ftrace_proto_gen:unittests",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -0700124 "tools/sanitizers_unittests",
125 ]
Primiano Tucci931284e2017-12-11 09:23:53 +0000126 }
Florian Mayerb64d6b12018-08-30 10:46:30 -0700127 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 Dearmanb6b029e2018-08-28 10:14:20 +0100132 if (build_standalone && !is_android) {
Lalit Maganticaed37e2018-06-01 03:03:08 +0100133 deps += [ "src/trace_processor:unittests" ]
134 }
Primiano Tuccib03ba362017-12-06 09:47:41 +0000135}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800136
Primiano Tucci808d6df2018-03-31 13:24:18 +0100137if (!build_with_chromium) {
Primiano Tuccib03ba362017-12-06 09:47:41 +0000138 executable("perfetto_benchmarks") {
139 testonly = true
140 deps = [
141 "gn:default_deps",
Primiano Tuccide82dae2018-06-04 16:17:49 +0200142 "src/traced/probes/ftrace:benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +0000143 "src/tracing:tracing_benchmarks",
Hector Dearmanbc8368e2018-01-25 17:34:11 +0000144 "test:benchmark_main",
Lalit Magantibfc3d3e2018-03-22 20:28:38 +0000145 "test:end_to_end_benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +0000146 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800147 }
Primiano Tucci4e49c022017-12-21 18:22:44 +0100148
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000149 executable("perfetto_integrationtests") {
150 testonly = true
151 deps = [
152 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +0000153 "gn:gtest_main",
Primiano Tuccide82dae2018-06-04 16:17:49 +0200154 "src/traced/probes/ftrace:integrationtests",
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000155 "test:end_to_end_integrationtests",
156 ]
Hector Dearman7f71d0e2018-08-09 11:26:10 +0100157 if (build_standalone && !is_android) {
158 deps += [ "src/trace_processor:integrationtests" ]
159 }
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000160 if (build_with_android) {
161 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
162 }
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000163 }
164
Primiano Tuccif3837d52018-01-10 21:12:41 +0000165 if (monolithic_binaries) {
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100166 libperfetto_target_type = "source_set"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000167 } else {
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100168 libperfetto_target_type = "shared_library"
Primiano Tuccif3837d52018-01-10 21:12:41 +0000169 }
170
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100171 target(libperfetto_target_type, "libperfetto") {
Primiano Tucci4e49c022017-12-21 18:22:44 +0100172 deps = [
173 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000174 "src/traced/probes",
175 "src/traced/service",
176 ]
177 }
178
Primiano Tucci3b729102018-01-08 18:16:36 +0000179 # 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 Tucci6067e732018-01-08 16:19:40 +0000182 executable("traced") {
183 deps = [
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100184 ":libperfetto",
Primiano Tucci6067e732018-01-08 16:19:40 +0000185 "gn:default_deps",
Primiano Tuccic2eb5102018-05-15 10:40:01 +0100186 "include/perfetto/traced",
Primiano Tucci6067e732018-01-08 16:19:40 +0000187 ]
188 sources = [
189 "src/traced/service/main.cc",
190 ]
191 }
192
Primiano Tucci3b729102018-01-08 18:16:36 +0000193 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
194 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000195 executable("traced_probes") {
196 deps = [
Primiano Tuccibdb2a592018-10-11 15:59:29 +0100197 ":libperfetto",
Primiano Tucci6067e732018-01-08 16:19:40 +0000198 "gn:default_deps",
Primiano Tuccic2eb5102018-05-15 10:40:01 +0100199 "include/perfetto/traced",
Primiano Tucci6067e732018-01-08 16:19:40 +0000200 ]
201 sources = [
202 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100203 ]
204 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000205
206 # The command line client for Perfetto. Allows to configure / start / stop
207 # tracing, acting as a Consumer.
208 executable("perfetto") {
209 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000210 "gn:default_deps",
Hector Dearmanc443a362018-02-28 16:03:56 +0000211 "src/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000212 ]
213 sources = [
Hector Dearmanc443a362018-02-28 16:03:56 +0000214 "src/perfetto_cmd/main.cc",
Primiano Tucci3b729102018-01-08 18:16:36 +0000215 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000216 if (is_android) {
217 deps += [ "src/base:android_task_runner" ]
218 }
Primiano Tucci6d848532018-01-17 10:32:33 +0000219 if (build_with_android) {
220 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000221 libs = [
222 "binder",
223 "services",
224 "utils",
225 ]
226 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000227 }
Primiano Tucci6aa75572018-03-21 05:33:14 -0700228
Primiano Tucci21c19d82018-03-29 12:35:08 +0100229 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 Tucci21c19d82018-03-29 12:35:08 +0100237
Primiano Tucci808d6df2018-03-31 13:24:18 +0100238 # 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 Tucci6aa75572018-03-21 05:33:14 -0700246 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700247}
248
249if (build_with_chromium) {
250 component("libperfetto") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000251 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800252 deps = [
253 "src/tracing",
254 ]
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700255 configs -= [ "//build/config/compiler:chromium_code" ]
256 configs += [ "//build/config/compiler:no_chromium_code" ]
257 public_deps = [
258 "include/perfetto/tracing/core",
Oystein Eftevaag6fcedac2018-07-02 12:02:55 -0700259 "protos/perfetto/trace:zero",
260 "protos/perfetto/trace/chrome:zero",
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700261 ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800262 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700263}
Primiano Tuccia1959712018-05-17 11:01:56 +0100264
Primiano Tucci59d6ace2018-09-26 22:24:20 +0100265if (!build_with_chromium) {
266 group("fuzzers") {
267 testonly = true
268 deps = [
269 "src/ipc:buffered_frame_deserializer_fuzzer",
270 "src/traced/probes/ftrace:cpu_reader_fuzzer",
271 "test:end_to_end_shared_memory_fuzzer",
272 ]
273 }
Primiano Tuccia1959712018-05-17 11:01:56 +0100274}