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