1# Copyright (C) 2024 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/test.gni") 18 19source_set("service") { 20 public_deps = [ 21 "..:common", 22 "../../../include/perfetto/ext/base", 23 "../../../include/perfetto/ext/tracing/core", 24 ] 25 deps = [ 26 "../../../gn:default_deps", 27 "../../../include/perfetto/tracing", 28 "../../../protos/perfetto/common:zero", 29 "../../../protos/perfetto/config:zero", 30 "../../../protos/perfetto/trace:zero", 31 "../../../protos/perfetto/trace/perfetto:zero", # For MetatraceWriter. 32 "../../android_stats", 33 "../../base", 34 "../../base:version", 35 "../../protozero/filtering:message_filter", 36 "../../protozero/filtering:string_filter", 37 "../core", 38 ] 39 sources = [ 40 "histogram.h", 41 "metatrace_writer.cc", 42 "metatrace_writer.h", 43 "packet_stream_validator.cc", 44 "packet_stream_validator.h", 45 "trace_buffer.cc", 46 "trace_buffer.h", 47 "tracing_service_impl.cc", 48 "tracing_service_impl.h", 49 ] 50 if (is_android && perfetto_build_with_android) { 51 deps += [ 52 "../../android_internal:headers", 53 "../../android_internal:lazy_library_loader", 54 ] 55 } 56} 57 58if (enable_perfetto_zlib) { 59 source_set("zlib_compressor") { 60 deps = [ 61 "../../../gn:default_deps", 62 "../../../gn:zlib", 63 "../../../include/perfetto/tracing", 64 "../core", 65 ] 66 sources = [ 67 "zlib_compressor.cc", 68 "zlib_compressor.h", 69 ] 70 } 71} 72 73perfetto_unittest_source_set("unittests") { 74 testonly = true 75 deps = [ 76 ":service", 77 "../../../gn:default_deps", 78 "../../../gn:gtest_and_gmock", 79 "../../../protos/perfetto/trace:cpp", 80 "../../../protos/perfetto/trace:zero", 81 "../../../protos/perfetto/trace/ftrace:cpp", 82 "../../../protos/perfetto/trace/perfetto:cpp", 83 "../../../src/protozero/filtering:bytecode_generator", 84 "../../base", 85 "../../base:test_support", 86 "../core", 87 "../test:test_support", 88 ] 89 90 if (enable_perfetto_zlib) { 91 deps += [ 92 ":zlib_compressor", 93 "../../../gn:zlib", 94 ] 95 } 96 97 sources = [ 98 "histogram_unittest.cc", 99 "packet_stream_validator_unittest.cc", 100 "trace_buffer_unittest.cc", 101 ] 102 103 if (enable_perfetto_zlib) { 104 sources += [ "zlib_compressor_unittest.cc" ] 105 } 106 107 # These tests rely on test_task_runner.h which 108 # has no Windows implementation. 109 if (!is_win) { 110 sources += [ "tracing_service_impl_unittest.cc" ] 111 } 112} 113 114if (enable_perfetto_benchmarks) { 115 source_set("benchmarks") { 116 testonly = true 117 deps = [ 118 ":service", 119 "../../../gn:benchmark", 120 "../../../gn:default_deps", 121 "../../../protos/perfetto/trace:zero", 122 "../../../protos/perfetto/trace/ftrace:zero", 123 "../../protozero", 124 "../core", 125 ] 126 sources = [ "packet_stream_validator_benchmark.cc" ] 127 } 128} 129 130perfetto_fuzzer_test("packet_stream_validator_fuzzer") { 131 sources = [ "packet_stream_validator_fuzzer.cc" ] 132 deps = [ 133 ":service", 134 "../../../gn:default_deps", 135 ] 136} 137