blob: e62e1ed86ab6fa2e182bae4d7e68b2c036713799 [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)",
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080031 "tools/ftrace_proto_gen:ftrace_proto_gen",
Primiano Tucci5fec9212017-12-11 23:08:40 +000032 "tools/proto_to_cpp",
Hector Dearman20b3c1c2018-01-15 15:34:03 +000033 "tools/trace_to_text",
Primiano Tucciae2879e2017-09-27 11:02:09 +090034 ]
Primiano Tuccib03ba362017-12-06 09:47:41 +000035 if (!build_with_chromium) {
36 deps += [
Oystein Eftevaag72dac262018-01-09 11:48:50 -080037 ":perfetto",
Primiano Tuccib03ba362017-12-06 09:47:41 +000038 ":perfetto_benchmarks",
Oystein Eftevaag72dac262018-01-09 11:48:50 -080039 ":traced",
40 ":traced_probes",
Primiano Tuccib03ba362017-12-06 09:47:41 +000041 "src/ftrace_reader:ftrace_reader_integrationtests",
42 ]
43 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090044}
45
Primiano Tuccib03ba362017-12-06 09:47:41 +000046executable("perfetto_tests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090047 testonly = true
48 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000049 "gn:default_deps",
50 "src/base:base_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000051 "src/ftrace_reader:ftrace_reader_unittests",
52 "src/ipc:perfetto_ipc_unittests",
53 "src/protozero:protozero_unittests",
54 "src/tracing:tracing_unittests",
Hector Dearman39071ba2018-01-16 13:58:50 +000055 "tools/ftrace_proto_gen:ftrace_proto_gen_unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090056 ]
Primiano Tucci931284e2017-12-11 09:23:53 +000057 if (!build_with_chromium) {
58 deps += [ "tools/sanitizers_unittests" ]
59 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000060}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080061
Primiano Tuccib03ba362017-12-06 09:47:41 +000062if (!build_with_chromium) {
63 executable("perfetto_benchmarks") {
64 testonly = true
65 deps = [
66 "gn:default_deps",
67 "src/tracing:tracing_benchmarks",
68 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080069 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010070
Primiano Tucci6b901562018-01-16 23:39:26 +000071 if (build_with_android) {
72 # Used by Android's statsd in /frameworks/base/cmds.
73 static_library("perfetto_protos_lite") {
74 deps = [
75 "gn:default_deps",
76 "protos:lite",
77 ]
78 }
Primiano Tucci7e2b67a2018-01-16 16:38:49 +000079 }
80
Primiano Tuccif3837d52018-01-10 21:12:41 +000081 if (monolithic_binaries) {
82 libtraced_shared_target_type = "source_set"
83 } else {
84 libtraced_shared_target_type = "shared_library"
85 }
86
87 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +010088 deps = [
89 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +000090 "src/traced/probes",
91 "src/traced/service",
92 ]
93 }
94
Primiano Tucci3b729102018-01-08 18:16:36 +000095 # The unprivileged trace daemon that listens for Producer and Consumer
96 # connections, handles the coordination of the tracing sessions and owns the
97 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +000098 executable("traced") {
99 deps = [
100 ":libtraced_shared",
101 "gn:default_deps",
102 ]
103 sources = [
104 "src/traced/service/main.cc",
105 ]
106 }
107
Primiano Tucci3b729102018-01-08 18:16:36 +0000108 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
109 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000110 executable("traced_probes") {
111 deps = [
112 ":libtraced_shared",
113 "gn:default_deps",
114 ]
115 sources = [
116 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100117 ]
118 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000119
120 # The command line client for Perfetto. Allows to configure / start / stop
121 # tracing, acting as a Consumer.
122 executable("perfetto") {
123 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000124 "gn:default_deps",
Primiano Tucci6d848532018-01-17 10:32:33 +0000125 "src/traced/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000126 ]
127 sources = [
128 "src/traced/perfetto_cmd/main.cc",
129 ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000130 if (build_with_android) {
131 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
132 deps += [ "src/base:android_task_runner" ]
133 libs = [
134 "binder",
135 "services",
136 "utils",
137 ]
138 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000139 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800140} else {
141 group("lib") {
142 public_configs = [ "gn:public_config" ]
143 deps = [
144 "src/tracing",
145 ]
146 }
147} # !build_with_chromium