• 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",
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 = "perfetto_config.descriptor"
86  descriptor_target = "../../protos/perfetto/config:perfetto_config_descriptor"
87}
88
89source_set("trigger_perfetto_cmd") {
90  public_deps = [
91    ":protos",
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") {
117  proto_generators = [ "cpp" ]
118  sources = [ "perfetto_cmd_state.proto" ]
119  proto_path = perfetto_root_path
120}
121
122perfetto_unittest_source_set("unittests") {
123  testonly = true
124  public_deps = []
125  deps = [
126    ":perfetto_cmd",
127    "../../gn:default_deps",
128    "../../gn:gtest_and_gmock",
129    "../../include/perfetto/base",
130    "../../include/perfetto/ext/base",
131    "../../protos/perfetto/config:cpp",
132    "../../protos/perfetto/config/ftrace:cpp",
133    "../../protos/perfetto/trace:cpp",
134    "../tracing/core",
135  ]
136  if (enable_perfetto_zlib) {
137    deps += [ "../../gn:zlib" ]
138  }
139  sources = [
140    "config_unittest.cc",
141    "packet_writer_unittest.cc",
142    "pbtxt_to_pb_unittest.cc",
143    "rate_limiter_unittest.cc",
144  ]
145}
146