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/wasm.gni")
18
19wasm_lib("trace_processor_wasm") {
20  name = "trace_processor"
21  sources = [
22    "wasm_bridge.cc",
23  ]
24
25  # All the deps below are implicitly xxx($wasm_toolchain) because of the
26  # outer "is_wasm" block.
27  deps = [
28    ":lib",
29    "../../buildtools:sqlite",
30    "../../gn:default_deps",
31    "../../include/perfetto/base",
32    "../../protos/perfetto/trace_processor:lite",
33  ]
34}
35
36# The library which eases processing of Perfetto traces by exposing reading
37# friendly APIs.
38static_library("trace_processor") {
39  deps = [
40    ":lib",
41  ]
42}
43
44source_set("lib") {
45  sources = [
46    "android_logs_table.cc",
47    "android_logs_table.h",
48    "args_table.cc",
49    "args_table.h",
50    "args_tracker.cc",
51    "args_tracker.h",
52    "chunked_trace_reader.h",
53    "clock_tracker.cc",
54    "clock_tracker.h",
55    "counter_definitions_table.cc",
56    "counter_definitions_table.h",
57    "counter_values_table.cc",
58    "counter_values_table.h",
59    "event_tracker.cc",
60    "event_tracker.h",
61    "filtered_row_index.cc",
62    "filtered_row_index.h",
63    "ftrace_descriptors.cc",
64    "ftrace_descriptors.h",
65    "ftrace_utils.cc",
66    "ftrace_utils.h",
67    "fuchsia_provider_view.cc",
68    "fuchsia_provider_view.h",
69    "fuchsia_trace_parser.cc",
70    "fuchsia_trace_parser.h",
71    "fuchsia_trace_tokenizer.cc",
72    "fuchsia_trace_tokenizer.h",
73    "fuchsia_trace_utils.cc",
74    "fuchsia_trace_utils.h",
75    "heap_profile_tracker.cc",
76    "heap_profile_tracker.h",
77    "instants_table.cc",
78    "instants_table.h",
79    "null_term_string_view.h",
80    "process_table.cc",
81    "process_table.h",
82    "process_tracker.cc",
83    "process_tracker.h",
84    "proto_incremental_state.h",
85    "proto_trace_parser.cc",
86    "proto_trace_parser.h",
87    "proto_trace_tokenizer.cc",
88    "proto_trace_tokenizer.h",
89    "query_constraints.cc",
90    "query_constraints.h",
91    "raw_table.cc",
92    "raw_table.h",
93    "row_iterators.cc",
94    "row_iterators.h",
95    "sched_slice_table.cc",
96    "sched_slice_table.h",
97    "scoped_db.h",
98    "slice_table.cc",
99    "slice_table.h",
100    "slice_tracker.cc",
101    "slice_tracker.h",
102    "span_join_operator_table.cc",
103    "span_join_operator_table.h",
104    "sql_stats_table.cc",
105    "sql_stats_table.h",
106    "sqlite3_str_split.cc",
107    "sqlite3_str_split.h",
108    "sqlite_utils.h",
109    "stats.h",
110    "stats_table.cc",
111    "stats_table.h",
112    "storage_columns.cc",
113    "storage_columns.h",
114    "storage_schema.cc",
115    "storage_schema.h",
116    "storage_table.cc",
117    "storage_table.h",
118    "string_pool.cc",
119    "string_pool.h",
120    "string_table.cc",
121    "string_table.h",
122    "syscall_tracker.cc",
123    "syscall_tracker.h",
124    "syscalls_aarch32.h",
125    "syscalls_aarch64.h",
126    "syscalls_armeabi.h",
127    "syscalls_x86_64.h",
128    "table.cc",
129    "table.h",
130    "thread_table.cc",
131    "thread_table.h",
132    "trace_blob_view.h",
133    "trace_parser.h",
134    "trace_processor.cc",
135    "trace_processor_context.cc",
136    "trace_processor_context.h",
137    "trace_processor_impl.cc",
138    "trace_processor_impl.h",
139    "trace_sorter.cc",
140    "trace_sorter.h",
141    "trace_storage.cc",
142    "trace_storage.h",
143    "virtual_destructors.cc",
144    "window_operator_table.cc",
145    "window_operator_table.h",
146  ]
147
148  deps = [
149    "../../buildtools:sqlite",
150    "../../gn:default_deps",
151    "../../include/perfetto/traced:sys_stats_counters",
152    "../../protos/perfetto/common:zero",
153    "../../protos/perfetto/metrics:zero",
154    "../../protos/perfetto/metrics/android:zero",
155    "../../protos/perfetto/trace:zero",
156    "../../protos/perfetto/trace/android:zero",
157    "../../protos/perfetto/trace/ftrace:zero",
158    "../../protos/perfetto/trace/interned_data:zero",
159    "../../protos/perfetto/trace/power:zero",
160    "../../protos/perfetto/trace/profiling:zero",
161    "../../protos/perfetto/trace/ps:zero",
162    "../../protos/perfetto/trace/sys_stats:zero",
163    "../../protos/perfetto/trace/track_event:zero",
164    "../base",
165    "../protozero",
166    "metrics:lib",
167  ]
168  public_deps = [
169    "../../include/perfetto/trace_processor",
170  ]
171  if (perfetto_build_standalone) {
172    sources += [
173      "json_trace_parser.cc",
174      "json_trace_parser.h",
175      "json_trace_tokenizer.cc",
176      "json_trace_tokenizer.h",
177      "json_trace_utils.cc",
178      "json_trace_utils.h",
179    ]
180    deps += [ "../../gn:jsoncpp_deps" ]
181  }
182}
183
184if (current_toolchain == host_toolchain) {
185  executable("trace_processor_shell_host") {
186    deps = [
187      ":lib",
188      "../../gn:default_deps",
189      "../base",
190    ]
191    if (perfetto_build_standalone) {
192      deps += [
193        "../../buildtools:linenoise",
194        "../../gn/standalone:gen_git_revision",
195      ]
196    }
197    sources = [
198      "trace_processor_shell.cc",
199    ]
200  }
201}
202
203copy("trace_processor_shell") {
204  host_out_dir_ = get_label_info(":trace_processor_shell_host($host_toolchain)",
205                                 "root_out_dir")
206  deps = [
207    ":trace_processor_shell_host($host_toolchain)",
208  ]
209  sources = [
210    "${host_out_dir_}/trace_processor_shell_host",
211  ]
212  outputs = [
213    "${root_out_dir}/trace_processor_shell",
214  ]
215}
216
217source_set("unittests") {
218  testonly = true
219  sources = [
220    "clock_tracker_unittest.cc",
221    "event_tracker_unittest.cc",
222    "filtered_row_index_unittest.cc",
223    "ftrace_utils_unittest.cc",
224    "heap_profile_tracker_unittest.cc",
225    "null_term_string_view_unittest.cc",
226    "process_table_unittest.cc",
227    "process_tracker_unittest.cc",
228    "proto_trace_parser_unittest.cc",
229    "query_constraints_unittest.cc",
230    "sched_slice_table_unittest.cc",
231    "slice_tracker_unittest.cc",
232    "span_join_operator_table_unittest.cc",
233    "sqlite3_str_split_unittest.cc",
234    "string_pool_unittest.cc",
235    "syscall_tracker_unittest.cc",
236    "thread_table_unittest.cc",
237    "trace_processor_impl_unittest.cc",
238    "trace_sorter_unittest.cc",
239  ]
240  deps = [
241    ":lib",
242    "../../buildtools:sqlite",
243    "../../gn:default_deps",
244    "../../gn:gtest_deps",
245    "../../protos/perfetto/common:zero",
246    "../../protos/perfetto/trace:zero",
247    "../../protos/perfetto/trace/ftrace:zero",
248    "../../protos/perfetto/trace/interned_data:zero",
249    "../../protos/perfetto/trace/ps:zero",
250    "../../protos/perfetto/trace/sys_stats:zero",
251    "../../protos/perfetto/trace/track_event:zero",
252    "../base",
253    "../protozero",
254  ]
255  if (perfetto_build_standalone) {
256    sources += [
257      "json_trace_tokenizer_unittest.cc",
258      "json_trace_utils_unittest.cc",
259    ]
260    deps += [ "../../gn:jsoncpp_deps" ]
261  }
262}
263
264source_set("integrationtests") {
265  testonly = true
266  sources = [
267    "trace_database_integrationtest.cc",
268  ]
269  deps = [
270    ":lib",
271    "../../buildtools:sqlite",
272    "../../gn:default_deps",
273    "../../gn:gtest_deps",
274    "../../protos/perfetto/trace:lite",
275    "../../protos/perfetto/trace_processor:lite",
276    "../base",
277    "../base:test_support",
278  ]
279  if (perfetto_build_standalone) {
280    deps += [ "../../gn:jsoncpp_deps" ]
281  }
282}
283
284perfetto_fuzzer_test("trace_processor_fuzzer") {
285  testonly = true
286  sources = [
287    "trace_parsing_fuzzer.cc",
288  ]
289  deps = [
290    ":lib",
291    "../../../../gn:default_deps",
292    "../../buildtools:sqlite",
293    "../../gn:default_deps",
294    "../../gn:gtest_deps",
295    "../../protos/perfetto/trace:lite",
296    "../../protos/perfetto/trace_processor:lite",
297    "../base",
298    "../base:test_support",
299  ]
300}
301