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/fuzzer.gni") 16import("../../gn/perfetto.gni") 17import("../../gn/perfetto_cc_proto_descriptor.gni") 18import("../../gn/perfetto_host_executable.gni") 19import("../../gn/test.gni") 20import("../../gn/wasm.gni") 21 22# Prevent that this file is accidentally included in embedder builds. 23assert(enable_perfetto_trace_processor) 24 25# The library which eases processing of Perfetto traces by exposing reading 26# friendly APIs. 27if (enable_perfetto_trace_processor_sqlite) { 28 static_library("trace_processor") { 29 complete_static_lib = true 30 public_deps = [ ":lib" ] 31 } 32} 33 34if (enable_perfetto_ui) { 35 wasm_lib("trace_processor_wasm") { 36 name = "trace_processor" 37 deps = [ 38 ":lib", 39 "../../gn:default_deps", 40 "../base", 41 "rpc:wasm_bridge", 42 ] 43 } 44} 45 46source_set("metatrace") { 47 sources = [ 48 "tp_metatrace.cc", 49 "tp_metatrace.h", 50 ] 51 deps = [ 52 "../../gn:default_deps", 53 "../../include/perfetto/ext/base", 54 "../../include/perfetto/trace_processor", 55 "../../protos/perfetto/trace_processor:zero", 56 ] 57} 58 59# In Bazel builds the ":demangle" target (below) should be a static_library so 60# it gets mapped to an actual target (rather than being squashed as a filegroup) 61# and can be replaced in Google internal builds via perfetto_cfg.bzl. 62# Unfortunately, however, static_library targets seem to break Wasm builds on 63# Mac. For this reason we just make it a source_set for all other build types. 64if (is_perfetto_build_generator) { 65 _demangle_target_type = "static_library" 66} else { 67 _demangle_target_type = "source_set" 68} 69 70target(_demangle_target_type, "demangle") { 71 sources = [ "demangle.cc" ] 72 deps = [ 73 "../../gn:default_deps", 74 "../../include/perfetto/base", 75 "../../include/perfetto/ext/base", 76 ] 77 public_deps = [ "../../include/perfetto/ext/trace_processor:demangle" ] 78 if (enable_perfetto_llvm_demangle) { 79 deps += [ "../../gn:llvm_demangle" ] 80 } 81} 82 83source_set("storage_minimal") { 84 sources = [ 85 "forwarding_trace_parser.cc", 86 "forwarding_trace_parser.h", 87 "trace_blob.cc", 88 "trace_processor_context.cc", 89 "trace_processor_storage.cc", 90 "trace_processor_storage_impl.cc", 91 "trace_processor_storage_impl.h", 92 "virtual_destructors.cc", 93 ] 94 deps = [ 95 "../../gn:default_deps", 96 "../base", 97 "../protozero", 98 "containers", 99 "importers/common", 100 "importers/common:parser_types", 101 "importers/ftrace:minimal", 102 "importers/fuchsia:fuchsia_record", 103 "importers/memory_tracker:graph_processor", 104 "importers/proto:gen_cc_chrome_track_event_descriptor", 105 "importers/proto:gen_cc_track_event_descriptor", 106 "importers/proto:minimal", 107 "importers/systrace:systrace_line", 108 "sorter", 109 "storage", 110 "tables", 111 "types", 112 "util:descriptors", 113 "util:gzip", 114 "util:proto_to_args_parser", 115 "util:stack_traces_util", 116 "views", 117 ] 118 public_deps = [ "../../include/perfetto/trace_processor:storage" ] 119} 120 121source_set("export_json") { 122 sources = [ 123 "export_json.cc", 124 "export_json.h", 125 ] 126 deps = [ 127 ":storage_minimal", 128 "../../gn:default_deps", 129 "../base", 130 "importers/json:minimal", 131 "storage", 132 "types", 133 ] 134 public_deps = [ "../../include/perfetto/ext/trace_processor:export_json" ] 135} 136 137if (enable_perfetto_trace_processor_sqlite) { 138 source_set("lib") { 139 sources = [ 140 "iterator_impl.cc", 141 "iterator_impl.h", 142 "read_trace.cc", 143 "read_trace_internal.cc", 144 "read_trace_internal.h", 145 "trace_processor.cc", 146 "trace_processor_impl.cc", 147 "trace_processor_impl.h", 148 ] 149 150 deps = [ 151 ":metatrace", 152 ":storage_minimal", 153 "../../gn:default_deps", 154 "../../protos/perfetto/common:zero", 155 "../../protos/perfetto/trace:zero", 156 "../../protos/perfetto/trace/perfetto:zero", 157 "../base", 158 "../protozero", 159 "db", 160 "importers/android_bugreport", 161 "importers/common", 162 "importers/ftrace:full", 163 "importers/fuchsia:full", 164 "importers/gzip:full", 165 "importers/json:full", 166 "importers/json:minimal", 167 "importers/ninja", 168 "importers/proto:full", 169 "importers/proto:minimal", 170 "importers/systrace:full", 171 "metrics", 172 "prelude/functions", 173 "prelude/operators", 174 "prelude/table_functions", 175 "prelude/tables_views", 176 "sqlite", 177 "stdlib:gen_amalgamated_stdlib", 178 "storage", 179 "tables", 180 "types", 181 "util", 182 "util:gzip", 183 "util:protozero_to_text", 184 "util:stdlib", 185 "views", 186 ] 187 public_deps = [ 188 "../../gn:sqlite", # iterator_impl.h includes sqlite3.h. 189 "../../include/perfetto/trace_processor", 190 ] 191 } 192 193 executable("trace_processor_shell") { 194 deps = [ 195 ":lib", 196 "../../gn:default_deps", 197 "../../gn:protobuf_full", 198 "../../protos/perfetto/trace_processor:zero", 199 "../../src/profiling:deobfuscator", 200 "../../src/profiling/symbolizer", 201 "../../src/profiling/symbolizer:symbolize_database", 202 "../base", 203 "../base:version", 204 "metrics", 205 "util", 206 "util:stdlib", 207 ] 208 if (enable_perfetto_trace_processor_linenoise) { 209 deps += [ "../../gn:linenoise" ] 210 } 211 if (enable_perfetto_trace_processor_httpd) { 212 deps += [ "rpc:httpd" ] 213 } 214 sources = [ 215 "trace_processor_shell.cc", 216 "util/proto_to_json.cc", 217 "util/proto_to_json.h", 218 ] 219 if (perfetto_build_standalone && !is_perfetto_build_generator) { 220 data_deps = [ 221 # The diff testing framework depends on these descriptors. 222 "../../protos/perfetto/metrics:descriptor", 223 "../../protos/perfetto/trace:descriptor", 224 "../../protos/perfetto/trace:test_extensions_descriptor", 225 "../../protos/perfetto/trace_processor:stack_descriptor", 226 "../../protos/third_party/pprof:profile_descriptor", 227 ] 228 } 229 } 230} # if (enable_perfetto_trace_processor_sqlite) 231 232perfetto_unittest_source_set("top_level_unittests") { 233 testonly = true 234 235 sources = [ 236 "forwarding_trace_parser_unittest.cc", 237 "ref_counted_unittest.cc", 238 ] 239 deps = [ 240 ":storage_minimal", 241 "../../gn:default_deps", 242 "../../gn:gtest_and_gmock", 243 "../../include/perfetto/trace_processor", 244 ] 245 246 if (enable_perfetto_trace_processor_json && !is_win) { 247 # export_json_unittest.cc uses base::TempFile, which is not supported on 248 # windows. 249 sources += [ "export_json_unittest.cc" ] 250 deps += [ 251 ":export_json", 252 "../../gn:jsoncpp", 253 "containers", 254 "importers/common", 255 "importers/proto:minimal", 256 "storage", 257 "types", 258 ] 259 } 260} 261 262perfetto_unittest_source_set("unittests") { 263 testonly = true 264 265 # Do not add sources to this target: use top_level_unittests 266 # instead. This us really just a grouping 267 deps = [ 268 ":top_level_unittests", 269 "containers:unittests", 270 "db:unittests", 271 "importers/android_bugreport:unittests", 272 "importers/common:unittests", 273 "importers/ftrace:unittests", 274 "importers/fuchsia:unittests", 275 "importers/memory_tracker:unittests", 276 "importers/proto:unittests", 277 "importers/syscalls:unittests", 278 "importers/systrace:unittests", 279 "rpc:unittests", 280 "sorter:unittests", 281 "tables:unittests", 282 "types:unittests", 283 "util:unittests", 284 "views:unittests", 285 ] 286 if (enable_perfetto_trace_processor_json) { 287 deps += [ "importers/json:unittests" ] 288 } 289 if (enable_perfetto_trace_processor_sqlite) { 290 deps += [ 291 "prelude/functions:unittests", 292 "prelude/operators:unittests", 293 "prelude/table_functions:unittests", 294 "sqlite:unittests", 295 ] 296 } 297} 298 299perfetto_cc_proto_descriptor("gen_cc_test_messages_descriptor") { 300 descriptor_name = "test_messages.descriptor" 301 descriptor_target = "../protozero:test_messages_descriptor" 302} 303 304source_set("integrationtests") { 305 testonly = true 306 sources = [] 307 deps = [] 308 if (enable_perfetto_trace_processor_sqlite) { 309 sources += [ 310 "read_trace_integrationtest.cc", 311 "trace_database_integrationtest.cc", 312 ] 313 deps += [ 314 ":lib", 315 "../../gn:default_deps", 316 "../../gn:gtest_and_gmock", 317 "../../protos/perfetto/common:zero", 318 "../../protos/perfetto/trace:zero", 319 "../../protos/perfetto/trace_processor:zero", 320 "../base", 321 "../base:test_support", 322 "sqlite", 323 ] 324 } 325} 326 327if (enable_perfetto_trace_processor_json) { 328 source_set("storage_minimal_smoke_tests") { 329 testonly = true 330 sources = [ "storage_minimal_smoke_test.cc" ] 331 deps = [ 332 ":export_json", 333 ":storage_minimal", 334 "../../gn:default_deps", 335 "../../gn:gtest_and_gmock", 336 "../../gn:gtest_main", 337 "../../gn:jsoncpp", 338 "../base:test_support", 339 ] 340 } 341} 342 343perfetto_fuzzer_test("trace_processor_fuzzer") { 344 testonly = true 345 sources = [ "trace_parsing_fuzzer.cc" ] 346 deps = [ 347 ":storage_minimal", 348 "../../gn:default_deps", 349 "../base", 350 ] 351} 352