blob: bb5863a983869d1c27f5f47f0b6d5f91ed7a498e [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)",
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",
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000039 ":perfetto_integrationtests",
Oystein Eftevaag72dac262018-01-09 11:48:50 -080040 ":traced",
41 ":traced_probes",
Primiano Tuccic5010802018-01-19 17:13:21 +000042 "protos/perfetto/config:merged_config", # For syntax-checking the proto.
Hector Dearmanfcbafda2018-01-18 11:13:57 +000043 "test/configs",
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080044 "tools:protoc_helper",
Primiano Tuccib03ba362017-12-06 09:47:41 +000045 ]
46 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090047}
48
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000049executable("perfetto_unittests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090050 testonly = true
51 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000052 "gn:default_deps",
53 "src/base:base_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000054 "src/ftrace_reader:ftrace_reader_unittests",
55 "src/ipc:perfetto_ipc_unittests",
56 "src/protozero:protozero_unittests",
57 "src/tracing:tracing_unittests",
Hector Dearman39071ba2018-01-16 13:58:50 +000058 "tools/ftrace_proto_gen:ftrace_proto_gen_unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090059 ]
Primiano Tucci931284e2017-12-11 09:23:53 +000060 if (!build_with_chromium) {
61 deps += [ "tools/sanitizers_unittests" ]
62 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000063}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080064
Primiano Tuccib03ba362017-12-06 09:47:41 +000065if (!build_with_chromium) {
66 executable("perfetto_benchmarks") {
67 testonly = true
68 deps = [
69 "gn:default_deps",
70 "src/tracing:tracing_benchmarks",
71 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080072 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010073
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000074 executable("perfetto_integrationtests") {
75 testonly = true
76 deps = [
77 "gn:default_deps",
78 "src/ftrace_reader:ftrace_reader_integrationtests",
79 "test:end_to_end_integrationtests",
80 ]
81 if (build_with_android) {
82 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
83 }
84 }
85
Primiano Tuccif3837d52018-01-10 21:12:41 +000086 if (monolithic_binaries) {
87 libtraced_shared_target_type = "source_set"
88 } else {
89 libtraced_shared_target_type = "shared_library"
90 }
91
92 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +010093 deps = [
94 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +000095 "src/traced/probes",
96 "src/traced/service",
97 ]
98 }
99
Primiano Tucci3b729102018-01-08 18:16:36 +0000100 # The unprivileged trace daemon that listens for Producer and Consumer
101 # connections, handles the coordination of the tracing sessions and owns the
102 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +0000103 executable("traced") {
104 deps = [
105 ":libtraced_shared",
106 "gn:default_deps",
107 ]
108 sources = [
109 "src/traced/service/main.cc",
110 ]
111 }
112
Primiano Tucci3b729102018-01-08 18:16:36 +0000113 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
114 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000115 executable("traced_probes") {
116 deps = [
117 ":libtraced_shared",
118 "gn:default_deps",
119 ]
120 sources = [
121 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100122 ]
123 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000124
125 # The command line client for Perfetto. Allows to configure / start / stop
126 # tracing, acting as a Consumer.
127 executable("perfetto") {
128 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000129 "gn:default_deps",
Primiano Tucci6d848532018-01-17 10:32:33 +0000130 "src/traced/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000131 ]
132 sources = [
133 "src/traced/perfetto_cmd/main.cc",
134 ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000135 if (build_with_android) {
136 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
137 deps += [ "src/base:android_task_runner" ]
138 libs = [
139 "binder",
140 "services",
141 "utils",
142 ]
143 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000144 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800145} else {
146 group("lib") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000147 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800148 deps = [
149 "src/tracing",
150 ]
151 }
152} # !build_with_chromium