• 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    ":gen_cc_config_descriptor",
53    ":trigger_producer",
54    "../../gn:default_deps",
55    "../../protos/perfetto/common:cpp",
56    "../../protos/perfetto/config:cpp",
57    "../../protos/perfetto/config/ftrace:cpp",
58    "../android_stats",
59    "../base",
60    "../protozero",
61    "../tracing/ipc/consumer",
62  ]
63  if (enable_perfetto_zlib) {
64    deps += [ "../../gn:zlib" ]
65  }
66  sources = [
67    "config.cc",
68    "config.h",
69    "packet_writer.cc",
70    "packet_writer.h",
71    "pbtxt_to_pb.cc",
72    "pbtxt_to_pb.h",
73    "perfetto_cmd.cc",
74    "perfetto_cmd.h",
75    "rate_limiter.cc",
76    "rate_limiter.h",
77  ]
78  if (is_android) {
79    deps += [ "../android_internal:lazy_library_loader" ]
80    sources += [ "perfetto_cmd_android.cc" ]
81  }
82}
83
84perfetto_cc_proto_descriptor("gen_cc_config_descriptor") {
85  descriptor_name = "config.descriptor"
86  descriptor_target = "../../protos/perfetto/config:descriptor"
87}
88
89source_set("trigger_perfetto_cmd") {
90  public_deps = [
91    ":protos_cpp",
92    "../../include/perfetto/ext/traced",
93  ]
94  deps = [
95    ":trigger_producer",
96    "../../gn:default_deps",
97    "../android_stats",
98    "../base",
99    "../tracing/ipc/producer",
100  ]
101  sources = [ "trigger_perfetto.cc" ]
102}
103
104source_set("trigger_producer") {
105  sources = [
106    "trigger_producer.cc",
107    "trigger_producer.h",
108  ]
109  deps = [
110    "../../gn:default_deps",
111    "../base",
112    "../tracing/ipc/producer",
113  ]
114}
115
116perfetto_proto_library("protos_@TYPE@") {
117  proto_generators = [
118    "cpp",
119    "source_set",
120  ]
121  sources = [ "perfetto_cmd_state.proto" ]
122  proto_path = perfetto_root_path
123}
124
125perfetto_unittest_source_set("unittests") {
126  testonly = true
127  public_deps = []
128  deps = [
129    ":perfetto_cmd",
130    "../../gn:default_deps",
131    "../../gn:gtest_and_gmock",
132    "../../include/perfetto/base",
133    "../../include/perfetto/ext/base",
134    "../../protos/perfetto/config:cpp",
135    "../../protos/perfetto/config/ftrace:cpp",
136    "../../protos/perfetto/trace:cpp",
137    "../tracing/core",
138  ]
139  if (enable_perfetto_zlib) {
140    deps += [ "../../gn:zlib" ]
141  }
142  sources = [
143    "config_unittest.cc",
144    "packet_writer_unittest.cc",
145    "pbtxt_to_pb_unittest.cc",
146    "rate_limiter_unittest.cc",
147  ]
148}
149