blob: 73b166b43372e9c14982fcf65e024fe41fdad1ae [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",
Hector Dearman20b3c1c2018-01-15 15:34:03 +000032 "tools/trace_to_text",
Primiano Tucciae2879e2017-09-27 11:02:09 +090033 ]
Primiano Tuccia0d80512018-02-18 00:09:23 +000034 if (is_linux || is_android) {
35 deps += [ "tools/ftrace_proto_gen:ftrace_proto_gen" ]
36 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000037 if (!build_with_chromium) {
38 deps += [
Primiano Tuccic5010802018-01-19 17:13:21 +000039 "protos/perfetto/config:merged_config", # For syntax-checking the proto.
Hector Dearmanfcbafda2018-01-18 11:13:57 +000040 "test/configs",
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080041 "tools:protoc_helper",
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",
50 ]
51 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000052 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090053}
54
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000055executable("perfetto_unittests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090056 testonly = true
57 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000058 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000059 "gn:gtest_main",
Primiano Tuccib03ba362017-12-06 09:47:41 +000060 "src/base:base_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000061 "src/ipc:perfetto_ipc_unittests",
62 "src/protozero:protozero_unittests",
Florian Mayer74b73a92018-03-09 17:37:13 +000063 "src/traced/probes/filesystem:filesystem_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000064 "src/tracing:tracing_unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090065 ]
Primiano Tuccia0d80512018-02-18 00:09:23 +000066 if (is_linux || is_android) {
67 deps += [
68 "src/ftrace_reader:ftrace_reader_unittests",
69 "tools/ftrace_proto_gen:ftrace_proto_gen_unittests",
70 ]
71 }
Primiano Tucci931284e2017-12-11 09:23:53 +000072 if (!build_with_chromium) {
73 deps += [ "tools/sanitizers_unittests" ]
74 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000075}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080076
Primiano Tuccic96f71b2018-02-06 19:21:09 +000077if (!build_with_chromium && (is_linux || is_android)) {
Primiano Tuccib03ba362017-12-06 09:47:41 +000078 executable("perfetto_benchmarks") {
79 testonly = true
80 deps = [
81 "gn:default_deps",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000082 "src/ftrace_reader:ftrace_reader_benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +000083 "src/tracing:tracing_benchmarks",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000084 "test:benchmark_main",
Primiano Tuccib03ba362017-12-06 09:47:41 +000085 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080086 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010087
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000088 executable("perfetto_integrationtests") {
89 testonly = true
90 deps = [
91 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000092 "gn:gtest_main",
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000093 "src/ftrace_reader:ftrace_reader_integrationtests",
94 "test:end_to_end_integrationtests",
95 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +000096 if (build_with_android) {
97 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
98 }
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000099 }
100
Primiano Tuccif3837d52018-01-10 21:12:41 +0000101 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 Tucci4e49c022017-12-21 18:22:44 +0100108 deps = [
109 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000110 "src/traced/probes",
111 "src/traced/service",
112 ]
113 }
114
Primiano Tucci3b729102018-01-08 18:16:36 +0000115 # 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 Tucci6067e732018-01-08 16:19:40 +0000118 executable("traced") {
119 deps = [
120 ":libtraced_shared",
121 "gn:default_deps",
122 ]
123 sources = [
124 "src/traced/service/main.cc",
125 ]
126 }
127
Primiano Tucci3b729102018-01-08 18:16:36 +0000128 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
129 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000130 executable("traced_probes") {
131 deps = [
132 ":libtraced_shared",
133 "gn:default_deps",
134 ]
135 sources = [
136 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100137 ]
138 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000139
140 # The command line client for Perfetto. Allows to configure / start / stop
141 # tracing, acting as a Consumer.
142 executable("perfetto") {
143 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000144 "gn:default_deps",
Hector Dearmanc443a362018-02-28 16:03:56 +0000145 "src/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000146 ]
147 sources = [
Hector Dearmanc443a362018-02-28 16:03:56 +0000148 "src/perfetto_cmd/main.cc",
Primiano Tucci3b729102018-01-08 18:16:36 +0000149 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000150 if (is_android) {
151 deps += [ "src/base:android_task_runner" ]
152 }
Primiano Tucci6d848532018-01-17 10:32:33 +0000153 if (build_with_android) {
154 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000155 libs = [
156 "binder",
157 "services",
158 "utils",
159 ]
160 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000161 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800162} else {
163 group("lib") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000164 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800165 deps = [
166 "src/tracing",
167 ]
168 }
169} # !build_with_chromium