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:gen_cc_android_track_event_descriptor", 131 "importers/proto:gen_cc_chrome_track_event_descriptor", 132 "importers/proto:gen_cc_track_event_descriptor", 133 "importers/proto:minimal", 134 "importers/systrace:systrace_line", 135 "sorter", 136 "storage", 137 "tables", 138 "types", 139 "util:descriptors", 140 "util:gzip", 141 "util:proto_to_args_parser", 142 "util:trace_type", 143 ] 144 public_deps = [ "../../include/perfetto/trace_processor:storage" ] 145} 146 147if (enable_perfetto_trace_processor_sqlite) { 148 source_set("lib") { 149 sources = [ 150 "iterator_impl.cc", 151 "iterator_impl.h", 152 "read_trace.cc", 153 "read_trace_internal.cc", 154 "read_trace_internal.h", 155 "trace_processor.cc", 156 "trace_processor_impl.cc", 157 "trace_processor_impl.h", 158 ] 159 deps = [ 160 ":metatrace", 161 ":storage_minimal", 162 "../../gn:default_deps", 163 "../../protos/perfetto/common:zero", 164 "../../protos/perfetto/trace:zero", 165 "../../protos/perfetto/trace/perfetto:zero", 166 "../../protos/perfetto/trace_processor:zero", 167 "../base", 168 "../base:clock_snapshots", 169 "../protozero", 170 "db", 171 "importers/android_bugreport", 172 "importers/archive", 173 "importers/art_method", 174 "importers/common", 175 "importers/etw:full", 176 "importers/ftrace:full", 177 "importers/fuchsia:full", 178 "importers/json:minimal", 179 "importers/ninja", 180 "importers/perf", 181 "importers/perf_text", 182 "importers/proto:full", 183 "importers/proto:minimal", 184 "importers/systrace:full", 185 "metrics", 186 "perfetto_sql/engine", 187 "perfetto_sql/intrinsics/functions", 188 "perfetto_sql/intrinsics/operators", 189 "perfetto_sql/intrinsics/table_functions", 190 "perfetto_sql/stdlib", 191 "sqlite", 192 "storage", 193 "tables", 194 "types", 195 "util", 196 "util:gzip", 197 "util:protozero_to_json", 198 "util:protozero_to_text", 199 "util:regex", 200 "util:stdlib", 201 "util:trace_type", 202 ] 203 204 if (enable_perfetto_etm_importer) { 205 deps += [ 206 "importers/etm", 207 "perfetto_sql/intrinsics/operators:etm", 208 ] 209 } 210 211 public_deps = [ 212 "../../gn:sqlite", # iterator_impl.h includes sqlite3.h. 213 "../../include/perfetto/trace_processor", 214 ] 215 if (enable_perfetto_trace_processor_mac_instruments) { 216 deps += [ "importers/instruments" ] 217 } 218 if (enable_perfetto_trace_processor_json) { 219 deps += [ 220 "importers/gecko", 221 "importers/json", 222 ] 223 } 224 } 225 226 executable("trace_processor_shell") { 227 deps = [ 228 ":lib", 229 "../../gn:default_deps", 230 "../../gn:protobuf_full", 231 "../../protos/perfetto/trace_processor:zero", 232 "../../src/profiling:deobfuscator", 233 "../../src/profiling/symbolizer", 234 "../../src/profiling/symbolizer:symbolize_database", 235 "../base", 236 "../base:version", 237 "metrics", 238 "rpc:stdiod", 239 "sqlite", 240 "util", 241 "util:stdlib", 242 ] 243 if (enable_perfetto_trace_processor_linenoise) { 244 deps += [ "../../gn:linenoise" ] 245 } 246 if (enable_perfetto_trace_processor_httpd) { 247 deps += [ "rpc:httpd" ] 248 } 249 sources = [ "trace_processor_shell.cc" ] 250 if ((perfetto_build_standalone || build_with_chromium) && 251 !is_perfetto_build_generator) { 252 data_deps = [ 253 # The diff testing framework depends on these descriptors. 254 "../../protos/perfetto/metrics:descriptor", 255 "../../protos/perfetto/trace:descriptor", 256 "../../protos/perfetto/trace:test_extensions_descriptor", 257 "../../protos/perfetto/trace_processor:stack_descriptor", 258 "../../protos/third_party/pprof:descriptor", 259 ] 260 } 261 } 262 263 # Shell target which does not link all the extra libraryes linked by 264 # trace processor shell (e.g. httpd, libprotobuf etc.). Use for binary size 265 # analysis of the trace processor library. 266 executable("trace_processor_minimal_shell") { 267 deps = [ 268 ":lib", 269 "../../gn:default_deps", 270 "util", 271 ] 272 sources = [ "minimal_shell.cc" ] 273 } 274} # if (enable_perfetto_trace_processor_sqlite) 275 276perfetto_unittest_source_set("top_level_unittests") { 277 testonly = true 278 279 sources = [ 280 "forwarding_trace_parser_unittest.cc", 281 "ref_counted_unittest.cc", 282 "trace_blob_unittest.cc", 283 ] 284 deps = [ 285 ":storage_minimal", 286 "../../gn:default_deps", 287 "../../gn:gtest_and_gmock", 288 "../../include/perfetto/trace_processor", 289 "util:trace_type", 290 ] 291 292 if (enable_perfetto_trace_processor_json && !is_win) { 293 # export_json_unittest.cc uses base::TempFile, which is not supported on 294 # windows. 295 sources += [ "export_json_unittest.cc" ] 296 deps += [ 297 ":export_json", 298 "../../gn:jsoncpp", 299 "../../include/perfetto/ext/trace_processor:export_json", 300 "containers", 301 "importers/common", 302 "importers/proto:minimal", 303 "storage", 304 "tables", 305 "types", 306 ] 307 } 308} 309 310perfetto_unittest_source_set("unittests") { 311 testonly = true 312 313 # Do not add sources to this target: use top_level_unittests 314 # instead. This us really just a grouping 315 deps = [ 316 ":top_level_unittests", 317 "containers:unittests", 318 "db:unittests", 319 "db/column:unittests", 320 "importers/android_bugreport:unittests", 321 "importers/common:unittests", 322 "importers/ftrace:unittests", 323 "importers/fuchsia:unittests", 324 "importers/memory_tracker:unittests", 325 "importers/perf:unittests", 326 "importers/proto:unittests", 327 "importers/syscalls:unittests", 328 "importers/systrace:unittests", 329 "rpc:unittests", 330 "sorter:unittests", 331 "tables:unittests", 332 "types:unittests", 333 "util:unittests", 334 ] 335 if (enable_perfetto_trace_processor_json) { 336 deps += [ "importers/json:unittests" ] 337 } 338 if (enable_perfetto_trace_processor_sqlite) { 339 deps += [ 340 "perfetto_sql/engine:unittests", 341 "perfetto_sql/intrinsics/functions:unittests", 342 "perfetto_sql/intrinsics/operators:unittests", 343 "perfetto_sql/intrinsics/table_functions:unittests", 344 "perfetto_sql/parser:unittests", 345 "perfetto_sql/preprocessor:unittests", 346 "perfetto_sql/tokenizer:unittests", 347 "sqlite:unittests", 348 ] 349 } 350 if (enable_perfetto_etm_importer) { 351 deps += [ "importers/etm:unittests" ] 352 } 353} 354 355perfetto_cc_proto_descriptor("gen_cc_test_messages_descriptor") { 356 descriptor_name = "test_messages.descriptor" 357 descriptor_target = "../protozero:testing_messages_descriptor" 358} 359 360source_set("integrationtests") { 361 testonly = true 362 sources = [] 363 deps = [] 364 if (enable_perfetto_trace_processor_sqlite) { 365 sources += [ 366 "read_trace_integrationtest.cc", 367 "trace_database_integrationtest.cc", 368 ] 369 deps += [ 370 ":lib", 371 "../../gn:default_deps", 372 "../../gn:gtest_and_gmock", 373 "../../protos/perfetto/common:zero", 374 "../../protos/perfetto/trace:zero", 375 "../../protos/perfetto/trace_processor:zero", 376 "../base", 377 "../base:test_support", 378 "sqlite", 379 ] 380 } 381} 382 383if (enable_perfetto_trace_processor_json) { 384 source_set("storage_minimal_smoke_tests") { 385 testonly = true 386 sources = [ "storage_minimal_smoke_test.cc" ] 387 deps = [ 388 ":export_json", 389 ":storage_minimal", 390 "../../gn:default_deps", 391 "../../gn:gtest_and_gmock", 392 "../../gn:gtest_main", 393 "../../gn:jsoncpp", 394 "../base:test_support", 395 ] 396 } 397} 398 399perfetto_fuzzer_test("trace_processor_fuzzer") { 400 testonly = true 401 sources = [ "trace_parsing_fuzzer.cc" ] 402 deps = [ 403 ":storage_minimal", 404 "../../gn:default_deps", 405 "../base", 406 ] 407} 408