blob: 4b0650170506381f1ea878dd90193bf210898516 [file] [log] [blame]
Primiano Tucci3b729102018-01-08 18:16:36 +00001# Copyright (C) 2018 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
Hector Dearman86cfbe12018-03-22 11:58:42 +000015import("../../gn/perfetto.gni")
16import("../../gn/proto_library.gni")
Primiano Tucci02c11762019-08-30 00:57:59 +020017import("../../gn/test.gni")
Hector Dearman86cfbe12018-03-22 11:58:42 +000018
Primiano Tucci02c11762019-08-30 00:57:59 +020019# The command line client for Perfetto. Allows to configure / start / stop
20# tracing, acting as a Consumer.
21executable("perfetto") {
22 deps = [
23 ":perfetto_cmd",
24 "../../gn:default_deps",
25 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +000026 sources = [ "main.cc" ]
Primiano Tucci02c11762019-08-30 00:57:59 +020027}
28
29# Tool to finalize long running traces.
30# This connects to traced as a producer and sends the triggers passed on the
31# commandline. This is a subset of what the perfetto binary can do but we
32# need a separate binary for programs that cannot (for good reason) use the
33# additional functionality (for example starting traces via consumer socket)
34# due to selinux rules.
35executable("trigger_perfetto") {
36 deps = [
37 ":trigger_perfetto_cmd",
38 "../../gn:default_deps",
39 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +000040 sources = [ "trigger_perfetto_main.cc" ]
Primiano Tucci02c11762019-08-30 00:57:59 +020041}
42
Hector Dearman92d7d112019-12-05 15:19:57 +000043source_set("perfetto_atoms") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +000044 sources = [ "perfetto_atoms.h" ]
Hector Dearman92d7d112019-12-05 15:19:57 +000045}
46
Primiano Tucci02c11762019-08-30 00:57:59 +020047# Contains all the implementation but not the main() entry point. This target
48# is shared both by the executable and tests.
Primiano Tucci3b729102018-01-08 18:16:36 +000049source_set("perfetto_cmd") {
50 public_deps = [
Hector Dearman86cfbe12018-03-22 11:58:42 +000051 ":protos",
Primiano Tucci2c5488f2019-06-01 03:27:28 +010052 "../../include/perfetto/ext/traced",
Primiano Tucci3b729102018-01-08 18:16:36 +000053 ]
54 deps = [
Hector Dearman92d7d112019-12-05 15:19:57 +000055 ":perfetto_atoms",
Hector Dearman696ff772019-04-23 18:38:53 +010056 ":trigger_producer",
Hector Dearmanc443a362018-02-28 16:03:56 +000057 "../../gn:default_deps",
Primiano Tucci54985c22019-12-03 12:14:08 +000058 "../../protos/perfetto/common:cpp",
59 "../../protos/perfetto/config:cpp",
60 "../../protos/perfetto/config/ftrace:cpp",
Primiano Tuccia6ebe132019-07-24 22:59:23 +010061 "../android_internal:lazy_library_loader",
Hector Dearmanc443a362018-02-28 16:03:56 +000062 "../base",
63 "../protozero",
Primiano Tuccic4c063b2020-01-27 09:34:46 +000064 "../tracing/ipc/consumer",
Primiano Tucci3b729102018-01-08 18:16:36 +000065 ]
Primiano Tucci1b5fdae2020-01-16 09:28:05 +000066 if (enable_perfetto_zlib) {
67 deps += [ "../../gn:zlib" ]
68 }
Primiano Tucci3b729102018-01-08 18:16:36 +000069 sources = [
Hector Dearman5edeafc2018-11-29 13:27:33 +000070 "config.cc",
71 "config.h",
Hector Dearman554627f2019-06-04 17:58:22 +010072 "packet_writer.cc",
73 "packet_writer.h",
Hector Dearmanb7fa5442018-11-08 18:39:32 +000074 "pbtxt_to_pb.cc",
75 "pbtxt_to_pb.h",
Primiano Tucci3b729102018-01-08 18:16:36 +000076 "perfetto_cmd.cc",
Hector Dearman86cfbe12018-03-22 11:58:42 +000077 "perfetto_cmd.h",
Hector Dearmanb7fa5442018-11-08 18:39:32 +000078 "perfetto_config.descriptor.h",
Hector Dearman86cfbe12018-03-22 11:58:42 +000079 "rate_limiter.cc",
80 "rate_limiter.h",
81 ]
Primiano Tucciec62e3e2019-07-26 22:18:31 +010082 if (is_android) {
83 sources += [ "perfetto_cmd_android.cc" ]
Primiano Tucci106605c2019-01-08 21:12:58 +000084 }
Hector Dearman86cfbe12018-03-22 11:58:42 +000085}
86
Hector Dearman696ff772019-04-23 18:38:53 +010087source_set("trigger_perfetto_cmd") {
88 public_deps = [
89 ":protos",
Primiano Tucci2c5488f2019-06-01 03:27:28 +010090 "../../include/perfetto/ext/traced",
Hector Dearman696ff772019-04-23 18:38:53 +010091 ]
92 deps = [
93 ":trigger_producer",
94 "../../gn:default_deps",
95 "../base",
Primiano Tuccic4c063b2020-01-27 09:34:46 +000096 "../tracing/ipc/producer",
Hector Dearman696ff772019-04-23 18:38:53 +010097 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +000098 sources = [ "trigger_perfetto.cc" ]
Hector Dearman696ff772019-04-23 18:38:53 +010099}
100
101source_set("trigger_producer") {
102 sources = [
103 "trigger_producer.cc",
104 "trigger_producer.h",
105 ]
106 deps = [
Hector Dearman696ff772019-04-23 18:38:53 +0100107 "../../gn:default_deps",
Hector Dearman696ff772019-04-23 18:38:53 +0100108 "../base",
Primiano Tuccic4c063b2020-01-27 09:34:46 +0000109 "../tracing/ipc/producer",
Hector Dearman696ff772019-04-23 18:38:53 +0100110 ]
111}
112
Primiano Tucci2cf8b532019-08-29 01:14:01 +0200113perfetto_proto_library("protos") {
Hector Dearman040f9582019-12-03 18:06:33 +0000114 proto_generators = [ "cpp" ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000115 sources = [ "perfetto_cmd_state.proto" ]
Primiano Tucci2cf8b532019-08-29 01:14:01 +0200116 proto_path = perfetto_root_path
Hector Dearman86cfbe12018-03-22 11:58:42 +0000117}
118
Primiano Tucci02c11762019-08-30 00:57:59 +0200119perfetto_unittest_source_set("unittests") {
Hector Dearman86cfbe12018-03-22 11:58:42 +0000120 testonly = true
121 public_deps = []
122 deps = [
123 ":perfetto_cmd",
124 "../../gn:default_deps",
Primiano Tucci13ae72f2019-06-06 10:53:02 +0100125 "../../gn:gtest_and_gmock",
Hector Dearman554627f2019-06-04 17:58:22 +0100126 "../../include/perfetto/base",
Primiano Tucci2c5488f2019-06-01 03:27:28 +0100127 "../../include/perfetto/ext/base",
Primiano Tucci54985c22019-12-03 12:14:08 +0000128 "../../protos/perfetto/config:cpp",
129 "../../protos/perfetto/config/ftrace:cpp",
Primiano Tuccife502c42019-12-11 01:00:27 +0000130 "../../protos/perfetto/trace:cpp",
Primiano Tuccic4c063b2020-01-27 09:34:46 +0000131 "../tracing/core",
Hector Dearman86cfbe12018-03-22 11:58:42 +0000132 ]
Primiano Tucci1b5fdae2020-01-16 09:28:05 +0000133 if (enable_perfetto_zlib) {
134 deps += [ "../../gn:zlib" ]
135 }
Hector Dearman86cfbe12018-03-22 11:58:42 +0000136 sources = [
Hector Dearman5edeafc2018-11-29 13:27:33 +0000137 "config_unittest.cc",
Hector Dearman554627f2019-06-04 17:58:22 +0100138 "packet_writer_unittest.cc",
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000139 "pbtxt_to_pb_unittest.cc",
Hector Dearman86cfbe12018-03-22 11:58:42 +0000140 "rate_limiter_unittest.cc",
Primiano Tucci3b729102018-01-08 18:16:36 +0000141 ]
142}