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/proto_library.gni") 17import("../../gn/test.gni") 18 19# 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 ] 26 sources = [ "main.cc" ] 27} 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 ] 40 sources = [ "trigger_perfetto_main.cc" ] 41} 42 43# Contains all the implementation but not the main() entry point. This target 44# is shared both by the executable and tests. 45source_set("perfetto_cmd") { 46 public_deps = [ 47 ":protos_cpp", 48 "../../include/perfetto/ext/traced", 49 ] 50 deps = [ 51 ":bugreport_path", 52 ":trigger_producer", 53 "../../gn:default_deps", 54 "../../protos/perfetto/common:cpp", 55 "../../protos/perfetto/config:cpp", 56 "../../protos/perfetto/config/ftrace:cpp", 57 "../../protos/perfetto/config/sys_stats:cpp", 58 "../android_stats", 59 "../base", 60 "../base:version", 61 "../protozero", 62 "../trace_config_utils:txt_to_pb", 63 "../tracing/ipc/consumer", 64 ] 65 sources = [ 66 "config.cc", 67 "config.h", 68 "packet_writer.cc", 69 "packet_writer.h", 70 "perfetto_cmd.cc", 71 "perfetto_cmd.h", 72 ] 73 assert_no_deps = [ "../trace_processor/*" ] 74 75 if (is_android) { 76 deps += [ "../android_internal:lazy_library_loader" ] 77 sources += [ "perfetto_cmd_android.cc" ] 78 } 79} 80 81source_set("bugreport_path") { 82 sources = [ "bugreport_path.h" ] 83 deps = [ "../../gn:default_deps" ] 84 public_deps = [ 85 "../../include/perfetto/base", 86 "../../include/perfetto/ext/base", 87 ] 88} 89 90source_set("trigger_perfetto_cmd") { 91 public_deps = [ 92 ":protos_cpp", 93 "../../include/perfetto/ext/traced", 94 ] 95 deps = [ 96 ":trigger_producer", 97 "../../gn:default_deps", 98 "../android_stats", 99 "../base", 100 "../tracing/ipc/producer", 101 ] 102 sources = [ "trigger_perfetto.cc" ] 103} 104 105source_set("trigger_producer") { 106 sources = [ 107 "trigger_producer.cc", 108 "trigger_producer.h", 109 ] 110 deps = [ 111 "../../gn:default_deps", 112 "../base", 113 "../tracing/ipc/producer", 114 ] 115} 116 117perfetto_proto_library("protos_@TYPE@") { 118 proto_generators = [ "cpp" ] 119 sources = [ "perfetto_cmd_state.proto" ] 120 proto_path = perfetto_root_path 121} 122 123perfetto_unittest_source_set("unittests") { 124 testonly = true 125 public_deps = [] 126 deps = [ 127 ":perfetto_cmd", 128 "../../gn:default_deps", 129 "../../gn:gtest_and_gmock", 130 "../../include/perfetto/base", 131 "../../include/perfetto/ext/base", 132 "../../protos/perfetto/config:cpp", 133 "../../protos/perfetto/config/ftrace:cpp", 134 "../../protos/perfetto/trace:cpp", 135 "../tracing/core", 136 ] 137 sources = [ 138 "config_unittest.cc", 139 "packet_writer_unittest.cc", 140 ] 141} 142