blob: 782f9a59a3e1b4821904ffe28589efa2e1103862 [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 = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000028 ":perfetto_tests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000029 "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)",
30 "src/protozero/protoc_plugin($host_toolchain)",
Hector Dearmanfcbafda2018-01-18 11:13:57 +000031 "tools:protoc_helper",
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080032 "tools/ftrace_proto_gen:ftrace_proto_gen",
Primiano Tucci5fec9212017-12-11 23:08:40 +000033 "tools/proto_to_cpp",
Hector Dearman20b3c1c2018-01-15 15:34:03 +000034 "tools/trace_to_text",
Primiano Tucciae2879e2017-09-27 11:02:09 +090035 ]
Primiano Tuccib03ba362017-12-06 09:47:41 +000036 if (!build_with_chromium) {
37 deps += [
Oystein Eftevaag72dac262018-01-09 11:48:50 -080038 ":perfetto",
Primiano Tuccib03ba362017-12-06 09:47:41 +000039 ":perfetto_benchmarks",
Oystein Eftevaag72dac262018-01-09 11:48:50 -080040 ":traced",
41 ":traced_probes",
Primiano Tuccib03ba362017-12-06 09:47:41 +000042 "src/ftrace_reader:ftrace_reader_integrationtests",
Hector Dearmanfcbafda2018-01-18 11:13:57 +000043 "test/configs",
Primiano Tuccib03ba362017-12-06 09:47:41 +000044 ]
45 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090046}
47
Primiano Tuccib03ba362017-12-06 09:47:41 +000048executable("perfetto_tests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090049 testonly = true
50 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000051 "gn:default_deps",
52 "src/base:base_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000053 "src/ftrace_reader:ftrace_reader_unittests",
54 "src/ipc:perfetto_ipc_unittests",
55 "src/protozero:protozero_unittests",
56 "src/tracing:tracing_unittests",
Hector Dearman39071ba2018-01-16 13:58:50 +000057 "tools/ftrace_proto_gen:ftrace_proto_gen_unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090058 ]
Primiano Tucci931284e2017-12-11 09:23:53 +000059 if (!build_with_chromium) {
60 deps += [ "tools/sanitizers_unittests" ]
61 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000062}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080063
Primiano Tuccib03ba362017-12-06 09:47:41 +000064if (!build_with_chromium) {
65 executable("perfetto_benchmarks") {
66 testonly = true
67 deps = [
68 "gn:default_deps",
69 "src/tracing:tracing_benchmarks",
70 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080071 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010072
Primiano Tucci6b901562018-01-16 23:39:26 +000073 if (build_with_android) {
74 # Used by Android's statsd in /frameworks/base/cmds.
75 static_library("perfetto_protos_lite") {
76 deps = [
77 "gn:default_deps",
78 "protos:lite",
79 ]
80 }
Primiano Tucci7e2b67a2018-01-16 16:38:49 +000081 }
82
Primiano Tuccif3837d52018-01-10 21:12:41 +000083 if (monolithic_binaries) {
84 libtraced_shared_target_type = "source_set"
85 } else {
86 libtraced_shared_target_type = "shared_library"
87 }
88
89 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +010090 deps = [
91 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +000092 "src/traced/probes",
93 "src/traced/service",
94 ]
95 }
96
Primiano Tucci3b729102018-01-08 18:16:36 +000097 # The unprivileged trace daemon that listens for Producer and Consumer
98 # connections, handles the coordination of the tracing sessions and owns the
99 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +0000100 executable("traced") {
101 deps = [
102 ":libtraced_shared",
103 "gn:default_deps",
104 ]
105 sources = [
106 "src/traced/service/main.cc",
107 ]
108 }
109
Primiano Tucci3b729102018-01-08 18:16:36 +0000110 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
111 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000112 executable("traced_probes") {
113 deps = [
114 ":libtraced_shared",
115 "gn:default_deps",
116 ]
117 sources = [
118 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100119 ]
120 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000121
122 # The command line client for Perfetto. Allows to configure / start / stop
123 # tracing, acting as a Consumer.
124 executable("perfetto") {
125 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000126 "gn:default_deps",
Primiano Tucci6d848532018-01-17 10:32:33 +0000127 "src/traced/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000128 ]
129 sources = [
130 "src/traced/perfetto_cmd/main.cc",
131 ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000132 if (build_with_android) {
133 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
134 deps += [ "src/base:android_task_runner" ]
135 libs = [
136 "binder",
137 "services",
138 "utils",
139 ]
140 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000141 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800142} else {
143 group("lib") {
144 public_configs = [ "gn:public_config" ]
145 deps = [
146 "src/tracing",
147 ]
148 }
149} # !build_with_chromium