blob: 408a682dbac31aaf34d7a5d3a6d0d8a82e4ac230 [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",
Primiano Tucciae2879e2017-09-27 11:02:09 +090033 ]
Primiano Tuccib03ba362017-12-06 09:47:41 +000034 if (!build_with_chromium) {
35 deps += [
Oystein Eftevaag72dac262018-01-09 11:48:50 -080036 ":perfetto",
Primiano Tuccib03ba362017-12-06 09:47:41 +000037 ":perfetto_benchmarks",
Oystein Eftevaag72dac262018-01-09 11:48:50 -080038 ":traced",
39 ":traced_probes",
Primiano Tuccib03ba362017-12-06 09:47:41 +000040 "src/ftrace_reader:ftrace_reader_integrationtests",
41 ]
42 }
Primiano Tucciae2879e2017-09-27 11:02:09 +090043}
44
Primiano Tuccib03ba362017-12-06 09:47:41 +000045executable("perfetto_tests") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090046 testonly = true
47 deps = [
Primiano Tuccib03ba362017-12-06 09:47:41 +000048 "gn:default_deps",
49 "src/base:base_unittests",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000050 "src/ftrace_reader:ftrace_reader_unittests",
51 "src/ipc:perfetto_ipc_unittests",
52 "src/protozero:protozero_unittests",
53 "src/tracing:tracing_unittests",
Primiano Tucciae2879e2017-09-27 11:02:09 +090054 ]
Primiano Tucci931284e2017-12-11 09:23:53 +000055 if (!build_with_chromium) {
56 deps += [ "tools/sanitizers_unittests" ]
57 }
Primiano Tuccib03ba362017-12-06 09:47:41 +000058}
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080059
Primiano Tuccib03ba362017-12-06 09:47:41 +000060if (!build_with_chromium) {
61 executable("perfetto_benchmarks") {
62 testonly = true
63 deps = [
64 "gn:default_deps",
65 "src/tracing:tracing_benchmarks",
66 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080067 }
Primiano Tucci4e49c022017-12-21 18:22:44 +010068
Primiano Tuccif3837d52018-01-10 21:12:41 +000069 if (monolithic_binaries) {
70 libtraced_shared_target_type = "source_set"
71 } else {
72 libtraced_shared_target_type = "shared_library"
73 }
74
75 target(libtraced_shared_target_type, "libtraced_shared") {
Primiano Tucci4e49c022017-12-21 18:22:44 +010076 deps = [
77 "gn:default_deps",
Primiano Tucci3b729102018-01-08 18:16:36 +000078 "src/traced/perfetto_cmd",
Primiano Tucci6067e732018-01-08 16:19:40 +000079 "src/traced/probes",
80 "src/traced/service",
81 ]
Primiano Tucciedf099c2018-01-08 18:27:56 +000082 if (build_with_android) {
83 cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
Primiano Tucci6ea459c2018-01-10 10:42:27 +000084 deps += [ "src/base:android_task_runner" ]
Sami Kyostilab5b71692018-01-12 12:16:44 +000085 libs = [
86 "binder",
87 "services",
88 "utils",
89 ]
Primiano Tucciedf099c2018-01-08 18:27:56 +000090 }
Primiano Tucci6067e732018-01-08 16:19:40 +000091 }
92
Primiano Tucci3b729102018-01-08 18:16:36 +000093 # The unprivileged trace daemon that listens for Producer and Consumer
94 # connections, handles the coordination of the tracing sessions and owns the
95 # log buffers.
Primiano Tucci6067e732018-01-08 16:19:40 +000096 executable("traced") {
97 deps = [
98 ":libtraced_shared",
99 "gn:default_deps",
100 ]
101 sources = [
102 "src/traced/service/main.cc",
103 ]
104 }
105
Primiano Tucci3b729102018-01-08 18:16:36 +0000106 # The unprivileged daemon that is allowed to access tracefs (for ftrace).
107 # Registers as a Producer on the traced daemon.
Primiano Tucci6067e732018-01-08 16:19:40 +0000108 executable("traced_probes") {
109 deps = [
110 ":libtraced_shared",
111 "gn:default_deps",
112 ]
113 sources = [
114 "src/traced/probes/main.cc",
Primiano Tucci4e49c022017-12-21 18:22:44 +0100115 ]
116 }
Primiano Tucci3b729102018-01-08 18:16:36 +0000117
118 # The command line client for Perfetto. Allows to configure / start / stop
119 # tracing, acting as a Consumer.
120 executable("perfetto") {
121 deps = [
122 ":libtraced_shared",
123 "gn:default_deps",
124 ]
125 sources = [
126 "src/traced/perfetto_cmd/main.cc",
127 ]
128 }
Oystein Eftevaag5e8a4eb2018-01-09 11:41:58 -0800129} else {
130 group("lib") {
131 public_configs = [ "gn:public_config" ]
132 deps = [
133 "src/tracing",
134 ]
135 }
136} # !build_with_chromium