• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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
15import("../../gn/perfetto.gni")
16import("../../gn/perfetto_cc_proto_descriptor.gni")
17import("../../gn/proto_library.gni")
18import("../../gn/test.gni")
19
20# The command line client for Perfetto. Allows to configure / start / stop
21# tracing, acting as a Consumer.
22executable("perfetto") {
23  deps = [
24    ":perfetto_cmd",
25    "../../gn:default_deps",
26  ]
27  sources = [ "main.cc" ]
28}
29
30# Tool to finalize long running traces.
31# This connects to traced as a producer and sends the triggers passed on the
32# commandline. This is a subset of what the perfetto binary can do but we
33# need a separate binary for programs that cannot (for good reason) use the
34# additional functionality (for example starting traces via consumer socket)
35# due to selinux rules.
36executable("trigger_perfetto") {
37  deps = [
38    ":trigger_perfetto_cmd",
39    "../../gn:default_deps",
40  ]
41  sources = [ "trigger_perfetto_main.cc" ]
42}
43
44# Contains all the implementation but not the main() entry point. This target
45# is shared both by the executable and tests.
46source_set("perfetto_cmd") {
47  public_deps = [
48    ":protos_cpp",
49    "../../include/perfetto/ext/traced",
50  ]
51  deps = [
52    ":bugreport_path",
53    ":gen_cc_config_descriptor",
54    ":pbtxt_to_pb",
55    ":trigger_producer",
56    "../../gn:default_deps",
57    "../../protos/perfetto/common:cpp",
58    "../../protos/perfetto/config:cpp",
59    "../../protos/perfetto/config/ftrace:cpp",
60    "../../protos/perfetto/config/sys_stats:cpp",
61    "../android_stats",
62    "../base",
63    "../base:version",
64    "../protozero",
65    "../tracing/ipc/consumer",
66  ]
67  sources = [
68    "config.cc",
69    "config.h",
70    "packet_writer.cc",
71    "packet_writer.h",
72    "perfetto_cmd.cc",
73    "perfetto_cmd.h",
74    "rate_limiter.cc",
75    "rate_limiter.h",
76  ]
77  if (is_android) {
78    deps += [ "../android_internal:lazy_library_loader" ]
79    sources += [ "perfetto_cmd_android.cc" ]
80  }
81}
82
83source_set("bugreport_path") {
84  sources = [ "bugreport_path.h" ]
85  deps = [ "../../gn:default_deps" ]
86  public_deps = [
87    "../../include/perfetto/base",
88    "../../include/perfetto/ext/base",
89  ]
90}
91
92source_set("pbtxt_to_pb") {
93  deps = [
94    ":gen_cc_config_descriptor",
95    "../../gn:default_deps",
96    "../../protos/perfetto/common:cpp",
97    "../base",
98    "../protozero",
99  ]
100  sources = [
101    "pbtxt_to_pb.cc",
102    "pbtxt_to_pb.h",
103  ]
104}
105
106perfetto_cc_proto_descriptor("gen_cc_config_descriptor") {
107  descriptor_name = "config.descriptor"
108  descriptor_target = "../../protos/perfetto/config:descriptor"
109}
110
111source_set("trigger_perfetto_cmd") {
112  public_deps = [
113    ":protos_cpp",
114    "../../include/perfetto/ext/traced",
115  ]
116  deps = [
117    ":trigger_producer",
118    "../../gn:default_deps",
119    "../android_stats",
120    "../base",
121    "../tracing/ipc/producer",
122  ]
123  sources = [ "trigger_perfetto.cc" ]
124}
125
126source_set("trigger_producer") {
127  sources = [
128    "trigger_producer.cc",
129    "trigger_producer.h",
130  ]
131  deps = [
132    "../../gn:default_deps",
133    "../base",
134    "../tracing/ipc/producer",
135  ]
136}
137
138perfetto_proto_library("protos_@TYPE@") {
139  proto_generators = [
140    "cpp",
141    "source_set",
142  ]
143  sources = [ "perfetto_cmd_state.proto" ]
144  proto_path = perfetto_root_path
145}
146
147perfetto_unittest_source_set("unittests") {
148  testonly = true
149  public_deps = []
150  deps = [
151    ":pbtxt_to_pb",
152    ":perfetto_cmd",
153    "../../gn:default_deps",
154    "../../gn:gtest_and_gmock",
155    "../../include/perfetto/base",
156    "../../include/perfetto/ext/base",
157    "../../protos/perfetto/config:cpp",
158    "../../protos/perfetto/config/ftrace:cpp",
159    "../../protos/perfetto/trace:cpp",
160    "../tracing/core",
161  ]
162  sources = [
163    "config_unittest.cc",
164    "packet_writer_unittest.cc",
165    "pbtxt_to_pb_unittest.cc",
166    "rate_limiter_unittest.cc",
167  ]
168}
169