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