blob: a5d896e4224c99f07235d56bf47e478c01933195 [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 Tuccif3837d52018-01-10 21:12:41 +000017declare_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}
23assert(!monolithic_binaries || !build_with_android)
24
Primiano Tucciae2879e2017-09-27 11:02:09 +090025group("all") {
26 testonly = true # allow to build also test targets
27 deps = [
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000028 ":perfetto_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000029 "src/protozero/protoc_plugin($host_toolchain)",
Primiano Tucciae2879e2017-09-27 11:02:09 +090030 ]
Primiano Tuccib03ba362017-12-06 09:47:41 +000031 if (!build_with_chromium) {
32 deps += [
Primiano Tucci808d6df2018-03-31 13:24:18 +010033 ":perfetto",
34 ":perfetto_benchmarks",
35 ":perfetto_integrationtests",
36 ":traced",
37 ":traced_probes",
Primiano Tuccic5010802018-01-19 17:13:21 +000038 "protos/perfetto/config:merged_config", # For syntax-checking the proto.
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070039 "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)",
Hector Dearmanfcbafda2018-01-18 11:13:57 +000040 "test/configs",
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080041 "tools:protoc_helper",
Primiano Tucci808d6df2018-03-31 13:24:18 +010042 "tools/ftrace_proto_gen:ftrace_proto_gen",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070043 "tools/proto_to_cpp",
Primiano Tuccib03ba362017-12-06 09:47:41 +000044 ]
Primiano Tucci21c19d82018-03-29 12:35:08 +010045 if (!build_with_android) {
46 deps += [ "tools/trace_to_text" ]
47 }
Primiano Tuccic96f71b2018-02-06 19:21:09 +000048 if (is_linux || is_android) {
Primiano Tucci808d6df2018-03-31 13:24:18 +010049 deps += [ "tools/skippy" ]
Primiano Tuccic96f71b2018-02-06 19:21:09 +000050 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000051 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090052}
53
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000054executable("perfetto_unittests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090055 testonly = true
56 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000057 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000058 "gn:gtest_main",
Hector Dearman6cfec8a2018-03-14 16:54:09 +000059 "src/base:unittests",
Bruce Dawsonc3e67632018-05-14 14:07:51 +010060 "src/protozero:unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090061 ]
Bruce Dawson2af6ef72018-05-01 15:28:39 +010062 # TODO(brucedawson): Enable these for Windows when possible.
63 if (!is_win) {
64 deps += [
Bruce Dawson2af6ef72018-05-01 15:28:39 +010065 "src/tracing:unittests",
66 ]
67 }
Primiano Tucci931284e2017-12-11 09:23:53 +000068 if (!build_with_chromium) {
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070069 deps += [
Primiano Tucci808d6df2018-03-31 13:24:18 +010070 "src/ftrace_reader:unittests",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070071 "src/ipc:unittests",
72 "src/perfetto_cmd:unittests",
Primiano Tucci808d6df2018-03-31 13:24:18 +010073 "src/traced/probes:unittests",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070074 "src/traced/probes/filesystem:unittests",
Primiano Tucci808d6df2018-03-31 13:24:18 +010075 "tools/ftrace_proto_gen:unittests",
Oystein Eftevaag067fd5b2018-03-27 12:39:30 -070076 "tools/sanitizers_unittests",
77 ]
Primiano Tucci931284e2017-12-11 09:23:53 +000078 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000079}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080080
Primiano Tucci808d6df2018-03-31 13:24:18 +010081if (!build_with_chromium) {
Primiano Tuccib03ba362017-12-06 09:47:41 +000082 executable("perfetto_benchmarks") {
83 testonly = true
84 deps = [
85 "gn:default_deps",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000086 "src/ftrace_reader:ftrace_reader_benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +000087 "src/tracing:tracing_benchmarks",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000088 "test:benchmark_main",
Lalit Magantibfc3d3e2018-03-22 20:28:38 +000089 "test:end_to_end_benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +000090 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080091 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010092
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000093 executable("perfetto_integrationtests") {
94 testonly = true
95 deps = [
96 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000097 "gn:gtest_main",
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000098 "src/ftrace_reader:ftrace_reader_integrationtests",
99 "test:end_to_end_integrationtests",
100 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000101 if (build_with_android) {
102 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
103 }
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000104 }
105
Primiano Tuccif3837d52018-01-10 21:12:41 +0000106 if (monolithic_binaries) {
107 libtraced_shared_target_type = "source_set"
108 } else {
109 libtraced_shared_target_type = "shared_library"
110 }
111
112 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +0100113 deps = [
114 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000115 "src/traced/probes",
116 "src/traced/service",
117 ]
118 }
119
Primiano Tucci3b729102018-01-08 18:16:36 +0000120 # The unprivileged trace daemon that listens for Producer and Consumer
121 # connections, handles the coordination of the tracing sessions and owns the
122 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +0000123 executable("traced") {
124 deps = [
125 ":libtraced_shared",
126 "gn:default_deps",
127 ]
128 sources = [
129 "src/traced/service/main.cc",
130 ]
131 }
132
Primiano Tucci3b729102018-01-08 18:16:36 +0000133 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
134 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000135 executable("traced_probes") {
136 deps = [
137 ":libtraced_shared",
138 "gn:default_deps",
139 ]
140 sources = [
141 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100142 ]
143 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000144
145 # The command line client for Perfetto. Allows to configure / start / stop
146 # tracing, acting as a Consumer.
147 executable("perfetto") {
148 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000149 "gn:default_deps",
Hector Dearmanc443a362018-02-28 16:03:56 +0000150 "src/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000151 ]
152 sources = [
Hector Dearmanc443a362018-02-28 16:03:56 +0000153 "src/perfetto_cmd/main.cc",
Primiano Tucci3b729102018-01-08 18:16:36 +0000154 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000155 if (is_android) {
156 deps += [ "src/base:android_task_runner" ]
157 }
Primiano Tucci6d848532018-01-17 10:32:33 +0000158 if (build_with_android) {
159 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000160 libs = [
161 "binder",
162 "services",
163 "utils",
164 ]
165 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000166 }
Primiano Tucci6aa75572018-03-21 05:33:14 -0700167
Primiano Tucci21c19d82018-03-29 12:35:08 +0100168 if (build_with_android) {
169 executable("trace_to_text") {
170 testonly = true
171 deps = [
172 "gn:default_deps",
173 "tools/trace_to_text:lib",
174 ]
175 }
Primiano Tucci21c19d82018-03-29 12:35:08 +0100176
Primiano Tucci808d6df2018-03-31 13:24:18 +0100177 # This target exports perfetto trace protos in the Android build system,
178 # allowing both host and device targets to implement custom parsers based on
179 # our protos.
180 static_library("perfetto_trace_protos") {
181 deps = [
182 "protos/perfetto/trace:lite",
183 ]
184 }
Primiano Tucci6aa75572018-03-21 05:33:14 -0700185 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700186}
187
188if (build_with_chromium) {
189 component("libperfetto") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000190 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800191 deps = [
192 "src/tracing",
193 ]
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700194 configs -= [ "//build/config/compiler:chromium_code" ]
195 configs += [ "//build/config/compiler:no_chromium_code" ]
196 public_deps = [
197 "include/perfetto/tracing/core",
198 ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800199 }
Oystein Eftevaaga812a942018-03-23 11:52:32 -0700200}