blob: ea0231511d228ee6de63f8cd87d9b5235bee5c3b [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/ipc/protoc_plugin:ipc_plugin($host_toolchain)",
30 "src/protozero/protoc_plugin($host_toolchain)",
Primiano Tucci5fec9212017-12-11 23:08:40 +000031 "tools/proto_to_cpp",
Primiano Tucciae2879e2017-09-27 11:02:09 +090032 ]
Primiano Tuccia0d80512018-02-18 00:09:23 +000033 if (is_linux || is_android) {
34 deps += [ "tools/ftrace_proto_gen:ftrace_proto_gen" ]
35 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000036 if (!build_with_chromium) {
37 deps += [
Primiano Tuccic5010802018-01-19 17:13:21 +000038 "protos/perfetto/config:merged_config", # For syntax-checking the proto.
Hector Dearmanfcbafda2018-01-18 11:13:57 +000039 "test/configs",
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080040 "tools:protoc_helper",
Oystein Eftevaag9eba16c2018-03-16 11:28:45 -070041 "tools/trace_to_text",
Primiano Tuccib03ba362017-12-06 09:47:41 +000042 ]
Primiano Tuccic96f71b2018-02-06 19:21:09 +000043 if (is_linux || is_android) {
44 deps += [
45 ":perfetto",
46 ":perfetto_benchmarks",
47 ":perfetto_integrationtests",
48 ":traced",
49 ":traced_probes",
Hector Dearman36397002018-03-20 18:42:08 +000050 "tools/skippy",
Primiano Tuccic96f71b2018-02-06 19:21:09 +000051 ]
52 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000053 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090054}
55
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000056executable("perfetto_unittests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090057 testonly = true
58 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000059 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000060 "gn:gtest_main",
Hector Dearman6cfec8a2018-03-14 16:54:09 +000061 "src/base:unittests",
62 "src/ipc:unittests",
63 "src/protozero:unittests",
64 "src/traced/probes/filesystem:unittests",
65 "src/tracing:unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090066 ]
Primiano Tuccia0d80512018-02-18 00:09:23 +000067 if (is_linux || is_android) {
68 deps += [
Hector Dearman6cfec8a2018-03-14 16:54:09 +000069 "src/ftrace_reader:unittests",
70 "src/traced/probes:unittests",
71 "tools/ftrace_proto_gen:unittests",
Primiano Tuccia0d80512018-02-18 00:09:23 +000072 ]
73 }
Primiano Tucci931284e2017-12-11 09:23:53 +000074 if (!build_with_chromium) {
75 deps += [ "tools/sanitizers_unittests" ]
76 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000077}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080078
Primiano Tuccic96f71b2018-02-06 19:21:09 +000079if (!build_with_chromium && (is_linux || is_android)) {
Primiano Tuccib03ba362017-12-06 09:47:41 +000080 executable("perfetto_benchmarks") {
81 testonly = true
82 deps = [
83 "gn:default_deps",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000084 "src/ftrace_reader:ftrace_reader_benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +000085 "src/tracing:tracing_benchmarks",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000086 "test:benchmark_main",
Primiano Tuccib03ba362017-12-06 09:47:41 +000087 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080088 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010089
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000090 executable("perfetto_integrationtests") {
91 testonly = true
92 deps = [
93 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000094 "gn:gtest_main",
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000095 "src/ftrace_reader:ftrace_reader_integrationtests",
96 "test:end_to_end_integrationtests",
97 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +000098 if (build_with_android) {
99 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
100 }
Lalit Maganti79f2d7b2018-01-23 18:27:33 +0000101 }
102
Primiano Tuccif3837d52018-01-10 21:12:41 +0000103 if (monolithic_binaries) {
104 libtraced_shared_target_type = "source_set"
105 } else {
106 libtraced_shared_target_type = "shared_library"
107 }
108
109 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +0100110 deps = [
111 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000112 "src/traced/probes",
113 "src/traced/service",
114 ]
115 }
116
Primiano Tucci3b729102018-01-08 18:16:36 +0000117 # The unprivileged trace daemon that listens for Producer and Consumer
118 # connections, handles the coordination of the tracing sessions and owns the
119 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +0000120 executable("traced") {
121 deps = [
122 ":libtraced_shared",
123 "gn:default_deps",
124 ]
125 sources = [
126 "src/traced/service/main.cc",
127 ]
128 }
129
Primiano Tucci3b729102018-01-08 18:16:36 +0000130 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
131 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000132 executable("traced_probes") {
133 deps = [
134 ":libtraced_shared",
135 "gn:default_deps",
136 ]
137 sources = [
138 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100139 ]
140 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000141
142 # The command line client for Perfetto. Allows to configure / start / stop
143 # tracing, acting as a Consumer.
144 executable("perfetto") {
145 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000146 "gn:default_deps",
Hector Dearmanc443a362018-02-28 16:03:56 +0000147 "src/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000148 ]
149 sources = [
Hector Dearmanc443a362018-02-28 16:03:56 +0000150 "src/perfetto_cmd/main.cc",
Primiano Tucci3b729102018-01-08 18:16:36 +0000151 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000152 if (is_android) {
153 deps += [ "src/base:android_task_runner" ]
154 }
Primiano Tucci6d848532018-01-17 10:32:33 +0000155 if (build_with_android) {
156 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000157 libs = [
158 "binder",
159 "services",
160 "utils",
161 ]
162 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000163 }
Primiano Tucci6aa75572018-03-21 05:33:14 -0700164
165 # This target exports perfetto trace protos in the Android build system,
166 # allowing both host and device targets to implement custom parsers based on
167 # our protos.
168 static_library("perfetto_trace_protos") {
169 deps = [
170 "protos/perfetto/trace:lite",
171 ]
172 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800173} else {
174 group("lib") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000175 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800176 deps = [
177 "src/tracing",
178 ]
179 }
180} # !build_with_chromium