blob: 4995177e67892f17885b171f4533ddde050f49f1 [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)",
Isabelle Taylord15631b2018-02-12 10:32:41 +000031 "tools/dump_process_data",
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 += [
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",
Primiano Tuccib03ba362017-12-06 09:47:41 +000041 ]
Primiano Tuccic96f71b2018-02-06 19:21:09 +000042 if (is_linux || is_android) {
43 deps += [
44 ":perfetto",
45 ":perfetto_benchmarks",
46 ":perfetto_integrationtests",
47 ":traced",
48 ":traced_probes",
49 ]
50 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000051 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090052}
53
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000054executable("perfetto_unittests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090055 testonly = true
56 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000057 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000058 "gn:gtest_main",
Primiano Tuccib03ba362017-12-06 09:47:41 +000059 "src/base:base_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000060 "src/ftrace_reader:ftrace_reader_unittests",
61 "src/ipc:perfetto_ipc_unittests",
62 "src/protozero:protozero_unittests",
63 "src/tracing:tracing_unittests",
Hector Dearman39071ba2018-01-16 13:58:50 +000064 "tools/ftrace_proto_gen:ftrace_proto_gen_unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090065 ]
Primiano Tucci931284e2017-12-11 09:23:53 +000066 if (!build_with_chromium) {
67 deps += [ "tools/sanitizers_unittests" ]
68 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000069}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080070
Primiano Tuccic96f71b2018-02-06 19:21:09 +000071if (!build_with_chromium && (is_linux || is_android)) {
Primiano Tuccib03ba362017-12-06 09:47:41 +000072 executable("perfetto_benchmarks") {
73 testonly = true
74 deps = [
75 "gn:default_deps",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000076 "src/ftrace_reader:ftrace_reader_benchmarks",
Primiano Tuccib03ba362017-12-06 09:47:41 +000077 "src/tracing:tracing_benchmarks",
Hector Dearmanbc8368e2018-01-25 17:34:11 +000078 "test:benchmark_main",
Primiano Tuccib03ba362017-12-06 09:47:41 +000079 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080080 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010081
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000082 executable("perfetto_integrationtests") {
83 testonly = true
84 deps = [
85 "gn:default_deps",
Florian Mayerd8bd81b2018-01-25 12:49:15 +000086 "gn:gtest_main",
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000087 "src/ftrace_reader:ftrace_reader_integrationtests",
88 "test:end_to_end_integrationtests",
89 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +000090 if (build_with_android) {
91 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
92 }
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000093 }
94
Primiano Tuccif3837d52018-01-10 21:12:41 +000095 if (monolithic_binaries) {
96 libtraced_shared_target_type = "source_set"
97 } else {
98 libtraced_shared_target_type = "shared_library"
99 }
100
101 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +0100102 deps = [
103 "gn:default_deps",
Primiano Tucci6067e732018-01-08 16:19:40 +0000104 "src/traced/probes",
105 "src/traced/service",
106 ]
107 }
108
Primiano Tucci3b729102018-01-08 18:16:36 +0000109 # The unprivileged trace daemon that listens for Producer and Consumer
110 # connections, handles the coordination of the tracing sessions and owns the
111 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +0000112 executable("traced") {
113 deps = [
114 ":libtraced_shared",
115 "gn:default_deps",
116 ]
117 sources = [
118 "src/traced/service/main.cc",
119 ]
120 }
121
Primiano Tucci3b729102018-01-08 18:16:36 +0000122 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
123 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000124 executable("traced_probes") {
125 deps = [
126 ":libtraced_shared",
127 "gn:default_deps",
128 ]
129 sources = [
130 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100131 ]
132 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000133
134 # The command line client for Perfetto. Allows to configure / start / stop
135 # tracing, acting as a Consumer.
136 executable("perfetto") {
137 deps = [
Primiano Tucci3b729102018-01-08 18:16:36 +0000138 "gn:default_deps",
Primiano Tucci6d848532018-01-17 10:32:33 +0000139 "src/traced/perfetto_cmd",
Primiano Tucci3b729102018-01-08 18:16:36 +0000140 ]
141 sources = [
142 "src/traced/perfetto_cmd/main.cc",
143 ]
Lalit Maganti0b9a6ac2018-02-16 18:05:06 +0000144 if (is_android) {
145 deps += [ "src/base:android_task_runner" ]
146 }
Primiano Tucci6d848532018-01-17 10:32:33 +0000147 if (build_with_android) {
148 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
Primiano Tucci6d848532018-01-17 10:32:33 +0000149 libs = [
150 "binder",
151 "services",
152 "utils",
153 ]
154 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000155 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800156} else {
157 group("lib") {
Primiano Tucci20b760c2018-01-19 12:36:12 +0000158 public_configs = [ "gn:public_config" ]
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800159 deps = [
160 "src/tracing",
161 ]
162 }
163} # !build_with_chromium