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 46# Depended upon by Chrome to do proto -> JSON conversion of traces. 47# Must be small binary size as all code here needs to be shipped in 48# Chrome. 49source_set("export_json") { 50 sources = [ 51 "export_json.cc", 52 "export_json.h", 53 ] 54 deps = [ 55 ":storage_minimal", 56 "../../gn:default_deps", 57 "../../include/perfetto/ext/trace_processor:export_json", 58 "../base", 59 "containers", 60 "importers/common", 61 "importers/json:minimal", 62 "storage", 63 "tables", 64 "types", 65 "util", 66 ] 67 public_deps = [ "../../include/perfetto/ext/trace_processor:export_json" ] 68} 69 70source_set("metatrace") { 71 sources = [ 72 "tp_metatrace.cc", 73 "tp_metatrace.h", 74 ] 75 deps = [ 76 "../../gn:default_deps", 77 "../../include/perfetto/ext/base", 78 "../../include/perfetto/trace_processor", 79 "../../protos/perfetto/trace_processor:zero", 80 ] 81} 82 83# In Bazel builds the ":demangle" target (below) should be a static_library so 84# it gets mapped to an actual target (rather than being squashed as a filegroup) 85# and can be replaced in Google internal builds via perfetto_cfg.bzl. 86# Unfortunately, however, static_library targets seem to break Wasm builds on 87# Mac. For this reason we just make it a source_set for all other build types. 88if (is_perfetto_build_generator) { 89 _demangle_target_type = "static_library" 90} else { 91 _demangle_target_type = "source_set" 92} 93 94target(_demangle_target_type, "demangle") { 95 sources = [ "demangle.cc" ] 96 deps = [ 97 "../../gn:default_deps", 98 "../../include/perfetto/base", 99 "../../include/perfetto/ext/base", 100 ] 101 public_deps = [ "../../include/perfetto/ext/trace_processor:demangle" ] 102 if (enable_perfetto_llvm_demangle) { 103 deps += [ "../../gn:llvm_demangle" ] 104 } 105} 106 107source_set("storage_minimal") { 108 sources = [ 109 "forwarding_trace_parser.cc", 110 "forwarding_trace_parser.h", 111 "trace_blob.cc", 112 "trace_processor_context.cc", 113 "trace_processor_storage.cc", 114 "trace_processor_storage_impl.cc", 115 "trace_processor_storage_impl.h", 116 "trace_reader_registry.cc", 117 "trace_reader_registry.h", 118 "virtual_destructors.cc", 119 ] 120 deps = [ 121 "../../gn:default_deps", 122 "../base", 123 "../protozero", 124 "containers", 125 "importers/common", 126 "importers/common:parser_types", 127 "importers/ftrace:minimal", 128 "importers/fuchsia:fuchsia_record", 129 "importers/memory_tracker:graph_processor", 130 "importers/proto:minimal", 131 "importers/systrace:systrace_line", 132 "sorter", 133 "storage", 134 "tables", 135 "types", 136 "util:descriptors", 137 "util:gzip", 138 "util:proto_to_args_parser", 139 "util:trace_type", 140 ] 141 public_deps = [ "../../include/perfetto/trace_processor:storage" ] 142} 143 144if (enable_perfetto_trace_processor_sqlite) { 145 source_set("lib") { 146 sources = [ 147 "iterator_impl.cc", 148 "iterator_impl.h", 149 "read_trace.cc", 150 "read_trace_internal.cc", 151 "read_trace_internal.h", 152 "trace_processor.cc", 153 "trace_processor_impl.cc", 154 "trace_processor_impl.h", 155 ] 156 deps = [ 157 ":metatrace", 158 ":storage_minimal", 159 "../../gn:default_deps", 160 "../../protos/perfetto/common:zero", 161 "../../protos/perfetto/trace:zero", 162 "../../protos/perfetto/trace/perfetto:zero", 163 "../../protos/perfetto/trace_processor:zero", 164 "../../protos/perfetto/trace_summary:zero", 165 "../base", 166 "../base:clock_snapshots", 167 "../protozero", 168 "db", 169 "importers/android_bugreport", 170 "importers/archive", 171 "importers/art_method", 172 "importers/common", 173 "importers/etw:full", 174 "importers/ftrace:full", 175 "importers/fuchsia:full", 176 "importers/json:minimal", 177 "importers/ninja", 178 "importers/perf", 179 "importers/perf_text", 180 "importers/proto:full", 181 "importers/proto:minimal", 182 "importers/systrace:full", 183 "metrics", 184 "perfetto_sql/engine", 185 "perfetto_sql/generator", 186 "perfetto_sql/intrinsics/functions", 187 "perfetto_sql/intrinsics/operators", 188 "perfetto_sql/intrinsics/table_functions", 189 "perfetto_sql/stdlib", 190 "sqlite", 191 "storage", 192 "tables", 193 "trace_summary", 194 "trace_summary:gen_cc_trace_summary_descriptor", 195 "types", 196 "util", 197 "util:gzip", 198 "util:protozero_to_json", 199 "util:protozero_to_text", 200 "util:regex", 201 "util:stdlib", 202 "util:trace_type", 203 ] 204 205 if (enable_perfetto_etm_importer) { 206 deps += [ 207 "importers/etm", 208 "importers/etm:file_tracker", 209 "perfetto_sql/intrinsics/operators:etm", 210 ] 211 } 212 213 public_deps = [ 214 "../../gn:sqlite", # iterator_impl.h includes sqlite3.h. 215 "../../include/perfetto/trace_processor", 216 ] 217 if (enable_perfetto_trace_processor_mac_instruments) { 218 deps += [ "importers/instruments" ] 219 } 220 if (enable_perfetto_trace_processor_json) { 221 deps += [ 222 "importers/gecko", 223 "importers/json", 224 ] 225 } 226 } 227 228 executable("trace_processor_shell") { 229 deps = [ 230 ":lib", 231 "../../gn:default_deps", 232 "../../gn:protobuf_full", 233 "../../protos/perfetto/trace_processor:zero", 234 "../../src/profiling:deobfuscator", 235 "../../src/profiling/symbolizer", 236 "../../src/profiling/symbolizer:symbolize_database", 237 "../base", 238 "../base:version", 239 "metrics", 240 "rpc:stdiod", 241 "sqlite", 242 "util", 243 "util:stdlib", 244 ] 245 if (enable_perfetto_trace_processor_linenoise) { 246 deps += [ "../../gn:linenoise" ] 247 } 248 if (enable_perfetto_trace_processor_httpd) { 249 deps += [ "rpc:httpd" ] 250 } 251 sources = [ "trace_processor_shell.cc" ] 252 if ((perfetto_build_standalone || build_with_chromium) && 253 !is_perfetto_build_generator) { 254 data_deps = [ 255 # The diff testing framework depends on these descriptors. 256 "../../protos/perfetto/metrics:descriptor", 257 "../../protos/perfetto/trace:descriptor", 258 "../../protos/perfetto/trace:test_extensions_descriptor", 259 "../../protos/perfetto/trace_processor:stack_descriptor", 260 "../../protos/perfetto/trace_summary:descriptor", 261 "../../protos/third_party/pprof:descriptor", 262 ] 263 } 264 } 265 266 # Shell target which does not link all the extra libraryes linked by 267 # trace processor shell (e.g. httpd, libprotobuf etc.). Use for binary size 268 # analysis of the trace processor library. 269 executable("trace_processor_minimal_shell") { 270 deps = [ 271 ":lib", 272 "../../gn:default_deps", 273 "util", 274 ] 275 sources = [ "minimal_shell.cc" ] 276 } 277} # if (enable_perfetto_trace_processor_sqlite) 278 279perfetto_unittest_source_set("top_level_unittests") { 280 testonly = true 281 282 sources = [ 283 "forwarding_trace_parser_unittest.cc", 284 "ref_counted_unittest.cc", 285 "trace_blob_unittest.cc", 286 ] 287 deps = [ 288 ":storage_minimal", 289 "../../gn:default_deps", 290 "../../gn:gtest_and_gmock", 291 "../../include/perfetto/trace_processor", 292 "util:trace_type", 293 ] 294 295 if (enable_perfetto_trace_processor_json && !is_win) { 296 # export_json_unittest.cc uses base::TempFile, which is not supported on 297 # windows. 298 sources += [ "export_json_unittest.cc" ] 299 deps += [ 300 ":export_json", 301 "../../gn:jsoncpp", 302 "../../include/perfetto/ext/trace_processor:export_json", 303 "containers", 304 "importers/common", 305 "importers/proto:minimal", 306 "storage", 307 "tables", 308 "types", 309 ] 310 } 311} 312 313perfetto_unittest_source_set("unittests") { 314 testonly = true 315 316 # Do not add sources to this target: use top_level_unittests 317 # instead. This us really just a grouping 318 deps = [ 319 ":top_level_unittests", 320 "containers:unittests", 321 "db:unittests", 322 "db/column:unittests", 323 "importers/android_bugreport:unittests", 324 "importers/common:unittests", 325 "importers/ftrace:unittests", 326 "importers/fuchsia:unittests", 327 "importers/memory_tracker:unittests", 328 "importers/perf:unittests", 329 "importers/proto:unittests", 330 "importers/syscalls:unittests", 331 "importers/systrace:unittests", 332 "perfetto_sql/generator:unittests", 333 "rpc:unittests", 334 "sorter:unittests", 335 "tables:unittests", 336 "types:unittests", 337 "util:unittests", 338 ] 339 if (enable_perfetto_trace_processor_json) { 340 deps += [ "importers/json:unittests" ] 341 } 342 if (enable_perfetto_trace_processor_sqlite) { 343 deps += [ 344 "perfetto_sql/engine:unittests", 345 "perfetto_sql/intrinsics/functions:unittests", 346 "perfetto_sql/intrinsics/operators:unittests", 347 "perfetto_sql/intrinsics/table_functions:unittests", 348 "perfetto_sql/parser:unittests", 349 "perfetto_sql/preprocessor:unittests", 350 "perfetto_sql/tokenizer:unittests", 351 "sqlite:unittests", 352 ] 353 } 354 if (enable_perfetto_etm_importer) { 355 deps += [ "importers/etm:unittests" ] 356 } 357} 358 359perfetto_cc_proto_descriptor("gen_cc_test_messages_descriptor") { 360 descriptor_name = "test_messages.descriptor" 361 descriptor_target = "../protozero:testing_messages_descriptor" 362} 363 364source_set("integrationtests") { 365 testonly = true 366 sources = [] 367 deps = [] 368 if (enable_perfetto_trace_processor_sqlite) { 369 sources += [ 370 "read_trace_integrationtest.cc", 371 "trace_database_integrationtest.cc", 372 ] 373 deps += [ 374 ":lib", 375 "../../gn:default_deps", 376 "../../gn:gtest_and_gmock", 377 "../../protos/perfetto/common:zero", 378 "../../protos/perfetto/trace:zero", 379 "../../protos/perfetto/trace_processor:zero", 380 "../base", 381 "../base:test_support", 382 "sqlite", 383 ] 384 } 385} 386 387if (enable_perfetto_trace_processor_json) { 388 source_set("storage_minimal_smoke_tests") { 389 testonly = true 390 sources = [ "storage_minimal_smoke_test.cc" ] 391 deps = [ 392 ":export_json", 393 ":storage_minimal", 394 "../../gn:default_deps", 395 "../../gn:gtest_and_gmock", 396 "../../gn:gtest_main", 397 "../../gn:jsoncpp", 398 "../base:test_support", 399 ] 400 } 401} 402 403perfetto_fuzzer_test("trace_processor_fuzzer") { 404 testonly = true 405 sources = [ "trace_parsing_fuzzer.cc" ] 406 deps = [ 407 ":storage_minimal", 408 "../../gn:default_deps", 409 "../base", 410 ] 411} 412