xref: /aosp_15_r20/external/perfetto/buildtools/BUILD.gn (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1# Copyright (C) 2017 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/perfetto.gni")
16import("../gn/standalone/libc++/libc++.gni")
17import("../gn/standalone/sanitizers/vars.gni")
18
19# We should never get here in embedder builds.
20assert(perfetto_build_standalone || is_perfetto_build_generator)
21
22# This is to make sure that we don't add accidental dependencies from build
23# files in src/ or include/ to buildtools. All deps (outside of /gn/*) should
24# go via the groups defined in gn/BUILD.gn, not directly into buildtools. This
25# is to allow embedders to re-route targets to their third_party directories.
26_buildtools_visibility = [
27  "./*",
28  "../gn:*",
29  "../gn/standalone:*",
30]
31
32# Used to suppress warnings coming from googletest macros expansions.
33# These suppressions apply both to gtest/gmock haders and to perfetto's
34# test translation units. See test/gtest_and_gmock.h for the subset of
35# suppressions that apply only to the gmock/gtest headers.
36config("test_warning_suppressions") {
37  visibility = _buildtools_visibility
38  if (is_clang) {
39    cflags = [
40      "-Wno-covered-switch-default",
41      "-Wno-deprecated-copy-dtor",
42      "-Wno-global-constructors",
43      "-Wno-inconsistent-missing-override",
44      "-Wno-language-extension-token",
45      "-Wno-suggest-destructor-override",
46      "-Wno-suggest-override",
47      "-Wno-undef",
48      "-Wno-unknown-warning-option",
49      "-Wno-unused-member-function",
50      "-Wno-used-but-marked-unused",
51      "-Wno-weak-vtables",
52      "-Wno-zero-as-null-pointer-constant",
53    ]
54  } else if (!is_win) {
55    cflags = [
56      "-Wno-unknown-warning-option",
57      "-Wno-deprecated-copy",
58      "-Wno-uninitialized",
59    ]
60  }
61}
62
63config("libunwindstack_config") {
64  visibility = _buildtools_visibility
65  cflags = [
66    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
67    # warnings coming from libunwindstack headers. Doing so would mask warnings
68    # in our own code.
69    perfetto_isystem_cflag,
70    rebase_path("android-unwinding/libunwindstack/include", root_build_dir),
71    perfetto_isystem_cflag,
72    rebase_path("android-libprocinfo/include", root_build_dir),
73    perfetto_isystem_cflag,
74    rebase_path("android-libbase/include", root_build_dir),
75    perfetto_isystem_cflag,
76    rebase_path("android-core/demangle/include", root_build_dir),
77    perfetto_isystem_cflag,
78    rebase_path("rustc-demangle-capi", root_build_dir),
79  ]
80
81  # TODO(rsavitski): figure out how to cleanly depend on bionic's uapi headers
82  defines = [
83    "NO_LIBDEXFILE_SUPPORT",
84    "NT_RISCV_VECTOR=0x901",
85    "ELFCOMPRESS_ZSTD=2",
86  ]
87}
88
89# Config to include gtest.h in test targets.
90config("googletest_config") {
91  visibility = _buildtools_visibility
92  defines = [ "GTEST_LANG_CXX11=1" ]
93  include_dirs = [
94    "googletest/googletest/include",
95    "googletest/googlemock/include",
96  ]
97  configs = [ ":test_warning_suppressions" ]
98}
99
100source_set("gtest") {
101  visibility = _buildtools_visibility
102  testonly = true
103  include_dirs = [ "googletest/googletest" ]
104  configs -= [ "//gn/standalone:extra_warnings" ]
105  public_configs = [ ":googletest_config" ]
106  all_dependent_configs = [ ":googletest_config" ]
107  sources = [ "googletest/googletest/src/gtest-all.cc" ]
108  deps = [ "//gn:default_deps" ]
109}
110
111source_set("gtest_main") {
112  visibility = _buildtools_visibility
113  testonly = true
114  configs -= [ "//gn/standalone:extra_warnings" ]
115  configs += [ ":googletest_config" ]
116  sources = [ "googletest/googletest/src/gtest_main.cc" ]
117  deps = [ "//gn:default_deps" ]
118}
119
120source_set("gmock") {
121  visibility = _buildtools_visibility
122  testonly = true
123  include_dirs = [ "googletest/googlemock" ]
124  configs -= [ "//gn/standalone:extra_warnings" ]
125  public_configs = [ ":googletest_config" ]
126  all_dependent_configs = [ ":googletest_config" ]
127  sources = [ "googletest/googlemock/src/gmock-all.cc" ]
128  deps = [ "//gn:default_deps" ]
129}
130
131# Configuration used to build libprotobuf_* and the protoc compiler.
132config("protobuf_config") {
133  visibility = _buildtools_visibility
134
135  # Apply the lighter supressions and macro definitions from above.
136  configs = [ "//gn:protobuf_gen_config" ]
137
138  defines = [ "HAVE_PTHREAD=1" ]
139  cflags = []
140
141  # Fixed upstream in:
142  # https://github.com/protocolbuffers/protobuf/pull/10112
143  # But we don't have that yet.
144  if (is_mac) {
145    cflags += [ "-Wno-deprecated-declarations" ]
146  }
147  if (is_gcc) {
148    cflags += [ "-Wno-stringop-overread" ]
149  }
150  if (is_win) {
151    cflags += [ "/W0" ]
152  }
153}
154
155# Configuration propagated to targets depending on protobuf_full.
156config("protobuf_full_public_config") {
157  visibility = _buildtools_visibility
158  cflags = []
159  if (is_clang) {
160    cflags += [ "-Wno-switch-enum" ]
161    if (is_win) {
162      cflags += [ "-Wno-undef" ]
163    }
164  }
165}
166
167_protobuf_headers = [
168  "protobuf/src/google/protobuf/any.h",
169  "protobuf/src/google/protobuf/any.pb.h",
170  "protobuf/src/google/protobuf/api.pb.h",
171  "protobuf/src/google/protobuf/arena_impl.h",
172  "protobuf/src/google/protobuf/arena.h",
173  "protobuf/src/google/protobuf/arenastring.h",
174  "protobuf/src/google/protobuf/arenaz_sampler.h",
175  "protobuf/src/google/protobuf/compiler/importer.h",
176  "protobuf/src/google/protobuf/compiler/parser.h",
177  "protobuf/src/google/protobuf/descriptor_database.h",
178  "protobuf/src/google/protobuf/descriptor.h",
179  "protobuf/src/google/protobuf/descriptor.pb.h",
180  "protobuf/src/google/protobuf/duration.pb.h",
181  "protobuf/src/google/protobuf/dynamic_message.h",
182  "protobuf/src/google/protobuf/empty.pb.h",
183  "protobuf/src/google/protobuf/endian.h",
184  "protobuf/src/google/protobuf/explicitly_constructed.h",
185  "protobuf/src/google/protobuf/extension_set_inl.h",
186  "protobuf/src/google/protobuf/extension_set.h",
187  "protobuf/src/google/protobuf/field_access_listener.h",
188  "protobuf/src/google/protobuf/field_mask.pb.h",
189  "protobuf/src/google/protobuf/generated_enum_reflection.h",
190  "protobuf/src/google/protobuf/generated_enum_util.h",
191  "protobuf/src/google/protobuf/generated_message_bases.h",
192  "protobuf/src/google/protobuf/generated_message_reflection.h",
193  "protobuf/src/google/protobuf/generated_message_tctable_decl.h",
194  "protobuf/src/google/protobuf/generated_message_tctable_impl.h",
195  "protobuf/src/google/protobuf/generated_message_util.h",
196  "protobuf/src/google/protobuf/has_bits.h",
197  "protobuf/src/google/protobuf/implicit_weak_message.h",
198  "protobuf/src/google/protobuf/inlined_string_field.h",
199  "protobuf/src/google/protobuf/io/coded_stream.h",
200  "protobuf/src/google/protobuf/io/io_win32.h",
201  "protobuf/src/google/protobuf/io/printer.h",
202  "protobuf/src/google/protobuf/io/strtod.h",
203  "protobuf/src/google/protobuf/io/tokenizer.h",
204  "protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h",
205  "protobuf/src/google/protobuf/io/zero_copy_stream_impl.h",
206  "protobuf/src/google/protobuf/io/zero_copy_stream.h",
207  "protobuf/src/google/protobuf/map_entry_lite.h",
208  "protobuf/src/google/protobuf/map_entry.h",
209  "protobuf/src/google/protobuf/map_field_inl.h",
210  "protobuf/src/google/protobuf/map_field_lite.h",
211  "protobuf/src/google/protobuf/map_field.h",
212  "protobuf/src/google/protobuf/map_type_handler.h",
213  "protobuf/src/google/protobuf/map.h",
214  "protobuf/src/google/protobuf/message_lite.h",
215  "protobuf/src/google/protobuf/message.h",
216  "protobuf/src/google/protobuf/metadata_lite.h",
217  "protobuf/src/google/protobuf/metadata.h",
218  "protobuf/src/google/protobuf/parse_context.h",
219  "protobuf/src/google/protobuf/port_def.inc",
220  "protobuf/src/google/protobuf/port_undef.inc",
221  "protobuf/src/google/protobuf/port.h",
222  "protobuf/src/google/protobuf/reflection_internal.h",
223  "protobuf/src/google/protobuf/reflection_ops.h",
224  "protobuf/src/google/protobuf/reflection.h",
225  "protobuf/src/google/protobuf/repeated_field.h",
226  "protobuf/src/google/protobuf/repeated_ptr_field.h",
227  "protobuf/src/google/protobuf/service.h",
228  "protobuf/src/google/protobuf/source_context.pb.h",
229  "protobuf/src/google/protobuf/struct.pb.h",
230  "protobuf/src/google/protobuf/stubs/bytestream.h",
231  "protobuf/src/google/protobuf/stubs/callback.h",
232  "protobuf/src/google/protobuf/stubs/casts.h",
233  "protobuf/src/google/protobuf/stubs/common.h",
234  "protobuf/src/google/protobuf/stubs/hash.h",
235  "protobuf/src/google/protobuf/stubs/logging.h",
236  "protobuf/src/google/protobuf/stubs/macros.h",
237  "protobuf/src/google/protobuf/stubs/map_util.h",
238  "protobuf/src/google/protobuf/stubs/mutex.h",
239  "protobuf/src/google/protobuf/stubs/once.h",
240  "protobuf/src/google/protobuf/stubs/platform_macros.h",
241  "protobuf/src/google/protobuf/stubs/port.h",
242  "protobuf/src/google/protobuf/stubs/status.h",
243  "protobuf/src/google/protobuf/stubs/stl_util.h",
244  "protobuf/src/google/protobuf/stubs/stringpiece.h",
245  "protobuf/src/google/protobuf/stubs/strutil.h",
246  "protobuf/src/google/protobuf/stubs/template_util.h",
247  "protobuf/src/google/protobuf/text_format.h",
248  "protobuf/src/google/protobuf/timestamp.pb.h",
249  "protobuf/src/google/protobuf/type.pb.h",
250  "protobuf/src/google/protobuf/unknown_field_set.h",
251  "protobuf/src/google/protobuf/util/delimited_message_util.h",
252  "protobuf/src/google/protobuf/util/field_comparator.h",
253  "protobuf/src/google/protobuf/util/field_mask_util.h",
254  "protobuf/src/google/protobuf/util/json_util.h",
255  "protobuf/src/google/protobuf/util/message_differencer.h",
256  "protobuf/src/google/protobuf/util/time_util.h",
257  "protobuf/src/google/protobuf/util/type_resolver_util.h",
258  "protobuf/src/google/protobuf/util/type_resolver.h",
259  "protobuf/src/google/protobuf/wire_format_lite.h",
260  "protobuf/src/google/protobuf/wire_format.h",
261  "protobuf/src/google/protobuf/wrappers.pb.h",
262]
263
264source_set("protobuf_lite") {
265  visibility = _buildtools_visibility
266  sources = [
267    "protobuf/src/google/protobuf/any_lite.cc",
268    "protobuf/src/google/protobuf/arena.cc",
269    "protobuf/src/google/protobuf/arenastring.cc",
270    "protobuf/src/google/protobuf/arenaz_sampler.cc",
271    "protobuf/src/google/protobuf/extension_set.cc",
272    "protobuf/src/google/protobuf/generated_enum_util.cc",
273    "protobuf/src/google/protobuf/generated_message_tctable_lite.cc",
274    "protobuf/src/google/protobuf/generated_message_util.cc",
275    "protobuf/src/google/protobuf/implicit_weak_message.cc",
276    "protobuf/src/google/protobuf/inlined_string_field.cc",
277    "protobuf/src/google/protobuf/io/coded_stream.cc",
278    "protobuf/src/google/protobuf/io/io_win32.cc",
279    "protobuf/src/google/protobuf/io/strtod.cc",
280    "protobuf/src/google/protobuf/io/zero_copy_stream.cc",
281    "protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc",
282    "protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
283    "protobuf/src/google/protobuf/map.cc",
284    "protobuf/src/google/protobuf/message_lite.cc",
285    "protobuf/src/google/protobuf/parse_context.cc",
286    "protobuf/src/google/protobuf/repeated_field.cc",
287    "protobuf/src/google/protobuf/repeated_ptr_field.cc",
288    "protobuf/src/google/protobuf/string_member_robber.h",
289    "protobuf/src/google/protobuf/stubs/bytestream.cc",
290    "protobuf/src/google/protobuf/stubs/common.cc",
291    "protobuf/src/google/protobuf/stubs/int128.cc",
292    "protobuf/src/google/protobuf/stubs/int128.h",
293    "protobuf/src/google/protobuf/stubs/mathutil.h",
294    "protobuf/src/google/protobuf/stubs/status.cc",
295    "protobuf/src/google/protobuf/stubs/status_macros.h",
296    "protobuf/src/google/protobuf/stubs/statusor.cc",
297    "protobuf/src/google/protobuf/stubs/statusor.h",
298    "protobuf/src/google/protobuf/stubs/stringpiece.cc",
299    "protobuf/src/google/protobuf/stubs/stringprintf.cc",
300    "protobuf/src/google/protobuf/stubs/stringprintf.h",
301    "protobuf/src/google/protobuf/stubs/structurally_valid.cc",
302    "protobuf/src/google/protobuf/stubs/strutil.cc",
303    "protobuf/src/google/protobuf/stubs/time.cc",
304    "protobuf/src/google/protobuf/stubs/time.h",
305    "protobuf/src/google/protobuf/wire_format_lite.cc",
306  ]
307  sources += _protobuf_headers
308  configs -= [ "//gn/standalone:extra_warnings" ]
309  if (is_win) {
310    # Protobuf has its own #define WIN32_LEAN_AND_MEAN.
311    configs -= [ "//gn/standalone:win32_lean_and_mean" ]
312  }
313  configs += [ ":protobuf_config" ]
314  public_configs = [ "//gn:protobuf_gen_config" ]
315  deps = [ "//gn:default_deps" ]
316}
317
318source_set("protobuf_full") {
319  visibility = _buildtools_visibility
320  deps = [
321    ":protobuf_lite",
322    "//gn:default_deps",
323  ]
324  sources = [
325    "protobuf/src/google/protobuf/any.cc",
326    "protobuf/src/google/protobuf/any.pb.cc",
327    "protobuf/src/google/protobuf/api.pb.cc",
328    "protobuf/src/google/protobuf/compiler/importer.cc",
329    "protobuf/src/google/protobuf/compiler/parser.cc",
330    "protobuf/src/google/protobuf/descriptor.cc",
331    "protobuf/src/google/protobuf/descriptor.pb.cc",
332    "protobuf/src/google/protobuf/descriptor_database.cc",
333    "protobuf/src/google/protobuf/duration.pb.cc",
334    "protobuf/src/google/protobuf/dynamic_message.cc",
335    "protobuf/src/google/protobuf/empty.pb.cc",
336    "protobuf/src/google/protobuf/extension_set_heavy.cc",
337    "protobuf/src/google/protobuf/field_mask.pb.cc",
338    "protobuf/src/google/protobuf/generated_message_bases.cc",
339    "protobuf/src/google/protobuf/generated_message_reflection.cc",
340    "protobuf/src/google/protobuf/generated_message_tctable_full.cc",
341    "protobuf/src/google/protobuf/io/gzip_stream.cc",
342    "protobuf/src/google/protobuf/io/printer.cc",
343    "protobuf/src/google/protobuf/io/tokenizer.cc",
344    "protobuf/src/google/protobuf/map_field.cc",
345    "protobuf/src/google/protobuf/message.cc",
346    "protobuf/src/google/protobuf/reflection_ops.cc",
347    "protobuf/src/google/protobuf/service.cc",
348    "protobuf/src/google/protobuf/source_context.pb.cc",
349    "protobuf/src/google/protobuf/struct.pb.cc",
350    "protobuf/src/google/protobuf/stubs/substitute.cc",
351    "protobuf/src/google/protobuf/stubs/substitute.h",
352    "protobuf/src/google/protobuf/text_format.cc",
353    "protobuf/src/google/protobuf/timestamp.pb.cc",
354    "protobuf/src/google/protobuf/type.pb.cc",
355    "protobuf/src/google/protobuf/unknown_field_set.cc",
356    "protobuf/src/google/protobuf/util/delimited_message_util.cc",
357    "protobuf/src/google/protobuf/util/field_comparator.cc",
358    "protobuf/src/google/protobuf/util/field_mask_util.cc",
359    "protobuf/src/google/protobuf/util/internal/constants.h",
360    "protobuf/src/google/protobuf/util/internal/datapiece.cc",
361    "protobuf/src/google/protobuf/util/internal/datapiece.h",
362    "protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc",
363    "protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h",
364    "protobuf/src/google/protobuf/util/internal/error_listener.cc",
365    "protobuf/src/google/protobuf/util/internal/error_listener.h",
366    "protobuf/src/google/protobuf/util/internal/expecting_objectwriter.h",
367    "protobuf/src/google/protobuf/util/internal/field_mask_utility.cc",
368    "protobuf/src/google/protobuf/util/internal/field_mask_utility.h",
369    "protobuf/src/google/protobuf/util/internal/json_escaping.cc",
370    "protobuf/src/google/protobuf/util/internal/json_escaping.h",
371    "protobuf/src/google/protobuf/util/internal/json_objectwriter.cc",
372    "protobuf/src/google/protobuf/util/internal/json_objectwriter.h",
373    "protobuf/src/google/protobuf/util/internal/json_stream_parser.cc",
374    "protobuf/src/google/protobuf/util/internal/json_stream_parser.h",
375    "protobuf/src/google/protobuf/util/internal/location_tracker.h",
376    "protobuf/src/google/protobuf/util/internal/mock_error_listener.h",
377    "protobuf/src/google/protobuf/util/internal/object_location_tracker.h",
378    "protobuf/src/google/protobuf/util/internal/object_source.h",
379    "protobuf/src/google/protobuf/util/internal/object_writer.cc",
380    "protobuf/src/google/protobuf/util/internal/object_writer.h",
381    "protobuf/src/google/protobuf/util/internal/proto_writer.cc",
382    "protobuf/src/google/protobuf/util/internal/proto_writer.h",
383    "protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc",
384    "protobuf/src/google/protobuf/util/internal/protostream_objectsource.h",
385    "protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc",
386    "protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h",
387    "protobuf/src/google/protobuf/util/internal/structured_objectwriter.h",
388    "protobuf/src/google/protobuf/util/internal/type_info.cc",
389    "protobuf/src/google/protobuf/util/internal/type_info.h",
390    "protobuf/src/google/protobuf/util/internal/type_info_test_helper.h",
391    "protobuf/src/google/protobuf/util/internal/utility.cc",
392    "protobuf/src/google/protobuf/util/internal/utility.h",
393    "protobuf/src/google/protobuf/util/json_util.cc",
394    "protobuf/src/google/protobuf/util/message_differencer.cc",
395    "protobuf/src/google/protobuf/util/time_util.cc",
396    "protobuf/src/google/protobuf/util/type_resolver_util.cc",
397    "protobuf/src/google/protobuf/wire_format.cc",
398    "protobuf/src/google/protobuf/wrappers.pb.cc",
399  ]
400  sources += _protobuf_headers
401  configs -= [ "//gn/standalone:extra_warnings" ]
402  if (is_win) {
403    # Protobuf has its own #define WIN32_LEAN_AND_MEAN.
404    configs -= [ "//gn/standalone:win32_lean_and_mean" ]
405  }
406  configs += [ ":protobuf_config" ]
407  public_configs = [
408    "//gn:protobuf_gen_config",
409    ":protobuf_full_public_config",
410  ]
411}
412
413source_set("protoc_lib") {
414  visibility = _buildtools_visibility
415  deps = [
416    ":protobuf_full",
417    "//gn:default_deps",
418  ]
419  sources = [
420    "protobuf/src/google/protobuf/compiler/code_generator.cc",
421    "protobuf/src/google/protobuf/compiler/code_generator.h",
422    "protobuf/src/google/protobuf/compiler/command_line_interface.cc",
423    "protobuf/src/google/protobuf/compiler/command_line_interface.h",
424    "protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h",
425    "protobuf/src/google/protobuf/compiler/cpp/enum.cc",
426    "protobuf/src/google/protobuf/compiler/cpp/enum.h",
427    "protobuf/src/google/protobuf/compiler/cpp/enum_field.cc",
428    "protobuf/src/google/protobuf/compiler/cpp/enum_field.h",
429    "protobuf/src/google/protobuf/compiler/cpp/extension.cc",
430    "protobuf/src/google/protobuf/compiler/cpp/extension.h",
431    "protobuf/src/google/protobuf/compiler/cpp/field.cc",
432    "protobuf/src/google/protobuf/compiler/cpp/field.h",
433    "protobuf/src/google/protobuf/compiler/cpp/file.cc",
434    "protobuf/src/google/protobuf/compiler/cpp/file.h",
435    "protobuf/src/google/protobuf/compiler/cpp/generator.cc",
436    "protobuf/src/google/protobuf/compiler/cpp/generator.h",
437    "protobuf/src/google/protobuf/compiler/cpp/helpers.cc",
438    "protobuf/src/google/protobuf/compiler/cpp/helpers.h",
439    "protobuf/src/google/protobuf/compiler/cpp/map_field.cc",
440    "protobuf/src/google/protobuf/compiler/cpp/map_field.h",
441    "protobuf/src/google/protobuf/compiler/cpp/message.cc",
442    "protobuf/src/google/protobuf/compiler/cpp/message.h",
443    "protobuf/src/google/protobuf/compiler/cpp/message_field.cc",
444    "protobuf/src/google/protobuf/compiler/cpp/message_field.h",
445    "protobuf/src/google/protobuf/compiler/cpp/message_layout_helper.h",
446    "protobuf/src/google/protobuf/compiler/cpp/names.h",
447    "protobuf/src/google/protobuf/compiler/cpp/options.h",
448    "protobuf/src/google/protobuf/compiler/cpp/padding_optimizer.cc",
449    "protobuf/src/google/protobuf/compiler/cpp/padding_optimizer.h",
450    "protobuf/src/google/protobuf/compiler/cpp/parse_function_generator.cc",
451    "protobuf/src/google/protobuf/compiler/cpp/parse_function_generator.h",
452    "protobuf/src/google/protobuf/compiler/cpp/primitive_field.cc",
453    "protobuf/src/google/protobuf/compiler/cpp/primitive_field.h",
454    "protobuf/src/google/protobuf/compiler/cpp/service.cc",
455    "protobuf/src/google/protobuf/compiler/cpp/service.h",
456    "protobuf/src/google/protobuf/compiler/cpp/string_field.cc",
457    "protobuf/src/google/protobuf/compiler/cpp/string_field.h",
458    "protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
459    "protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.h",
460    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc",
461    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum.h",
462    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
463    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.h",
464    "protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
465    "protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.h",
466    "protobuf/src/google/protobuf/compiler/csharp/csharp_generator.cc",
467    "protobuf/src/google/protobuf/compiler/csharp/csharp_generator.h",
468    "protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
469    "protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.h",
470    "protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
471    "protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.h",
472    "protobuf/src/google/protobuf/compiler/csharp/csharp_message.cc",
473    "protobuf/src/google/protobuf/compiler/csharp/csharp_message.h",
474    "protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
475    "protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.h",
476    "protobuf/src/google/protobuf/compiler/csharp/csharp_names.h",
477    "protobuf/src/google/protobuf/compiler/csharp/csharp_options.h",
478    "protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
479    "protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.h",
480    "protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
481    "protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.h",
482    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
483    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h",
484    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
485    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h",
486    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
487    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h",
488    "protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
489    "protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h",
490    "protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
491    "protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h",
492    "protobuf/src/google/protobuf/compiler/java/context.cc",
493    "protobuf/src/google/protobuf/compiler/java/context.h",
494    "protobuf/src/google/protobuf/compiler/java/doc_comment.cc",
495    "protobuf/src/google/protobuf/compiler/java/doc_comment.h",
496    "protobuf/src/google/protobuf/compiler/java/enum.cc",
497    "protobuf/src/google/protobuf/compiler/java/enum.h",
498    "protobuf/src/google/protobuf/compiler/java/enum_field.cc",
499    "protobuf/src/google/protobuf/compiler/java/enum_field.h",
500    "protobuf/src/google/protobuf/compiler/java/enum_field_lite.cc",
501    "protobuf/src/google/protobuf/compiler/java/enum_field_lite.h",
502    "protobuf/src/google/protobuf/compiler/java/enum_lite.cc",
503    "protobuf/src/google/protobuf/compiler/java/enum_lite.h",
504    "protobuf/src/google/protobuf/compiler/java/extension.cc",
505    "protobuf/src/google/protobuf/compiler/java/extension.h",
506    "protobuf/src/google/protobuf/compiler/java/extension_lite.cc",
507    "protobuf/src/google/protobuf/compiler/java/extension_lite.h",
508    "protobuf/src/google/protobuf/compiler/java/field.cc",
509    "protobuf/src/google/protobuf/compiler/java/field.h",
510    "protobuf/src/google/protobuf/compiler/java/file.cc",
511    "protobuf/src/google/protobuf/compiler/java/file.h",
512    "protobuf/src/google/protobuf/compiler/java/generator.cc",
513    "protobuf/src/google/protobuf/compiler/java/generator.h",
514    "protobuf/src/google/protobuf/compiler/java/generator_factory.cc",
515    "protobuf/src/google/protobuf/compiler/java/generator_factory.h",
516    "protobuf/src/google/protobuf/compiler/java/helpers.cc",
517    "protobuf/src/google/protobuf/compiler/java/helpers.h",
518    "protobuf/src/google/protobuf/compiler/java/java_generator.h",
519    "protobuf/src/google/protobuf/compiler/java/kotlin_generator.cc",
520    "protobuf/src/google/protobuf/compiler/java/kotlin_generator.h",
521    "protobuf/src/google/protobuf/compiler/java/map_field.cc",
522    "protobuf/src/google/protobuf/compiler/java/map_field.h",
523    "protobuf/src/google/protobuf/compiler/java/map_field_lite.cc",
524    "protobuf/src/google/protobuf/compiler/java/map_field_lite.h",
525    "protobuf/src/google/protobuf/compiler/java/message.cc",
526    "protobuf/src/google/protobuf/compiler/java/message.h",
527    "protobuf/src/google/protobuf/compiler/java/message_builder.cc",
528    "protobuf/src/google/protobuf/compiler/java/message_builder.h",
529    "protobuf/src/google/protobuf/compiler/java/message_builder_lite.cc",
530    "protobuf/src/google/protobuf/compiler/java/message_builder_lite.h",
531    "protobuf/src/google/protobuf/compiler/java/message_field.cc",
532    "protobuf/src/google/protobuf/compiler/java/message_field.h",
533    "protobuf/src/google/protobuf/compiler/java/message_field_lite.cc",
534    "protobuf/src/google/protobuf/compiler/java/message_field_lite.h",
535    "protobuf/src/google/protobuf/compiler/java/message_lite.cc",
536    "protobuf/src/google/protobuf/compiler/java/message_lite.h",
537    "protobuf/src/google/protobuf/compiler/java/name_resolver.cc",
538    "protobuf/src/google/protobuf/compiler/java/name_resolver.h",
539    "protobuf/src/google/protobuf/compiler/java/names.h",
540    "protobuf/src/google/protobuf/compiler/java/options.h",
541    "protobuf/src/google/protobuf/compiler/java/primitive_field.cc",
542    "protobuf/src/google/protobuf/compiler/java/primitive_field.h",
543    "protobuf/src/google/protobuf/compiler/java/primitive_field_lite.cc",
544    "protobuf/src/google/protobuf/compiler/java/primitive_field_lite.h",
545    "protobuf/src/google/protobuf/compiler/java/service.cc",
546    "protobuf/src/google/protobuf/compiler/java/service.h",
547    "protobuf/src/google/protobuf/compiler/java/shared_code_generator.cc",
548    "protobuf/src/google/protobuf/compiler/java/shared_code_generator.h",
549    "protobuf/src/google/protobuf/compiler/java/string_field.cc",
550    "protobuf/src/google/protobuf/compiler/java/string_field.h",
551    "protobuf/src/google/protobuf/compiler/java/string_field_lite.cc",
552    "protobuf/src/google/protobuf/compiler/java/string_field_lite.h",
553    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
554    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.h",
555    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
556    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h",
557    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
558    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.h",
559    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.cc",
560    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.h",
561    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.cc",
562    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.h",
563    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
564    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.h",
565    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
566    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.h",
567    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
568    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.h",
569    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc",
570    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.h",
571    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
572    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.h",
573    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h",
574    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
575    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.h",
576    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
577    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h",
578    "protobuf/src/google/protobuf/compiler/php/php_generator.cc",
579    "protobuf/src/google/protobuf/compiler/php/php_generator.h",
580    "protobuf/src/google/protobuf/compiler/plugin.cc",
581    "protobuf/src/google/protobuf/compiler/plugin.h",
582    "protobuf/src/google/protobuf/compiler/plugin.pb.cc",
583    "protobuf/src/google/protobuf/compiler/plugin.pb.h",
584    "protobuf/src/google/protobuf/compiler/python/generator.cc",
585    "protobuf/src/google/protobuf/compiler/python/generator.h",
586    "protobuf/src/google/protobuf/compiler/python/helpers.cc",
587    "protobuf/src/google/protobuf/compiler/python/helpers.h",
588    "protobuf/src/google/protobuf/compiler/python/pyi_generator.cc",
589    "protobuf/src/google/protobuf/compiler/python/pyi_generator.h",
590    "protobuf/src/google/protobuf/compiler/python/python_generator.h",
591    "protobuf/src/google/protobuf/compiler/ruby/ruby_generator.cc",
592    "protobuf/src/google/protobuf/compiler/ruby/ruby_generator.h",
593    "protobuf/src/google/protobuf/compiler/scc.h",
594    "protobuf/src/google/protobuf/compiler/subprocess.cc",
595    "protobuf/src/google/protobuf/compiler/subprocess.h",
596    "protobuf/src/google/protobuf/compiler/zip_writer.cc",
597    "protobuf/src/google/protobuf/compiler/zip_writer.h",
598  ]
599  configs -= [ "//gn/standalone:extra_warnings" ]
600  if (is_win) {
601    # Protobuf does has its own #define WIN32_LEAN_AND_MEAN.
602    configs -= [ "//gn/standalone:win32_lean_and_mean" ]
603  }
604  configs += [ ":protobuf_config" ]
605  public_configs = [
606    "//gn:protobuf_gen_config",
607    ":protobuf_full_public_config",
608  ]
609}
610
611if (current_toolchain == host_toolchain) {
612  executable("protoc") {
613    visibility = _buildtools_visibility
614    deps = [
615      ":protoc_lib",
616      "//gn:default_deps",
617    ]
618    sources = [ "protobuf/src/google/protobuf/compiler/main.cc" ]
619    configs -= [ "//gn/standalone:extra_warnings" ]
620    if (is_win) {
621      # Protobuf does has its own #define WIN32_LEAN_AND_MEAN.
622      configs -= [ "//gn/standalone:win32_lean_and_mean" ]
623    }
624  }
625}  # host_toolchain
626
627if (use_custom_libcxx) {
628  config("libunwind_config") {
629    defines = [ "_LIBUNWIND_IS_NATIVE_ONLY" ]
630    cflags = [
631      "-fstrict-aliasing",
632      "-fPIC",
633
634      # ValueAsBitPattern in Unwind-EHABI.cpp is only used on Debug builds.
635      "-Wno-unused-function",
636
637      # libunwind expects to be compiled with unwind tables so it can
638      # unwind its own frames.
639      "-funwind-tables",
640    ]
641  }
642
643  source_set("libunwind") {
644    visibility = _buildtools_visibility
645    sources = [
646      # C++ sources
647      "libunwind/src/Unwind-EHABI.cpp",
648      "libunwind/src/libunwind.cpp",
649
650      # C sources
651      "libunwind/src/Unwind-sjlj.c",
652      "libunwind/src/UnwindLevel1-gcc-ext.c",
653      "libunwind/src/UnwindLevel1.c",
654
655      # ASM sources
656      "libunwind/src/UnwindRegistersRestore.S",
657      "libunwind/src/UnwindRegistersSave.S",
658    ]
659    include_dirs = [
660      "libunwind/include",
661      "libunwind/src",
662    ]
663    configs -= [
664      "//gn/standalone:extra_warnings",
665      "//gn/standalone:no_exceptions",
666      "//gn/standalone:no_rtti",
667
668      # When building with msan, libunwind itself triggers memory violations
669      # that causes msan to get stuck into an infinite loop. Just don't
670      # instrument libunwind itself.
671      "//gn/standalone/sanitizers:sanitizers_cflags",
672    ]
673    configs += [
674      "//gn/standalone/sanitizers:sanitizer_options_link_helper",
675
676      ":libunwind_config",
677    ]
678  }
679
680  # Config applied to both libc++ and libc++abi targets below.
681  config("libc++config") {
682    visibility = _buildtools_visibility
683    cflags = [ "-fstrict-aliasing" ]
684    if (is_win) {
685      cflags += [
686        # libc++ wants to redefine the macros WIN32_LEAN_AND_MEAN and
687        # _CRT_RAND_S in its implementation.
688        "-Wno-macro-redefined",
689      ]
690    } else {
691      cflags += [ "-fPIC" ]
692    }
693    configs = [ "//gn/standalone:c++20" ]
694    defines = [ "_LIBCPP_BUILDING_LIBRARY" ]
695  }
696
697  source_set("libc++abi") {
698    visibility = _buildtools_visibility
699
700    # Fuchsia builds don't link against any libraries that provide stack
701    # unwinding symbols, unlike Linux does with glibc (same applies for
702    # Android). Build and link against libunwind manually to get this
703    # functionality.
704    if (is_fuchsia || is_android) {
705      deps = [ ":libunwind" ]
706    }
707
708    sources = [
709      "libcxxabi/src/abort_message.cpp",
710      "libcxxabi/src/cxa_aux_runtime.cpp",
711      "libcxxabi/src/cxa_default_handlers.cpp",
712      "libcxxabi/src/cxa_exception.cpp",
713      "libcxxabi/src/cxa_exception_storage.cpp",
714      "libcxxabi/src/cxa_handlers.cpp",
715
716      # This file is supposed to be used in fno-exception builds of
717      # libc++abi.  We build lib++/libc++abi with exceptions enabled.
718      #"trunk/src/cxa_noexception.cpp",
719      "libcxxabi/src/cxa_personality.cpp",
720      "libcxxabi/src/cxa_vector.cpp",
721      "libcxxabi/src/cxa_virtual.cpp",
722      "libcxxabi/src/fallback_malloc.cpp",
723      "libcxxabi/src/private_typeinfo.cpp",
724      "libcxxabi/src/stdlib_exception.cpp",
725      "libcxxabi/src/stdlib_stdexcept.cpp",
726      "libcxxabi/src/stdlib_typeinfo.cpp",
727    ]
728
729    if (!is_tsan) {
730      sources += [ "libcxxabi/src/cxa_guard.cpp" ]
731    }
732
733    # See the comment in cxa_demangle_stub.cc for why we don't use LLVM's
734    # demangler on android.
735    sources += [ "libcxxabi/src/cxa_demangle.cpp" ]
736
737    if (is_fuchsia || is_android || is_linux) {
738      sources += [ "libcxxabi/src/cxa_thread_atexit.cpp" ]
739    }
740
741    defines = [
742      "LIBCXXABI_SILENT_TERMINATE",
743
744      # TODO(crbug.com/1298070) _LIBCPP_CONSTINIT is defined in a libc++
745      # revision more recent than the one currently used in Perfetto/Chrome.
746      "_LIBCPP_CONSTINIT=constinit",
747    ]
748
749    configs -= [
750      "//gn/standalone:extra_warnings",
751      "//gn/standalone:no_exceptions",
752      "//gn/standalone:no_rtti",
753      "//gn/standalone:c++17",
754    ]
755    configs += [
756      ":libc++config",
757      "//gn/standalone/sanitizers:sanitizer_options_link_helper",
758    ]
759    if (!custom_libcxx_is_static) {
760      configs -= [ "//gn/standalone:visibility_hidden" ]
761    }
762
763    # libc++abi depends on libc++ internals.
764    include_dirs = [ "libcxx/src" ]
765  }
766
767  # Explicitly set version macros to Windows 7 to prevent libc++ from adding a
768  # hard dependency on GetSystemTimePreciseAsFileTime, which was introduced in
769  # Windows 8.
770  config("libc++winver") {
771    defines = [
772      "NTDDI_VERSION=NTDDI_WIN7",
773      "_WIN32_WINNT=_WIN32_WINNT_WIN7",
774      "WINVER=_WIN32_WINNT_WIN7",
775    ]
776  }
777
778  if (custom_libcxx_is_static) {
779    libcxx_target_type = "source_set"
780  } else {
781    libcxx_target_type = "shared_library"
782  }
783
784  target(libcxx_target_type, "libc++") {
785    visibility = _buildtools_visibility
786    visibility += [ "../gn/standalone/libc++:*" ]
787
788    if (is_linux && !is_clang) {
789      libs = [ "atomic" ]
790    }
791
792    inputs = [
793      "libcxx_config/__assertion_handler",
794      "libcxx_config/__config_site",
795    ]
796
797    sources = [
798      "libcxx/src/algorithm.cpp",
799      "libcxx/src/any.cpp",
800      "libcxx/src/atomic.cpp",
801      "libcxx/src/barrier.cpp",
802      "libcxx/src/bind.cpp",
803      "libcxx/src/call_once.cpp",
804      "libcxx/src/charconv.cpp",
805      "libcxx/src/chrono.cpp",
806      "libcxx/src/condition_variable.cpp",
807      "libcxx/src/condition_variable_destructor.cpp",
808      "libcxx/src/error_category.cpp",
809      "libcxx/src/exception.cpp",
810      "libcxx/src/filesystem/directory_iterator.cpp",
811      "libcxx/src/filesystem/filesystem_error.cpp",
812      "libcxx/src/filesystem/operations.cpp",
813      "libcxx/src/filesystem/path.cpp",
814      "libcxx/src/functional.cpp",
815      "libcxx/src/future.cpp",
816      "libcxx/src/hash.cpp",
817      "libcxx/src/ios.cpp",
818      "libcxx/src/ios.instantiations.cpp",
819      "libcxx/src/iostream.cpp",
820      "libcxx/src/legacy_pointer_safety.cpp",
821      "libcxx/src/locale.cpp",
822      "libcxx/src/memory.cpp",
823      "libcxx/src/mutex.cpp",
824      "libcxx/src/mutex_destructor.cpp",
825      "libcxx/src/new_handler.cpp",
826      "libcxx/src/new_helpers.cpp",
827      "libcxx/src/optional.cpp",
828      "libcxx/src/random.cpp",
829      "libcxx/src/random_shuffle.cpp",
830      "libcxx/src/regex.cpp",
831      "libcxx/src/ryu/d2fixed.cpp",
832      "libcxx/src/ryu/d2s.cpp",
833      "libcxx/src/ryu/f2s.cpp",
834      "libcxx/src/shared_mutex.cpp",
835      "libcxx/src/stdexcept.cpp",
836      "libcxx/src/string.cpp",
837      "libcxx/src/strstream.cpp",
838      "libcxx/src/system_error.cpp",
839      "libcxx/src/thread.cpp",
840      "libcxx/src/typeinfo.cpp",
841      "libcxx/src/valarray.cpp",
842      "libcxx/src/variant.cpp",
843      "libcxx/src/vector.cpp",
844      "libcxx/src/verbose_abort.cpp",
845    ]
846    if (!using_sanitizer) {
847      # In {a,t,m}san configurations, operator new and operator delete will be
848      # provided by the sanitizer runtime library.  Since libc++ defines these
849      # symbols with weak linkage, and the *san runtime uses strong linkage, it
850      # should technically be OK to include this file, but it's removed to be
851      # explicit.
852      # We need using_sanitizer rather than is_asan || is_msan ... because in
853      # perfetto, when cross-compiling, we build only targets with sanitizers,
854      # but not host artifacts, and using_sanitizer is only true for the
855      # target toolchain, while is_asan is globally true on all toolchains.
856      sources += [ "libcxx/src/new.cpp" ]
857    }
858
859    include_dirs = [ "libcxx/src" ]
860    if (is_win) {
861      sources += [
862        "libcxx/src/support/win32/locale_win32.cpp",
863        "libcxx/src/support/win32/support.cpp",
864        "libcxx/src/support/win32/thread_win32.cpp",
865      ]
866      configs += [ ":libc++winver" ]
867    }
868    configs -= [
869      "//gn/standalone:extra_warnings",
870      "//gn/standalone:no_exceptions",
871      "//gn/standalone:no_rtti",
872      "//gn/standalone:c++17",
873    ]
874    if ((is_android || is_mac) && !custom_libcxx_is_static) {
875      # Use libc++_perfetto to avoid conflicting with system libc++
876      output_name = "libc++_perfettto"
877    }
878    configs += [
879      ":libc++config",
880      "//gn/standalone/sanitizers:sanitizer_options_link_helper",
881    ]
882    if (!custom_libcxx_is_static) {
883      configs -= [ "//gn/standalone:visibility_hidden" ]
884    }
885
886    defines = []
887    if (custom_libcxx_is_static) {
888      if (is_mac && is_clang) {
889        # We want operator new/delete to be private on Mac, but these functions
890        # are implicitly created by the compiler for each translation unit, as
891        # specified in the C++ spec 3.7.4p2, which makes them always have
892        # default visibility.  This option is needed to force hidden visibility
893        # since -fvisibility=hidden doesn't have the desired effect.
894        cflags = [ "-fvisibility-global-new-delete-hidden" ]
895      } else {
896        defines += [
897          # This resets the visibility to default only for the various
898          # flavors of operator new and operator delete.  These symbols
899          # are weak and get overriden by Chromium-provided ones, but if
900          # these symbols had hidden visibility, this would make the
901          # Chromium symbols hidden too because elf visibility rules
902          # require that linkers use the least visible form when merging,
903          # and if this is hidden, then when we merge it with tcmalloc's
904          # operator new, hidden visibility would win. However, tcmalloc
905          # needs a visible operator new to also override operator new
906          # references from system libraries.
907          # TODO(lld): Ask lld for a --force-public-visibility flag or
908          # similar to that overrides the default elf merging rules, and
909          # make tcmalloc's gn config pass that to all its dependencies,
910          # then remove this override here.
911          "_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))",
912        ]
913      }
914    }
915    if (!is_mac && using_sanitizer && (is_asan || is_tsan || is_msan)) {
916      # In {a,t,m}san configurations, operator new and operator delete will be
917      # provided by the sanitizer runtime library.  Since libc++ defines these
918      # symbols with weak linkage, and the *san runtime uses strong linkage, it
919      # should technically be OK to omit this, but it's added to be explicit.
920      defines += [ "_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS" ]
921    }
922
923    if (!is_win) {
924      defines += [ "LIBCXX_BUILDING_LIBCXXABI" ]
925      deps = [ ":libc++abi" ]
926    }
927  }
928}  # if (use_custom_libcxx)
929
930config("benchmark_config") {
931  visibility = _buildtools_visibility
932  include_dirs = [ "benchmark/include" ]
933  configs = [ ":test_warning_suppressions" ]
934}
935
936source_set("benchmark") {
937  visibility = _buildtools_visibility
938  testonly = true
939  sources = [
940    "benchmark/include/benchmark/benchmark.h",
941    "benchmark/src/arraysize.h",
942    "benchmark/src/benchmark.cc",
943    "benchmark/src/benchmark_api_internal.cc",
944    "benchmark/src/benchmark_api_internal.h",
945    "benchmark/src/benchmark_name.cc",
946    "benchmark/src/benchmark_register.cc",
947    "benchmark/src/benchmark_register.h",
948    "benchmark/src/benchmark_runner.cc",
949    "benchmark/src/benchmark_runner.h",
950    "benchmark/src/check.h",
951    "benchmark/src/colorprint.cc",
952    "benchmark/src/colorprint.h",
953    "benchmark/src/commandlineflags.cc",
954    "benchmark/src/commandlineflags.h",
955    "benchmark/src/complexity.cc",
956    "benchmark/src/complexity.h",
957    "benchmark/src/console_reporter.cc",
958    "benchmark/src/counter.cc",
959    "benchmark/src/counter.h",
960    "benchmark/src/csv_reporter.cc",
961    "benchmark/src/cycleclock.h",
962    "benchmark/src/internal_macros.h",
963    "benchmark/src/json_reporter.cc",
964    "benchmark/src/log.h",
965    "benchmark/src/mutex.h",
966    "benchmark/src/perf_counters.cc",
967    "benchmark/src/perf_counters.h",
968    "benchmark/src/re.h",
969    "benchmark/src/reporter.cc",
970    "benchmark/src/sleep.cc",
971    "benchmark/src/sleep.h",
972    "benchmark/src/statistics.cc",
973    "benchmark/src/statistics.h",
974    "benchmark/src/string_util.cc",
975    "benchmark/src/string_util.h",
976    "benchmark/src/sysinfo.cc",
977    "benchmark/src/thread_manager.h",
978    "benchmark/src/thread_timer.h",
979    "benchmark/src/timers.cc",
980    "benchmark/src/timers.h",
981  ]
982  defines = [ "HAVE_POSIX_REGEX" ]
983  public_configs = [ ":benchmark_config" ]
984  all_dependent_configs = [ ":benchmark_config" ]
985  if (!is_win) {
986    cflags = [ "-Wno-deprecated-declarations" ]
987  }
988  configs -= [ "//gn/standalone:extra_warnings" ]
989  deps = [ "//gn:default_deps" ]
990}
991
992# On Linux/Android use libbacktrace in debug builds for better stacktraces.
993if (is_linux || is_android) {
994  config("libbacktrace_config") {
995    visibility = _buildtools_visibility
996    include_dirs = [
997      "libbacktrace_config",
998      "libbacktrace",
999    ]
1000    cflags = [
1001      # We force include this config file because "config.h" is too generic as a
1002      # file name and on some platforms #include "config.h" ends up colliding
1003      # importing some other project's config.h.
1004      "-include",
1005      rebase_path("libbacktrace_config/config.h", root_build_dir),
1006    ]
1007  }
1008
1009  source_set("libbacktrace") {
1010    visibility = _buildtools_visibility
1011    sources = [
1012      "libbacktrace/dwarf.c",
1013      "libbacktrace/elf.c",
1014      "libbacktrace/fileline.c",
1015      "libbacktrace/mmap.c",
1016      "libbacktrace/mmapio.c",
1017      "libbacktrace/posix.c",
1018      "libbacktrace/sort.c",
1019      "libbacktrace/state.c",
1020    ]
1021    configs -= [ "//gn/standalone:extra_warnings" ]
1022    public_configs = [ ":libbacktrace_config" ]
1023    deps = [ "//gn:default_deps" ]
1024  }
1025}
1026
1027config("sqlite_config") {
1028  visibility = _buildtools_visibility
1029  include_dirs = [ "sqlite" ]
1030  cflags = [
1031    "-DSQLITE_THREADSAFE=0",
1032    "-DSQLITE_DEFAULT_MEMSTATUS=0",
1033    "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
1034    "-DSQLITE_OMIT_DEPRECATED",
1035    "-DSQLITE_OMIT_SHARED_CACHE",
1036    "-DHAVE_USLEEP",
1037    "-DHAVE_UTIME",
1038    "-DSQLITE_BYTEORDER=1234",
1039    "-DSQLITE_DEFAULT_AUTOVACUUM=0",
1040    "-DSQLITE_DEFAULT_MMAP_SIZE=0",
1041    "-DSQLITE_CORE",
1042    "-DSQLITE_TEMP_STORE=3",
1043    "-DSQLITE_OMIT_LOAD_EXTENSION",
1044    "-DSQLITE_OMIT_RANDOMNESS",
1045    "-DSQLITE_OMIT_AUTOINIT",
1046    "-DSQLITE_ENABLE_JSON1",
1047  ]
1048  if (is_clang && is_win) {
1049    # SQLite uses __int64 which clang complains about unless
1050    # we specify this flag.
1051    cflags += [ "-Wno-language-extension-token" ]
1052  }
1053}
1054
1055source_set("sqlite") {
1056  visibility = _buildtools_visibility
1057  if (perfetto_use_system_sqlite) {
1058    # Use the system sqlite library instead of the hermetic one.
1059    libs = [ "sqlite3" ]
1060  } else {
1061    sources = [
1062      "sqlite/sqlite3.c",
1063      "sqlite/sqlite3.h",
1064      "sqlite/sqlite3ext.h",
1065      "sqlite_src/ext/misc/percentile.c",
1066    ]
1067  }
1068  configs -= [ "//gn/standalone:extra_warnings" ]
1069  public_configs = [ ":sqlite_config" ]
1070  deps = [ "//gn:default_deps" ]
1071}
1072
1073source_set("lzma") {
1074  visibility = _buildtools_visibility
1075  defines = [ "_7ZIP_ST" ]
1076  sources = [
1077    "lzma/C/7zAlloc.c",
1078    "lzma/C/7zArcIn.c",
1079    "lzma/C/7zBuf.c",
1080    "lzma/C/7zBuf2.c",
1081    "lzma/C/7zCrc.c",
1082    "lzma/C/7zCrcOpt.c",
1083    "lzma/C/7zDec.c",
1084    "lzma/C/7zFile.c",
1085    "lzma/C/7zStream.c",
1086    "lzma/C/Aes.c",
1087    "lzma/C/AesOpt.c",
1088    "lzma/C/Alloc.c",
1089    "lzma/C/Bcj2.c",
1090    "lzma/C/Bra.c",
1091    "lzma/C/Bra86.c",
1092    "lzma/C/BraIA64.c",
1093    "lzma/C/CpuArch.c",
1094    "lzma/C/Delta.c",
1095    "lzma/C/LzFind.c",
1096    "lzma/C/Lzma2Dec.c",
1097    "lzma/C/Lzma2Enc.c",
1098    "lzma/C/Lzma86Dec.c",
1099    "lzma/C/Lzma86Enc.c",
1100    "lzma/C/LzmaDec.c",
1101    "lzma/C/LzmaEnc.c",
1102    "lzma/C/LzmaLib.c",
1103    "lzma/C/Ppmd7.c",
1104    "lzma/C/Ppmd7Dec.c",
1105    "lzma/C/Ppmd7Enc.c",
1106    "lzma/C/Sha256.c",
1107    "lzma/C/Sort.c",
1108    "lzma/C/Xz.c",
1109    "lzma/C/XzCrc64.c",
1110    "lzma/C/XzCrc64Opt.c",
1111    "lzma/C/XzDec.c",
1112    "lzma/C/XzEnc.c",
1113    "lzma/C/XzIn.c",
1114  ]
1115  configs -= [ "//gn/standalone:extra_warnings" ]
1116  cflags = [
1117    "-Wno-empty-body",
1118    "-Wno-enum-conversion",
1119  ]
1120  deps = [ "//gn:default_deps" ]
1121}
1122
1123source_set("zlib") {
1124  visibility = _buildtools_visibility
1125  sources = [
1126    "zlib/adler32.c",
1127    "zlib/chromeconf.h",
1128    "zlib/compress.c",
1129    "zlib/contrib/optimizations/insert_string.h",
1130    "zlib/cpu_features.c",
1131    "zlib/cpu_features.h",
1132    "zlib/crc32.c",
1133    "zlib/crc32.h",
1134    "zlib/deflate.c",
1135    "zlib/deflate.h",
1136    "zlib/gzclose.c",
1137    "zlib/gzguts.h",
1138    "zlib/gzlib.c",
1139    "zlib/gzread.c",
1140    "zlib/gzwrite.c",
1141    "zlib/infback.c",
1142    "zlib/inffast.c",
1143    "zlib/inffast.h",
1144    "zlib/inffixed.h",
1145    "zlib/inflate.c",
1146    "zlib/inflate.h",
1147    "zlib/inftrees.c",
1148    "zlib/inftrees.h",
1149    "zlib/trees.c",
1150    "zlib/trees.h",
1151    "zlib/uncompr.c",
1152    "zlib/zconf.h",
1153    "zlib/zlib.h",
1154    "zlib/zutil.c",
1155    "zlib/zutil.h",
1156  ]
1157  configs -= [ "//gn/standalone:extra_warnings" ]
1158  public_configs = [ ":zlib_config" ]
1159  deps = [ "//gn:default_deps" ]
1160
1161  if (is_win) {
1162    defines = [ "X86_WINDOWS" ]
1163  }
1164
1165  # TODO(primiano): look into ADLER32_SIMD_SSSE3 and other SIMD optimizations
1166  # (from chromium's third_party/zlib/BUILD.gn).
1167}
1168
1169config("zlib_config") {
1170  visibility = _buildtools_visibility
1171  defines = [
1172    "ZLIB_IMPLEMENTATION",
1173    "CHROMIUM_ZLIB_NO_CHROMECONF",
1174  ]
1175  cflags = [
1176    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
1177    # warnings coming from third-party headers. Doing so would mask warnings in
1178    # our own code.
1179    perfetto_isystem_cflag,
1180    rebase_path("zlib", root_build_dir),
1181  ]
1182  if (is_clang) {
1183    cflags += [
1184      "-Wno-unknown-warning-option",
1185      "-Wno-deprecated-non-prototype",
1186    ]
1187  }
1188}
1189
1190source_set("zstd") {
1191  visibility = _buildtools_visibility
1192  sources = [
1193    "zstd/lib/common/allocations.h",
1194    "zstd/lib/common/bits.h",
1195    "zstd/lib/common/bitstream.h",
1196    "zstd/lib/common/compiler.h",
1197    "zstd/lib/common/cpu.h",
1198    "zstd/lib/common/debug.c",
1199    "zstd/lib/common/debug.h",
1200    "zstd/lib/common/entropy_common.c",
1201    "zstd/lib/common/error_private.c",
1202    "zstd/lib/common/error_private.h",
1203    "zstd/lib/common/fse.h",
1204    "zstd/lib/common/fse_decompress.c",
1205    "zstd/lib/common/huf.h",
1206    "zstd/lib/common/mem.h",
1207    "zstd/lib/common/pool.c",
1208    "zstd/lib/common/pool.h",
1209    "zstd/lib/common/portability_macros.h",
1210    "zstd/lib/common/threading.c",
1211    "zstd/lib/common/threading.h",
1212    "zstd/lib/common/xxhash.c",
1213    "zstd/lib/common/xxhash.h",
1214    "zstd/lib/common/zstd_common.c",
1215    "zstd/lib/common/zstd_deps.h",
1216    "zstd/lib/common/zstd_internal.h",
1217    "zstd/lib/common/zstd_trace.h",
1218    "zstd/lib/compress/clevels.h",
1219    "zstd/lib/compress/fse_compress.c",
1220    "zstd/lib/compress/hist.c",
1221    "zstd/lib/compress/hist.h",
1222    "zstd/lib/compress/huf_compress.c",
1223    "zstd/lib/compress/zstd_compress.c",
1224    "zstd/lib/compress/zstd_compress_internal.h",
1225    "zstd/lib/compress/zstd_compress_literals.c",
1226    "zstd/lib/compress/zstd_compress_literals.h",
1227    "zstd/lib/compress/zstd_compress_sequences.c",
1228    "zstd/lib/compress/zstd_compress_sequences.h",
1229    "zstd/lib/compress/zstd_compress_superblock.c",
1230    "zstd/lib/compress/zstd_compress_superblock.h",
1231    "zstd/lib/compress/zstd_cwksp.h",
1232    "zstd/lib/compress/zstd_double_fast.c",
1233    "zstd/lib/compress/zstd_double_fast.h",
1234    "zstd/lib/compress/zstd_fast.c",
1235    "zstd/lib/compress/zstd_fast.h",
1236    "zstd/lib/compress/zstd_lazy.c",
1237    "zstd/lib/compress/zstd_lazy.h",
1238    "zstd/lib/compress/zstd_ldm.c",
1239    "zstd/lib/compress/zstd_ldm.h",
1240    "zstd/lib/compress/zstd_ldm_geartab.h",
1241    "zstd/lib/compress/zstd_opt.c",
1242    "zstd/lib/compress/zstd_opt.h",
1243    "zstd/lib/compress/zstdmt_compress.c",
1244    "zstd/lib/compress/zstdmt_compress.h",
1245    "zstd/lib/decompress/huf_decompress.c",
1246    "zstd/lib/decompress/zstd_ddict.c",
1247    "zstd/lib/decompress/zstd_ddict.h",
1248    "zstd/lib/decompress/zstd_decompress.c",
1249    "zstd/lib/decompress/zstd_decompress_block.c",
1250    "zstd/lib/decompress/zstd_decompress_block.h",
1251    "zstd/lib/decompress/zstd_decompress_internal.h",
1252    "zstd/lib/deprecated/zbuff.h",
1253    "zstd/lib/deprecated/zbuff_common.c",
1254    "zstd/lib/deprecated/zbuff_compress.c",
1255    "zstd/lib/deprecated/zbuff_decompress.c",
1256    "zstd/lib/dictBuilder/cover.c",
1257    "zstd/lib/dictBuilder/cover.h",
1258    "zstd/lib/dictBuilder/divsufsort.c",
1259    "zstd/lib/dictBuilder/divsufsort.h",
1260    "zstd/lib/dictBuilder/fastcover.c",
1261    "zstd/lib/dictBuilder/zdict.c",
1262    "zstd/lib/zdict.h",
1263    "zstd/lib/zstd.h",
1264    "zstd/lib/zstd_errors.h",
1265  ]
1266  configs -= [ "//gn/standalone:extra_warnings" ]
1267  public_configs = [ ":zstd_config" ]
1268  deps = [ "//gn:default_deps" ]
1269}
1270
1271config("zstd_config") {
1272  visibility = _buildtools_visibility
1273  cflags = [
1274    perfetto_isystem_cflag,
1275    rebase_path("zstd", root_build_dir),
1276  ]
1277  if (current_cpu == "x64") {
1278    defines = [ "ZSTD_DISABLE_ASM" ]
1279  }
1280}
1281
1282# For standalone profiler builds.
1283source_set("libunwindstack") {
1284  visibility = _buildtools_visibility
1285  include_dirs = [
1286    "android-unwinding/libunwindstack/include",
1287    "android-unwinding/libunwindstack",
1288    "android-libbase/include",
1289    "android-logging/liblog/include",
1290    "android-libprocinfo/include",
1291    "android-core/include",
1292    "android-core/libcutils/include",
1293    "bionic/libc/async_safe/include",
1294    "bionic/libc/platform/",
1295    "lzma/C",
1296    "zstd/lib",
1297  ]
1298  deps = [
1299    ":lzma",
1300    ":zlib",
1301    ":zstd",
1302    "//gn:default_deps",
1303  ]
1304  sources = [
1305    "android-libbase/file.cpp",
1306    "android-libbase/stringprintf.cpp",
1307    "android-libbase/strings.cpp",
1308    "android-unwinding/libunwindstack/ArmExidx.cpp",
1309    "android-unwinding/libunwindstack/Demangle.cpp",
1310    "android-unwinding/libunwindstack/DwarfCfa.cpp",
1311    "android-unwinding/libunwindstack/DwarfEhFrameWithHdr.cpp",
1312    "android-unwinding/libunwindstack/DwarfMemory.cpp",
1313    "android-unwinding/libunwindstack/DwarfOp.cpp",
1314    "android-unwinding/libunwindstack/DwarfSection.cpp",
1315    "android-unwinding/libunwindstack/Elf.cpp",
1316    "android-unwinding/libunwindstack/ElfInterface.cpp",
1317    "android-unwinding/libunwindstack/ElfInterfaceArm.cpp",
1318    "android-unwinding/libunwindstack/Global.cpp",
1319    "android-unwinding/libunwindstack/JitDebug.cpp",
1320    "android-unwinding/libunwindstack/MapInfo.cpp",
1321    "android-unwinding/libunwindstack/Maps.cpp",
1322    "android-unwinding/libunwindstack/Memory.cpp",
1323    "android-unwinding/libunwindstack/MemoryXz.cpp",
1324    "android-unwinding/libunwindstack/Regs.cpp",
1325    "android-unwinding/libunwindstack/RegsArm.cpp",
1326    "android-unwinding/libunwindstack/RegsArm64.cpp",
1327    "android-unwinding/libunwindstack/RegsRiscv64.cpp",
1328    "android-unwinding/libunwindstack/RegsX86.cpp",
1329    "android-unwinding/libunwindstack/RegsX86_64.cpp",
1330    "android-unwinding/libunwindstack/Symbols.cpp",
1331    "android-unwinding/libunwindstack/Unwinder.cpp",
1332  ]
1333  if (!is_android) {
1334    sources += [
1335      "android-libbase/liblog_symbols.cpp",
1336      "android-libbase/logging.cpp",
1337      "android-libbase/threads.cpp",
1338      "android-logging/liblog/logger_write.cpp",
1339      "android-logging/liblog/properties.cpp",
1340      "android-unwinding/libunwindstack/LogStdout.cpp",
1341      "android-unwinding/libunwindstack/MemoryMte.cpp",
1342    ]
1343  } else {
1344    sources += [ "android-unwinding/libunwindstack/LogAndroid.cpp" ]
1345  }
1346  if (current_cpu == "x86") {
1347    sources += [ "android-unwinding/libunwindstack/AsmGetRegsX86.S" ]
1348  } else if (current_cpu == "x64") {
1349    sources += [ "android-unwinding/libunwindstack/AsmGetRegsX86_64.S" ]
1350  }
1351  configs -= [
1352    "//gn/standalone:extra_warnings",
1353    "//gn/standalone:visibility_hidden",
1354  ]
1355  cflags = [ "-DFAKE_LOG_DEVICE=1" ]
1356  if (!is_win) {
1357    cflags += [
1358      "-Wno-deprecated-declarations",
1359      "-Wno-vla-cxx-extension",
1360      "-Wno-c99-designator",
1361    ]
1362  }
1363  public_configs = [ ":libunwindstack_config" ]
1364}
1365
1366config("bionic_kernel_uapi_headers") {
1367  visibility = _buildtools_visibility
1368  cflags = [
1369    perfetto_isystem_cflag,
1370    rebase_path("bionic/libc/kernel", root_build_dir),
1371  ]
1372}
1373
1374config("jsoncpp_config") {
1375  visibility = _buildtools_visibility
1376  cflags = [ "-DJSON_USE_EXCEPTION=0" ]
1377  cflags += [
1378    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
1379    # warnings coming from third-party headers. Doing so would mask warnings in
1380    # our own code.
1381    perfetto_isystem_cflag,
1382    rebase_path("jsoncpp/include", root_build_dir),
1383  ]
1384  if (!is_win) {
1385    cflags += [ "-Wno-deprecated-declarations" ]
1386  }
1387  if (is_clang && is_win) {
1388    # JSON uses __int64 which clang complains about unless we specify this flag.
1389    cflags += [ "-Wno-language-extension-token" ]
1390  }
1391}
1392
1393source_set("jsoncpp") {
1394  visibility = _buildtools_visibility
1395  sources = [
1396    "jsoncpp/src/lib_json/json_reader.cpp",
1397    "jsoncpp/src/lib_json/json_value.cpp",
1398    "jsoncpp/src/lib_json/json_writer.cpp",
1399  ]
1400  configs -= [ "//gn/standalone:extra_warnings" ]
1401  public_configs = [ ":jsoncpp_config" ]
1402  deps = [ "//gn:default_deps" ]
1403}
1404
1405config("no_format_warning") {
1406  cflags = [ "-Wno-format" ]
1407}
1408
1409if (enable_perfetto_trace_processor_mac_instruments) {
1410  config("expat_public_config") {
1411    defines = [ "XML_STATIC" ]
1412    cflags = [
1413      # Using -isystem instead of include_dirs (-I), so we don't need to
1414      # suppress warnings coming from third-party headers. Doing so would mask
1415      # warnings in our own code.
1416      perfetto_isystem_cflag,
1417      rebase_path("expat/src/expat/lib", root_build_dir),
1418      perfetto_isystem_cflag,
1419      rebase_path("expat/include", root_build_dir),
1420    ]
1421  }
1422
1423  source_set("expat") {
1424    sources = [
1425      "expat/src/expat/lib/expat.h",
1426      "expat/src/expat/lib/xmlparse.c",
1427      "expat/src/expat/lib/xmlrole.c",
1428      "expat/src/expat/lib/xmltok.c",
1429    ]
1430
1431    public_configs = [ ":expat_public_config" ]
1432    configs -= [ "//gn/standalone:extra_warnings" ]
1433    configs += [ ":no_format_warning" ]
1434
1435    defines = [
1436      "_LIB",
1437      "HAVE_EXPAT_CONFIG_H",
1438    ]
1439  }
1440}
1441
1442config("linenoise_config") {
1443  visibility = _buildtools_visibility
1444  cflags = [
1445    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
1446    # warnings coming from third-party headers. Doing so would mask warnings in
1447    # our own code.
1448    perfetto_isystem_cflag,
1449    rebase_path("linenoise", root_build_dir),
1450  ]
1451}
1452
1453source_set("linenoise") {
1454  visibility = _buildtools_visibility
1455  sources = [
1456    "linenoise/linenoise.c",
1457    "linenoise/linenoise.h",
1458  ]
1459  configs -= [ "//gn/standalone:extra_warnings" ]
1460  public_configs = [ ":linenoise_config" ]
1461  cflags = [ "-Wno-tautological-unsigned-zero-compare" ]
1462  deps = [ "//gn:default_deps" ]
1463}
1464
1465if (use_libfuzzer) {
1466  source_set("libfuzzer") {
1467    visibility = _buildtools_visibility
1468    configs -= [
1469      "//gn/standalone:extra_warnings",
1470      "//gn/standalone/sanitizers:sanitizers_cflags",
1471    ]
1472    sources = [
1473      "libfuzzer/FuzzerCrossOver.cpp",
1474      "libfuzzer/FuzzerDataFlowTrace.cpp",
1475      "libfuzzer/FuzzerDriver.cpp",
1476      "libfuzzer/FuzzerExtFunctionsDlsym.cpp",
1477      "libfuzzer/FuzzerExtFunctionsWeak.cpp",
1478      "libfuzzer/FuzzerExtFunctionsWindows.cpp",
1479      "libfuzzer/FuzzerExtraCounters.cpp",
1480      "libfuzzer/FuzzerFork.cpp",
1481      "libfuzzer/FuzzerIO.cpp",
1482      "libfuzzer/FuzzerIOPosix.cpp",
1483      "libfuzzer/FuzzerIOWindows.cpp",
1484      "libfuzzer/FuzzerLoop.cpp",
1485      "libfuzzer/FuzzerMain.cpp",
1486      "libfuzzer/FuzzerMerge.cpp",
1487      "libfuzzer/FuzzerMutate.cpp",
1488      "libfuzzer/FuzzerSHA1.cpp",
1489      "libfuzzer/FuzzerTracePC.cpp",
1490      "libfuzzer/FuzzerUtil.cpp",
1491      "libfuzzer/FuzzerUtilDarwin.cpp",
1492      "libfuzzer/FuzzerUtilFuchsia.cpp",
1493      "libfuzzer/FuzzerUtilLinux.cpp",
1494      "libfuzzer/FuzzerUtilPosix.cpp",
1495      "libfuzzer/FuzzerUtilWindows.cpp",
1496    ]
1497    deps = [ "//gn:default_deps" ]
1498  }
1499}
1500
1501config("llvm_demangle_config") {
1502  visibility = _buildtools_visibility
1503  include_dirs = [ "llvm-project/llvm/include" ]
1504}
1505
1506source_set("llvm_demangle") {
1507  visibility = _buildtools_visibility
1508  configs -= [ "//gn/standalone:extra_warnings" ]
1509  public_configs = [ ":llvm_demangle_config" ]
1510  sources = [
1511    "llvm-project/llvm/include/llvm/Demangle/Demangle.h",
1512    "llvm-project/llvm/include/llvm/Demangle/DemangleConfig.h",
1513    "llvm-project/llvm/include/llvm/Demangle/ItaniumDemangle.h",
1514    "llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangle.h",
1515    "llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h",
1516    "llvm-project/llvm/include/llvm/Demangle/StringViewExtras.h",
1517    "llvm-project/llvm/include/llvm/Demangle/Utility.h",
1518    "llvm-project/llvm/lib/Demangle/DLangDemangle.cpp",
1519    "llvm-project/llvm/lib/Demangle/Demangle.cpp",
1520    "llvm-project/llvm/lib/Demangle/ItaniumDemangle.cpp",
1521    "llvm-project/llvm/lib/Demangle/MicrosoftDemangle.cpp",
1522    "llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp",
1523    "llvm-project/llvm/lib/Demangle/RustDemangle.cpp",
1524  ]
1525  deps = [ "//gn:default_deps" ]
1526}
1527
1528if (enable_perfetto_grpc) {
1529  config("grpc_absl_config") {
1530    visibility = _buildtools_visibility
1531    include_dirs = [ "grpc/src/third_party/abseil-cpp" ]
1532    cflags = [
1533      "-Wno-deprecated-builtins",
1534      "-Wno-deprecated-pragma",
1535    ]
1536  }
1537
1538  config("grpc_boringssl_config") {
1539    visibility = _buildtools_visibility
1540    include_dirs = [ "grpc/src/third_party/boringssl-with-bazel/src/include" ]
1541    if (is_gcc) {
1542      cflags = [ "-Wno-stringop-overflow" ]
1543    }
1544  }
1545
1546  config("grpc_upb_config") {
1547    visibility = _buildtools_visibility
1548    include_dirs = [
1549      "grpc/src/third_party/upb",
1550      "grpc/src/src/core/ext/upb-generated",
1551      "grpc/src/src/core/ext/upbdefs-generated",
1552    ]
1553  }
1554
1555  config("grpc_re2_config") {
1556    visibility = _buildtools_visibility
1557    include_dirs = [ "grpc/src/third_party/re2" ]
1558  }
1559
1560  config("grpc_internal_config") {
1561    visibility = _buildtools_visibility
1562    include_dirs = [
1563      "grpc/protobuf_include",
1564      "grpc/src",
1565      "grpc/src/include",
1566      "grpc/src/src/core/ext/upb-gen",
1567      "grpc/src/src/core/ext/upbdefs-gen",
1568      "grpc/src/third_party/abseil-cpp",
1569      "grpc/src/third_party/address_sorting/include",
1570      "grpc/src/third_party/re2",
1571      "grpc/src/third_party/upb",
1572      "grpc/src/third_party/utf8_range",
1573      "grpc/src/third_party/xxhash",
1574    ]
1575    cflags = [ "-DGRPC_ARES=0" ]
1576    if (is_gcc) {
1577      cflags += [
1578        "-Wno-attributes",
1579        "-Wno-return-type",
1580      ]
1581    }
1582  }
1583
1584  config("grpc_gen_config") {
1585    cflags = [
1586      # Using -isystem instead of include_dirs (-I), so we don't need to
1587      # suppress warnings coming from libprotobuf headers. Doing so would mask
1588      # warnings in our own code.
1589      perfetto_isystem_cflag,
1590      rebase_path("grpc/src/include", root_build_dir),
1591      perfetto_isystem_cflag,
1592      rebase_path("grpc/src/third_party/abseil-cpp", root_build_dir),
1593    ]
1594
1595    # This issues appear in .grpc.pb.h files so we unfortunately need to leak
1596    # the cflags outside of just compiling this code.
1597    if (is_clang && !is_win) {
1598      cflags += [
1599        "-Wno-weak-vtables",
1600        "-Wno-suggest-destructor-override",
1601      ]
1602    }
1603  }
1604
1605  config("grpc_public_config") {
1606    visibility = _buildtools_visibility
1607    cflags = [
1608      perfetto_isystem_cflag,
1609      rebase_path("grpc/src/include", root_build_dir),
1610    ]
1611  }
1612  config("cpp_httplib_config") {
1613    visibility = _buildtools_visibility
1614    cflags = [
1615      perfetto_isystem_cflag,
1616      rebase_path("cpp-httplib", root_build_dir),
1617    ]
1618  }
1619
1620  source_set("cpp_httplib") {
1621    visibility = _buildtools_visibility
1622    sources = [ "cpp-httplib/httplib.h" ]
1623    public_configs = [ ":cpp_httplib_config" ]
1624    deps = [ "//gn:default_deps" ]
1625  }
1626}
1627
1628if (enable_perfetto_etm_importer) {
1629  config("open_csd_config") {
1630    visibility = _buildtools_visibility
1631    cflags = [
1632      # Using -isystem instead of include_dirs (-I), so we don't need to
1633      # suppress warnings coming from third-party headers. Doing so would mask
1634      # warnings in our own code.
1635      perfetto_isystem_cflag,
1636      rebase_path("open_csd/decoder/include", root_build_dir),
1637    ]
1638    defines = [ "ENABLE_LARGE_TRACE_SOURCES" ]
1639  }
1640
1641  source_set("open_csd") {
1642    visibility = _buildtools_visibility
1643    sources = [
1644      "open_csd/decoder/source/c_api/ocsd_c_api.cpp",
1645      "open_csd/decoder/source/c_api/ocsd_c_api_custom_obj.cpp",
1646      "open_csd/decoder/source/c_api/ocsd_c_api_custom_obj.h",
1647      "open_csd/decoder/source/c_api/ocsd_c_api_obj.h",
1648      "open_csd/decoder/source/ete/trc_cmp_cfg_ete.cpp",
1649      "open_csd/decoder/source/etmv3/trc_cmp_cfg_etmv3.cpp",
1650      "open_csd/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp",
1651      "open_csd/decoder/source/etmv3/trc_pkt_elem_etmv3.cpp",
1652      "open_csd/decoder/source/etmv3/trc_pkt_proc_etmv3.cpp",
1653      "open_csd/decoder/source/etmv3/trc_pkt_proc_etmv3_impl.cpp",
1654      "open_csd/decoder/source/etmv3/trc_pkt_proc_etmv3_impl.h",
1655      "open_csd/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp",
1656      "open_csd/decoder/source/etmv4/trc_etmv4_stack_elem.cpp",
1657      "open_csd/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp",
1658      "open_csd/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp",
1659      "open_csd/decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp",
1660      "open_csd/decoder/source/i_dec/trc_i_decode.cpp",
1661      "open_csd/decoder/source/i_dec/trc_idec_arminst.cpp",
1662      "open_csd/decoder/source/mem_acc/trc_mem_acc_base.cpp",
1663      "open_csd/decoder/source/mem_acc/trc_mem_acc_bufptr.cpp",
1664      "open_csd/decoder/source/mem_acc/trc_mem_acc_cache.cpp",
1665      "open_csd/decoder/source/mem_acc/trc_mem_acc_cb.cpp",
1666      "open_csd/decoder/source/mem_acc/trc_mem_acc_file.cpp",
1667      "open_csd/decoder/source/mem_acc/trc_mem_acc_mapper.cpp",
1668      "open_csd/decoder/source/ocsd_code_follower.cpp",
1669      "open_csd/decoder/source/ocsd_dcd_tree.cpp",
1670      "open_csd/decoder/source/ocsd_error.cpp",
1671      "open_csd/decoder/source/ocsd_error_logger.cpp",
1672      "open_csd/decoder/source/ocsd_gen_elem_list.cpp",
1673      "open_csd/decoder/source/ocsd_gen_elem_stack.cpp",
1674      "open_csd/decoder/source/ocsd_lib_dcd_register.cpp",
1675      "open_csd/decoder/source/ocsd_msg_logger.cpp",
1676      "open_csd/decoder/source/ocsd_version.cpp",
1677      "open_csd/decoder/source/pkt_printers/gen_elem_printer.cpp",
1678      "open_csd/decoder/source/pkt_printers/raw_frame_printer.cpp",
1679      "open_csd/decoder/source/pkt_printers/trc_print_fact.cpp",
1680      "open_csd/decoder/source/ptm/trc_cmp_cfg_ptm.cpp",
1681      "open_csd/decoder/source/ptm/trc_pkt_decode_ptm.cpp",
1682      "open_csd/decoder/source/ptm/trc_pkt_elem_ptm.cpp",
1683      "open_csd/decoder/source/ptm/trc_pkt_proc_ptm.cpp",
1684      "open_csd/decoder/source/stm/trc_pkt_decode_stm.cpp",
1685      "open_csd/decoder/source/stm/trc_pkt_elem_stm.cpp",
1686      "open_csd/decoder/source/stm/trc_pkt_proc_stm.cpp",
1687      "open_csd/decoder/source/trc_component.cpp",
1688      "open_csd/decoder/source/trc_core_arch_map.cpp",
1689      "open_csd/decoder/source/trc_frame_deformatter.cpp",
1690      "open_csd/decoder/source/trc_frame_deformatter_impl.h",
1691      "open_csd/decoder/source/trc_gen_elem.cpp",
1692      "open_csd/decoder/source/trc_printable_elem.cpp",
1693      "open_csd/decoder/source/trc_ret_stack.cpp",
1694    ]
1695
1696    cflags = [
1697      "-Wno-switch",
1698      "-Wno-deprecated-declarations",
1699    ]
1700
1701    configs -= [
1702      "//gn/standalone:extra_warnings",
1703      "//gn/standalone:no_exceptions",
1704      "//gn/standalone:no_rtti",
1705    ]
1706    include_dirs = [ "open_csd/decoder/include" ]
1707    public_configs = [ ":open_csd_config" ]
1708  }
1709}
1710