| # Copyright (C) 2024 The Android Open Source Project | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| import("../../../gn/fuzzer.gni") | |
| import("../../../gn/perfetto.gni") | |
| import("../../../gn/test.gni") | |
| source_set("service") { | |
| public_deps = [ | |
| "..:common", | |
| "../../../include/perfetto/ext/base", | |
| "../../../include/perfetto/ext/tracing/core", | |
| "../v2", | |
| ] | |
| deps = [ | |
| ":proto_group_rewriter", | |
| "../../../gn:default_deps", | |
| "../../../include/perfetto/tracing", | |
| "../../../protos/perfetto/common:zero", | |
| "../../../protos/perfetto/config:zero", | |
| "../../../protos/perfetto/config/protovm:cpp", | |
| "../../../protos/perfetto/protovm:cpp", | |
| "../../../protos/perfetto/trace:zero", | |
| "../../../protos/perfetto/trace/perfetto:cpp", | |
| "../../../protos/perfetto/trace/perfetto:zero", # For MetatraceWriter. | |
| "../../android_stats", | |
| "../../base", | |
| "../../base:clock_snapshots", | |
| "../../base:version", | |
| "../../base/regex", | |
| "../../protovm", | |
| "../../protozero/filtering:message_filter", | |
| "../../protozero/filtering:message_filter_config", | |
| "../../protozero/filtering:string_filter", | |
| "../core", | |
| ] | |
| sources = [ | |
| "block_allocator.cc", | |
| "block_allocator.h", | |
| "clock.cc", | |
| "clock.h", | |
| "dependencies.h", | |
| "histogram.h", | |
| "metatrace_writer.cc", | |
| "metatrace_writer.h", | |
| "packet_stream_validator.cc", | |
| "packet_stream_validator.h", | |
| "random.cc", | |
| "random.h", | |
| "sequence_state_map.cc", | |
| "sequence_state_map.h", | |
| "service_ring_buffer_drainer.cc", | |
| "service_ring_buffer_drainer.h", | |
| "trace_buffer.h", | |
| "trace_buffer_factory.cc", | |
| "trace_buffer_factory.h", | |
| "trace_buffer_protovms.cc", | |
| "trace_buffer_protovms.h", | |
| "trace_buffer_v1.cc", | |
| "trace_buffer_v1.h", | |
| "trace_buffer_v2.cc", | |
| "trace_buffer_v2.h", | |
| "tracing_service_endpoints_impl.cc", | |
| "tracing_service_endpoints_impl.h", | |
| "tracing_service_impl.cc", | |
| "tracing_service_impl.h", | |
| "tracing_service_session.cc", | |
| "tracing_service_session.h", | |
| "tracing_service_structs.h", | |
| ] | |
| if (is_android && perfetto_build_with_android) { | |
| deps += [ | |
| "../../android_internal:headers", | |
| "../../android_internal:lazy_library_loader", | |
| ] | |
| } | |
| # The service compresses ReadBuffers output using the codecs below, which | |
| # pull in the optional compression libraries. Depend on them only when | |
| # enabled, so libz/libzstd stay out of builds that don't compress. | |
| if (enable_perfetto_zlib) { | |
| deps += [ ":zlib_compressor" ] | |
| } | |
| if (enable_perfetto_zstd) { | |
| deps += [ | |
| ":zstd_compressor", | |
| "../../../gn:zstd", | |
| ] | |
| # TraceBufferV3 needs zstd to store packets, so include it only with zstd. | |
| # TraceBufferFactory skips it in other builds. | |
| sources += [ | |
| "trace_buffer_v3.cc", | |
| "trace_buffer_v3.h", | |
| "zstd_frame_codec.cc", | |
| "zstd_frame_codec.h", | |
| ] | |
| } | |
| } | |
| # Shared by the zlib and zstd packet compressors below; header-only. | |
| if (enable_perfetto_zlib || enable_perfetto_zstd) { | |
| source_set("packet_compressor_common") { | |
| public_deps = [ | |
| "../../../gn:default_deps", | |
| "../../../include/perfetto/ext/tracing/core", | |
| "../../protozero", | |
| ] | |
| sources = [ "packet_compressor_common.h" ] | |
| } | |
| } | |
| if (enable_perfetto_zlib) { | |
| source_set("zlib_compressor") { | |
| deps = [ | |
| ":packet_compressor_common", | |
| "../../../gn:default_deps", | |
| "../../../gn:zlib", | |
| "../../../include/perfetto/tracing", | |
| "../core", | |
| ] | |
| sources = [ | |
| "zlib_compressor.cc", | |
| "zlib_compressor.h", | |
| ] | |
| } | |
| } | |
| if (enable_perfetto_zstd) { | |
| source_set("zstd_compressor") { | |
| deps = [ | |
| ":packet_compressor_common", | |
| "../../../gn:default_deps", | |
| "../../../gn:zstd", | |
| "../../../include/perfetto/tracing", | |
| "../core", | |
| ] | |
| sources = [ | |
| "zstd_compressor.cc", | |
| "zstd_compressor.h", | |
| ] | |
| } | |
| } | |
| # Pure conversion from tracing v2 internal group framing to length-delimited | |
| # protobuf. Runs at read time in the service on untrusted reassembled packets. | |
| source_set("proto_group_rewriter") { | |
| public_deps = [ | |
| "../../../include/perfetto/ext/base", | |
| "../../../include/perfetto/ext/tracing/core", | |
| ] | |
| deps = [ | |
| "../../../gn:default_deps", | |
| "../../../include/perfetto/protozero", | |
| "../../base", | |
| ] | |
| sources = [ | |
| "proto_group_rewriter.cc", | |
| "proto_group_rewriter.h", | |
| ] | |
| } | |
| perfetto_fuzzer_test("proto_group_rewriter_fuzzer") { | |
| sources = [ | |
| "proto_group_rewriter_fuzzer.cc", | |
| "proto_group_rewriter_reference_for_testing.h", | |
| ] | |
| deps = [ | |
| ":proto_group_rewriter", | |
| "../../../gn:default_deps", | |
| "../../../include/perfetto/protozero", | |
| "../../base", | |
| ] | |
| } | |
| perfetto_unittest_source_set("unittests") { | |
| testonly = true | |
| deps = [ | |
| ":proto_group_rewriter", | |
| ":service", | |
| "../../../gn:default_deps", | |
| "../../../gn:gtest_and_gmock", | |
| "../../../include/perfetto/protozero", | |
| "../../../protos/perfetto/common:semantic_type_cpp", | |
| "../../../protos/perfetto/config/protovm:cpp", | |
| "../../../protos/perfetto/protovm:cpp", | |
| "../../../protos/perfetto/trace:cpp", | |
| "../../../protos/perfetto/trace:zero", | |
| "../../../protos/perfetto/trace/ftrace:cpp", | |
| "../../../protos/perfetto/trace/perfetto:cpp", | |
| "../../../src/protozero/filtering:bytecode_generator", | |
| "../../base", | |
| "../../base:test_support", | |
| "../../protozero", | |
| "../core", | |
| "../test:test_support", | |
| "../v2", | |
| "../v2:test_support", | |
| ] | |
| if (enable_perfetto_zlib) { | |
| deps += [ | |
| ":zlib_compressor", | |
| "../../../gn:zlib", | |
| ] | |
| } | |
| if (enable_perfetto_zstd) { | |
| deps += [ | |
| ":zstd_compressor", | |
| "../../../gn:zstd", | |
| "../../protovm", | |
| ] | |
| } | |
| sources = [ | |
| "block_allocator_unittest.cc", | |
| "histogram_unittest.cc", | |
| "packet_stream_validator_unittest.cc", | |
| "proto_group_rewriter_reference_for_testing.h", | |
| "proto_group_rewriter_unittest.cc", | |
| "sequence_state_map_unittest.cc", | |
| "service_ring_buffer_drainer_unittest.cc", | |
| "trace_buffer_factory_unittest.cc", | |
| "trace_buffer_v1_unittest.cc", | |
| "trace_buffer_v2_unittest.cc", | |
| ] | |
| if (enable_perfetto_zlib || enable_perfetto_zstd) { | |
| deps += [ ":packet_compressor_common" ] | |
| sources += [ "compressor_unittest.cc" ] | |
| } | |
| if (enable_perfetto_zstd) { | |
| sources += [ | |
| "trace_buffer_v3_unittest.cc", | |
| "zstd_frame_codec_unittest.cc", | |
| ] | |
| } | |
| # These tests rely on test_task_runner.h which | |
| # has no Windows implementation. | |
| if (!is_win) { | |
| sources += [ "tracing_service_impl_unittest.cc" ] | |
| } | |
| } | |
| if (enable_perfetto_benchmarks) { | |
| source_set("benchmarks") { | |
| testonly = true | |
| deps = [ | |
| ":service", | |
| "../../../gn:benchmark", | |
| "../../../gn:default_deps", | |
| "../../../protos/perfetto/trace:zero", | |
| "../../../protos/perfetto/trace/ftrace:zero", | |
| "../../../protos/perfetto/trace/track_event:zero", | |
| "../../../protos/third_party/android/art:art_heap_graph_zero", | |
| "../../protozero", | |
| "../core", | |
| "../test:test_support", | |
| ] | |
| sources = [ | |
| "compression_benchmark.cc", | |
| "packet_stream_validator_benchmark.cc", | |
| "trace_buffer_benchmark.cc", | |
| ] | |
| if (enable_perfetto_zlib) { | |
| deps += [ | |
| ":zlib_compressor", | |
| "../../../gn:zlib", | |
| ] | |
| } | |
| if (enable_perfetto_zstd) { | |
| deps += [ | |
| ":zstd_compressor", | |
| "../../../gn:zstd", | |
| ] | |
| } | |
| } | |
| } | |
| perfetto_fuzzer_test("packet_stream_validator_fuzzer") { | |
| sources = [ "packet_stream_validator_fuzzer.cc" ] | |
| deps = [ | |
| ":service", | |
| "../../../gn:default_deps", | |
| ] | |
| } |