blob: 31f6c705a06ae4568447230772b730bd03a77bf3 [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")
16
Primiano Tuccia1959712018-05-17 11:01:56 +010017# For use_libfuzzer.
18if (!build_with_chromium) {
19 import("//gn/standalone/sanitizers/vars.gni")
20} else {
21 import("//build/config/sanitizers/sanitizers.gni")
22}
23
Primiano Tuccif3837d52018-01-10 21:12:41 +000024declare_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}
30assert(!monolithic_binaries || !build_with_android)
31
Primiano Tucciae2879e2017-09-27 11:02:09 +090032group("all") {
33 testonly = true # allow to build also test targets
34 deps = [
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000035 ":perfetto_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000036 "src/protozero/protoc_plugin($host_toolchain)",
Primiano Tucciae2879e2017-09-27 11:02:09 +090037 ]
Primiano Tuccib03ba362017-12-06 09:47:41 +000038 if (!build_with_chromium) {
39 deps += [
Primiano Tucci808d6df2018-03-31 13:24:18 +010040 ":perfetto",
41 ":perfetto_benchmarks",
42 ":perfetto_integrationtests",
43 ":traced",
44 ":traced_probes",
Primiano Tuccic5010802018-01-19 17:13:21 +000045 "protos/perfetto/config:merged_config", # For syntax-checking the proto.
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070046 "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)",
Hector Dearmanfcbafda2018-01-18 11:13:57 +000047 "test/configs",
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080048 "tools:protoc_helper",
Primiano Tucci808d6df2018-03-31 13:24:18 +010049 "tools/ftrace_proto_gen:ftrace_proto_gen",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070050 "tools/proto_to_cpp",
Primiano Tuccib03ba362017-12-06 09:47:41 +000051 ]
Primiano Tucci21c19d82018-03-29 12:35:08 +010052 if (!build_with_android) {
Primiano Tucci5968caf2018-08-06 10:31:46 +010053 deps += [
54 ":trace_processor",
55 "tools/trace_to_text",
56 ]
Primiano Tucci21c19d82018-03-29 12:35:08 +010057 }
Primiano Tuccic96f71b2018-02-06 19:21:09 +000058 if (is_linux || is_android) {
Primiano Tucci808d6df2018-03-31 13:24:18 +010059 deps += [ "tools/skippy" ]
Primiano Tuccic96f71b2018-02-06 19:21:09 +000060 }
Primiano Tucci1640ffa2018-05-14 18:25:33 +010061 if (is_linux) {
62 deps += [ "tools:pipestats" ]
63 }
Primiano Tuccia1959712018-05-17 11:01:56 +010064 if (use_libfuzzer) {
65 deps += [ ":fuzzers" ]
66 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000067 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090068}
69
Primiano Tucci3faad742018-05-16 19:30:48 +010070# TODO(primiano): temporary workaround to:
71# 1) Prevent that the UI gets build automatically when doing ninja -C out/xx .
72# 2) Avoid breaking the chrome build, that right now depends on "all".
73group("default") {
74 testonly = true # allow to build also test targets
75 deps = [
76 ":all",
77 ]
78}
79
80if (build_standalone) {
81 group("ui") {
82 deps = [
83 "ui",
84 ]
85 }
Primiano Tucci5968caf2018-08-06 10:31:46 +010086
87 # The trace processor shell executable. An interactive shell that allows to
88 # make queries on the trace using the terminal.
89 group("trace_processor") {
90 deps = [
91 "src/trace_processor:trace_processor_shell",
92 ]
93 }
Primiano Tucci3faad742018-05-16 19:30:48 +010094}
95
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000096executable("perfetto_unittests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090097 testonly = true
98 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000099 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +0000100 "gn:gtest_main",
Hector Dearman6cfec8a2018-03-14 16:54:09 +0000101 "src/base:unittests",
Bruce Dawsonc3e67632018-05-14 14:07:51 +0100102 "src/protozero:unittests",
Oystein Eftevaage5e84fb2018-06-01 17:34:56 -0700103 "src/tracing:unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +0900104 ]
Primiano Tucci1640ffa2018-05-14 18:25:33 +0100105
Primiano Tucci931284e2017-12-11 09:23:53 +0000106 if (!build_with_chromium) {
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -0700107 deps += [
108 "src/ipc:unittests",
109 "src/perfetto_cmd:unittests",
Florian Mayer8aba4322018-08-06 09:45:38 +0100110 "src/profiling/memory:unittests",
Primiano Tucci808d6df2018-03-31 13:24:18 +0100111 "src/traced/probes:unittests",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -0700112 "src/traced/probes/filesystem:unittests",
Primiano Tuccide82dae2018-06-04 16:17:49 +0200113 "src/traced/probes/ftrace:unittests",
Primiano Tucci808d6df2018-03-31 13:24:18 +0100114 "tools/ftrace_proto_gen:unittests",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -0700115 "tools/sanitizers_unittests",
116 ]
Primiano Tucci931284e2017-12-11 09:23:53 +0000117 }
Lalit Maganticaed37e2018-06-01 03:03:08 +0100118 if (build_standalone) {
119 deps += [ "src/trace_processor:unittests" ]
120 }
Primiano Tuccib03ba362017-12-06 09:47:41 +0000121}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800122
Primiano Tucci808d6df2018-03-31 13:24:18 +0100123if (!build_with_chromium) {
Primiano Tuccib03ba362017-12-06 09:47:41 +0000124 executable("perfetto_benchmarks") {
125 testonly = true
126 deps = [
127 "gn:default_deps",
Primiano Tuccide82dae2018-06-04 16:17:49 +0200128 "src/traced/probes/ftrace:benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +0000129 "src/tracing:tracing_benchmarks",
Hector Dearmanbc8368e2018-01-25 17:34:11 +0000130 "test:benchmark_main",
Lalit Magantibfc3d3e2018-03-22 20:28:38 +0000131 "test:end_to_end_benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +0000132 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800133 }
Primiano Tucci4e49c022017-12-21 18:22:44 +0100134
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000135 executable("perfetto_integrationtests") {
136 testonly = true
137 deps = [
138 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +0000139 "gn:gtest_main",
Primiano Tuccide82dae2018-06-04 16:17:49 +0200140 "src/traced/probes/ftrace:integrationtests",
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000141 "test:end_to_end_integrationtests",
142 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000143 if (build_with_android) {
144 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
145 }
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000146 }
147
Primiano Tuccif3837d52018-01-10 21:12:41 +0000148 if (monolithic_binaries) {
149 libtraced_shared_target_type = "source_set"
150 } else {
151 libtraced_shared_target_type = "shared_library"
152 }
153
154 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +0100155 deps = [
156 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000157 "src/traced/probes",
158 "src/traced/service",
159 ]
160 }
161
Primiano Tucci3b729102018-01-08 18:16:36 +0000162 # The unprivileged trace daemon that listens for Producer and Consumer
163 # connections, handles the coordination of the tracing sessions and owns the
164 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +0000165 executable("traced") {
166 deps = [
167 ":libtraced_shared",
168 "gn:default_deps",
Primiano Tuccic2eb5102018-05-15 10:40:01 +0100169 "include/perfetto/traced",
Primiano Tucci6067e732018-01-08 16:19:40 +0000170 ]
171 sources = [
172 "src/traced/service/main.cc",
173 ]
174 }
175
Primiano Tucci3b729102018-01-08 18:16:36 +0000176 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
177 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000178 executable("traced_probes") {
179 deps = [
180 ":libtraced_shared",
181 "gn:default_deps",
Primiano Tuccic2eb5102018-05-15 10:40:01 +0100182 "include/perfetto/traced",
Primiano Tucci6067e732018-01-08 16:19:40 +0000183 ]
184 sources = [
185 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100186 ]
187 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000188
189 # The command line client for Perfetto. Allows to configure / start / stop
190 # tracing, acting as a Consumer.
191 executable("perfetto") {
192 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000193 "gn:default_deps",
Hector Dearmanc443a362018-02-28 16:03:56 +0000194 "src/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000195 ]
196 sources = [
Hector Dearmanc443a362018-02-28 16:03:56 +0000197 "src/perfetto_cmd/main.cc",
Primiano Tucci3b729102018-01-08 18:16:36 +0000198 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000199 if (is_android) {
200 deps += [ "src/base:android_task_runner" ]
201 }
Primiano Tucci6d848532018-01-17 10:32:33 +0000202 if (build_with_android) {
203 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000204 libs = [
205 "binder",
206 "services",
207 "utils",
208 ]
209 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000210 }
Primiano Tucci6aa75572018-03-21 05:33:14 -0700211
Primiano Tucci21c19d82018-03-29 12:35:08 +0100212 if (build_with_android) {
213 executable("trace_to_text") {
214 testonly = true
215 deps = [
216 "gn:default_deps",
217 "tools/trace_to_text:lib",
218 ]
219 }
Primiano Tucci21c19d82018-03-29 12:35:08 +0100220
Primiano Tucci808d6df2018-03-31 13:24:18 +0100221 # This target exports perfetto trace protos in the Android build system,
222 # allowing both host and device targets to implement custom parsers based on
223 # our protos.
224 static_library("perfetto_trace_protos") {
225 deps = [
226 "protos/perfetto/trace:lite",
227 ]
228 }
Primiano Tucci6aa75572018-03-21 05:33:14 -0700229 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700230}
231
232if (build_with_chromium) {
233 component("libperfetto") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000234 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800235 deps = [
236 "src/tracing",
237 ]
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700238 configs -= [ "//build/config/compiler:chromium_code" ]
239 configs += [ "//build/config/compiler:no_chromium_code" ]
240 public_deps = [
241 "include/perfetto/tracing/core",
Oystein Eftevaag6fcedac2018-07-02 12:02:55 -0700242 "protos/perfetto/trace:zero",
243 "protos/perfetto/trace/chrome:zero",
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700244 ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800245 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700246}
Primiano Tuccia1959712018-05-17 11:01:56 +0100247
Oystein Eftevaag608d8f82018-05-23 09:59:01 -0700248if (use_libfuzzer && !build_with_chromium) {
Primiano Tuccia1959712018-05-17 11:01:56 +0100249 group("fuzzers") {
250 testonly = true
251 deps = [
Primiano Tuccia1959712018-05-17 11:01:56 +0100252 "src/ipc:buffered_frame_deserializer_fuzzer",
Primiano Tuccide82dae2018-06-04 16:17:49 +0200253 "src/traced/probes/ftrace:cpu_reader_fuzzer",
Primiano Tuccia1959712018-05-17 11:01:56 +0100254 "test:end_to_end_shared_memory_fuzzer",
255 ]
256 }
257}