• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    ]
59  }
60}
61
62config("libunwindstack_config") {
63  visibility = _buildtools_visibility
64  cflags = [
65    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
66    # warnings coming from libunwindstack headers. Doing so would mask warnings
67    # in our own code.
68    perfetto_isystem_cflag,
69    rebase_path("android-unwinding/libunwindstack/include", root_build_dir),
70    perfetto_isystem_cflag,
71    rebase_path("android-libprocinfo/include", root_build_dir),
72    perfetto_isystem_cflag,
73    rebase_path("android-libbase/include", root_build_dir),
74    perfetto_isystem_cflag,
75    rebase_path("android-core/demangle/include", root_build_dir),
76  ]
77  if (is_android) {
78    cflags += [
79      perfetto_isystem_cflag,
80      rebase_path("bionic/libc/include", root_build_dir),
81    ]
82  }
83  defines = [ "NO_LIBDEXFILE_SUPPORT" ]
84}
85
86# Config to include gtest.h in test targets.
87config("googletest_config") {
88  visibility = _buildtools_visibility
89  defines = [ "GTEST_LANG_CXX11=1" ]
90  include_dirs = [
91    "googletest/googletest/include",
92    "googletest/googlemock/include",
93  ]
94  configs = [ ":test_warning_suppressions" ]
95}
96
97source_set("gtest") {
98  visibility = _buildtools_visibility
99  testonly = true
100  include_dirs = [ "googletest/googletest" ]
101  configs -= [ "//gn/standalone:extra_warnings" ]
102  public_configs = [ ":googletest_config" ]
103  all_dependent_configs = [ ":googletest_config" ]
104  sources = [ "googletest/googletest/src/gtest-all.cc" ]
105  deps = [ "//gn:default_deps" ]
106}
107
108source_set("gtest_main") {
109  visibility = _buildtools_visibility
110  testonly = true
111  configs -= [ "//gn/standalone:extra_warnings" ]
112  configs += [ ":googletest_config" ]
113  sources = [ "googletest/googletest/src/gtest_main.cc" ]
114  deps = [ "//gn:default_deps" ]
115}
116
117source_set("gmock") {
118  visibility = _buildtools_visibility
119  testonly = true
120  include_dirs = [ "googletest/googlemock" ]
121  configs -= [ "//gn/standalone:extra_warnings" ]
122  public_configs = [ ":googletest_config" ]
123  all_dependent_configs = [ ":googletest_config" ]
124  sources = [ "googletest/googlemock/src/gmock-all.cc" ]
125  deps = [ "//gn:default_deps" ]
126}
127
128# Configuration used to build libprotobuf_* and the protoc compiler.
129config("protobuf_config") {
130  visibility = _buildtools_visibility
131
132  # Apply the lighter supressions and macro definitions from above.
133  configs = [ "//gn:protobuf_gen_config" ]
134
135  defines = [ "HAVE_PTHREAD=1" ]
136  cflags = []
137  if (is_clang) {
138    # We do NOT build libprotobuf with -Wextra or -Weverything. But still it
139    # hits some warnings that we need to suppress.
140    cflags += [
141      "-Wno-unknown-warning-option",
142      "-Wno-enum-compare-switch",
143      "-Wno-user-defined-warnings",
144      "-Wno-tautological-constant-compare",
145      "-Wno-inconsistent-missing-override",
146    ]
147  } else if (!is_win) {  # implies gcc
148    cflags += [ "-Wno-return-type" ]
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  }
162}
163
164source_set("protobuf_lite") {
165  visibility = _buildtools_visibility
166  sources = [
167    "protobuf/src/google/protobuf/any_lite.cc",
168    "protobuf/src/google/protobuf/arena.cc",
169    "protobuf/src/google/protobuf/arena.h",
170    "protobuf/src/google/protobuf/arena_impl.h",
171    "protobuf/src/google/protobuf/arenastring.h",
172    "protobuf/src/google/protobuf/extension_set.cc",
173    "protobuf/src/google/protobuf/extension_set.h",
174    "protobuf/src/google/protobuf/generated_enum_util.cc",
175    "protobuf/src/google/protobuf/generated_enum_util.h",
176    "protobuf/src/google/protobuf/generated_message_table_driven_lite.cc",
177    "protobuf/src/google/protobuf/generated_message_table_driven_lite.h",
178    "protobuf/src/google/protobuf/generated_message_util.cc",
179    "protobuf/src/google/protobuf/generated_message_util.h",
180    "protobuf/src/google/protobuf/has_bits.h",
181    "protobuf/src/google/protobuf/implicit_weak_message.cc",
182    "protobuf/src/google/protobuf/implicit_weak_message.h",
183    "protobuf/src/google/protobuf/inlined_string_field.h",
184    "protobuf/src/google/protobuf/io/coded_stream.cc",
185    "protobuf/src/google/protobuf/io/coded_stream.h",
186    "protobuf/src/google/protobuf/io/coded_stream_inl.h",
187    "protobuf/src/google/protobuf/io/io_win32.cc",
188    "protobuf/src/google/protobuf/io/io_win32.h",
189    "protobuf/src/google/protobuf/io/strtod.cc",
190    "protobuf/src/google/protobuf/io/strtod.h",
191    "protobuf/src/google/protobuf/io/zero_copy_stream.cc",
192    "protobuf/src/google/protobuf/io/zero_copy_stream.h",
193    "protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc",
194    "protobuf/src/google/protobuf/io/zero_copy_stream_impl.h",
195    "protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
196    "protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h",
197    "protobuf/src/google/protobuf/map.h",
198    "protobuf/src/google/protobuf/map_entry_lite.h",
199    "protobuf/src/google/protobuf/map_field_lite.h",
200    "protobuf/src/google/protobuf/map_type_handler.h",
201    "protobuf/src/google/protobuf/message_lite.cc",
202    "protobuf/src/google/protobuf/message_lite.h",
203    "protobuf/src/google/protobuf/repeated_field.cc",
204    "protobuf/src/google/protobuf/repeated_field.h",
205    "protobuf/src/google/protobuf/stubs/bytestream.cc",
206    "protobuf/src/google/protobuf/stubs/bytestream.h",
207    "protobuf/src/google/protobuf/stubs/callback.h",
208    "protobuf/src/google/protobuf/stubs/casts.h",
209    "protobuf/src/google/protobuf/stubs/common.cc",
210    "protobuf/src/google/protobuf/stubs/common.h",
211    "protobuf/src/google/protobuf/stubs/fastmem.h",
212    "protobuf/src/google/protobuf/stubs/hash.h",
213    "protobuf/src/google/protobuf/stubs/int128.cc",
214    "protobuf/src/google/protobuf/stubs/int128.h",
215    "protobuf/src/google/protobuf/stubs/logging.h",
216    "protobuf/src/google/protobuf/stubs/macros.h",
217    "protobuf/src/google/protobuf/stubs/map_util.h",
218    "protobuf/src/google/protobuf/stubs/mutex.h",
219    "protobuf/src/google/protobuf/stubs/once.h",
220    "protobuf/src/google/protobuf/stubs/platform_macros.h",
221    "protobuf/src/google/protobuf/stubs/port.h",
222    "protobuf/src/google/protobuf/stubs/status.cc",
223    "protobuf/src/google/protobuf/stubs/status.h",
224    "protobuf/src/google/protobuf/stubs/status_macros.h",
225    "protobuf/src/google/protobuf/stubs/statusor.cc",
226    "protobuf/src/google/protobuf/stubs/statusor.h",
227    "protobuf/src/google/protobuf/stubs/stl_util.h",
228    "protobuf/src/google/protobuf/stubs/stringpiece.cc",
229    "protobuf/src/google/protobuf/stubs/stringpiece.h",
230    "protobuf/src/google/protobuf/stubs/stringprintf.cc",
231    "protobuf/src/google/protobuf/stubs/stringprintf.h",
232    "protobuf/src/google/protobuf/stubs/structurally_valid.cc",
233    "protobuf/src/google/protobuf/stubs/strutil.cc",
234    "protobuf/src/google/protobuf/stubs/strutil.h",
235    "protobuf/src/google/protobuf/stubs/template_util.h",
236    "protobuf/src/google/protobuf/stubs/time.cc",
237    "protobuf/src/google/protobuf/stubs/time.h",
238    "protobuf/src/google/protobuf/wire_format_lite.cc",
239    "protobuf/src/google/protobuf/wire_format_lite.h",
240  ]
241  configs -= [ "//gn/standalone:extra_warnings" ]
242  if (is_win) {
243    # Protobuf has its own #define WIN32_LEAN_AND_MEAN.
244    configs -= [ "//gn/standalone:win32_lean_and_mean" ]
245  }
246  configs += [ ":protobuf_config" ]
247  public_configs = [ "//gn:protobuf_gen_config" ]
248  deps = [ "//gn:default_deps" ]
249}
250
251source_set("protobuf_full") {
252  visibility = _buildtools_visibility
253  deps = [
254    ":protobuf_lite",
255    "//gn:default_deps",
256  ]
257  sources = [
258    "protobuf/src/google/protobuf/any.cc",
259    "protobuf/src/google/protobuf/any.h",
260    "protobuf/src/google/protobuf/any.pb.cc",
261    "protobuf/src/google/protobuf/any.pb.h",
262    "protobuf/src/google/protobuf/api.pb.cc",
263    "protobuf/src/google/protobuf/api.pb.h",
264    "protobuf/src/google/protobuf/compiler/importer.cc",
265    "protobuf/src/google/protobuf/compiler/importer.h",
266    "protobuf/src/google/protobuf/compiler/parser.cc",
267    "protobuf/src/google/protobuf/compiler/parser.h",
268    "protobuf/src/google/protobuf/descriptor.cc",
269    "protobuf/src/google/protobuf/descriptor.h",
270    "protobuf/src/google/protobuf/descriptor.pb.cc",
271    "protobuf/src/google/protobuf/descriptor.pb.h",
272    "protobuf/src/google/protobuf/descriptor_database.cc",
273    "protobuf/src/google/protobuf/descriptor_database.h",
274    "protobuf/src/google/protobuf/duration.pb.cc",
275    "protobuf/src/google/protobuf/duration.pb.h",
276    "protobuf/src/google/protobuf/dynamic_message.cc",
277    "protobuf/src/google/protobuf/dynamic_message.h",
278    "protobuf/src/google/protobuf/empty.pb.cc",
279    "protobuf/src/google/protobuf/empty.pb.h",
280    "protobuf/src/google/protobuf/extension_set_heavy.cc",
281    "protobuf/src/google/protobuf/field_mask.pb.cc",
282    "protobuf/src/google/protobuf/field_mask.pb.h",
283    "protobuf/src/google/protobuf/generated_enum_reflection.h",
284    "protobuf/src/google/protobuf/generated_message_reflection.cc",
285    "protobuf/src/google/protobuf/generated_message_reflection.h",
286    "protobuf/src/google/protobuf/io/gzip_stream.cc",
287    "protobuf/src/google/protobuf/io/gzip_stream.h",
288    "protobuf/src/google/protobuf/io/printer.cc",
289    "protobuf/src/google/protobuf/io/printer.h",
290    "protobuf/src/google/protobuf/io/tokenizer.cc",
291    "protobuf/src/google/protobuf/io/tokenizer.h",
292    "protobuf/src/google/protobuf/map_entry.h",
293    "protobuf/src/google/protobuf/map_field.cc",
294    "protobuf/src/google/protobuf/map_field.h",
295    "protobuf/src/google/protobuf/map_field_inl.h",
296    "protobuf/src/google/protobuf/message.cc",
297    "protobuf/src/google/protobuf/message.h",
298    "protobuf/src/google/protobuf/metadata.h",
299    "protobuf/src/google/protobuf/reflection.h",
300    "protobuf/src/google/protobuf/reflection_internal.h",
301    "protobuf/src/google/protobuf/reflection_ops.cc",
302    "protobuf/src/google/protobuf/reflection_ops.h",
303    "protobuf/src/google/protobuf/service.cc",
304    "protobuf/src/google/protobuf/service.h",
305    "protobuf/src/google/protobuf/source_context.pb.cc",
306    "protobuf/src/google/protobuf/source_context.pb.h",
307    "protobuf/src/google/protobuf/struct.pb.cc",
308    "protobuf/src/google/protobuf/struct.pb.h",
309    "protobuf/src/google/protobuf/stubs/mathlimits.cc",
310    "protobuf/src/google/protobuf/stubs/mathlimits.h",
311    "protobuf/src/google/protobuf/stubs/mathutil.h",
312    "protobuf/src/google/protobuf/stubs/substitute.cc",
313    "protobuf/src/google/protobuf/stubs/substitute.h",
314    "protobuf/src/google/protobuf/text_format.cc",
315    "protobuf/src/google/protobuf/text_format.h",
316    "protobuf/src/google/protobuf/timestamp.pb.cc",
317    "protobuf/src/google/protobuf/timestamp.pb.h",
318    "protobuf/src/google/protobuf/type.pb.cc",
319    "protobuf/src/google/protobuf/type.pb.h",
320    "protobuf/src/google/protobuf/unknown_field_set.cc",
321    "protobuf/src/google/protobuf/unknown_field_set.h",
322    "protobuf/src/google/protobuf/util/field_comparator.cc",
323    "protobuf/src/google/protobuf/util/field_comparator.h",
324    "protobuf/src/google/protobuf/util/field_mask_util.cc",
325    "protobuf/src/google/protobuf/util/field_mask_util.h",
326    "protobuf/src/google/protobuf/util/internal/constants.h",
327    "protobuf/src/google/protobuf/util/internal/datapiece.cc",
328    "protobuf/src/google/protobuf/util/internal/datapiece.h",
329    "protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc",
330    "protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h",
331    "protobuf/src/google/protobuf/util/internal/error_listener.cc",
332    "protobuf/src/google/protobuf/util/internal/error_listener.h",
333    "protobuf/src/google/protobuf/util/internal/field_mask_utility.cc",
334    "protobuf/src/google/protobuf/util/internal/field_mask_utility.h",
335    "protobuf/src/google/protobuf/util/internal/json_escaping.cc",
336    "protobuf/src/google/protobuf/util/internal/json_escaping.h",
337    "protobuf/src/google/protobuf/util/internal/json_objectwriter.cc",
338    "protobuf/src/google/protobuf/util/internal/json_objectwriter.h",
339    "protobuf/src/google/protobuf/util/internal/json_stream_parser.cc",
340    "protobuf/src/google/protobuf/util/internal/json_stream_parser.h",
341    "protobuf/src/google/protobuf/util/internal/location_tracker.h",
342    "protobuf/src/google/protobuf/util/internal/object_location_tracker.h",
343    "protobuf/src/google/protobuf/util/internal/object_source.h",
344    "protobuf/src/google/protobuf/util/internal/object_writer.cc",
345    "protobuf/src/google/protobuf/util/internal/object_writer.h",
346    "protobuf/src/google/protobuf/util/internal/proto_writer.cc",
347    "protobuf/src/google/protobuf/util/internal/proto_writer.h",
348    "protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc",
349    "protobuf/src/google/protobuf/util/internal/protostream_objectsource.h",
350    "protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc",
351    "protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h",
352    "protobuf/src/google/protobuf/util/internal/structured_objectwriter.h",
353    "protobuf/src/google/protobuf/util/internal/type_info.cc",
354    "protobuf/src/google/protobuf/util/internal/type_info.h",
355    "protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc",
356    "protobuf/src/google/protobuf/util/internal/type_info_test_helper.h",
357    "protobuf/src/google/protobuf/util/internal/utility.cc",
358    "protobuf/src/google/protobuf/util/internal/utility.h",
359    "protobuf/src/google/protobuf/util/json_util.cc",
360    "protobuf/src/google/protobuf/util/json_util.h",
361    "protobuf/src/google/protobuf/util/message_differencer.cc",
362    "protobuf/src/google/protobuf/util/message_differencer.h",
363    "protobuf/src/google/protobuf/util/time_util.cc",
364    "protobuf/src/google/protobuf/util/time_util.h",
365    "protobuf/src/google/protobuf/util/type_resolver.h",
366    "protobuf/src/google/protobuf/util/type_resolver_util.cc",
367    "protobuf/src/google/protobuf/util/type_resolver_util.h",
368    "protobuf/src/google/protobuf/wire_format.cc",
369    "protobuf/src/google/protobuf/wire_format.h",
370    "protobuf/src/google/protobuf/wrappers.pb.cc",
371    "protobuf/src/google/protobuf/wrappers.pb.h",
372  ]
373  configs -= [ "//gn/standalone:extra_warnings" ]
374  if (is_win) {
375    # Protobuf has its own #define WIN32_LEAN_AND_MEAN.
376    configs -= [ "//gn/standalone:win32_lean_and_mean" ]
377  }
378  configs += [ ":protobuf_config" ]
379  public_configs = [
380    "//gn:protobuf_gen_config",
381    ":protobuf_full_public_config",
382  ]
383}
384
385source_set("protoc_lib") {
386  visibility = _buildtools_visibility
387  deps = [
388    ":protobuf_full",
389    "//gn:default_deps",
390  ]
391  sources = [
392    "protobuf/src/google/protobuf/compiler/code_generator.cc",
393    "protobuf/src/google/protobuf/compiler/code_generator.h",
394    "protobuf/src/google/protobuf/compiler/command_line_interface.cc",
395    "protobuf/src/google/protobuf/compiler/command_line_interface.h",
396    "protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc",
397    "protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h",
398    "protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
399    "protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h",
400    "protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc",
401    "protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h",
402    "protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc",
403    "protobuf/src/google/protobuf/compiler/cpp/cpp_field.h",
404    "protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc",
405    "protobuf/src/google/protobuf/compiler/cpp/cpp_file.h",
406    "protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc",
407    "protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h",
408    "protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc",
409    "protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h",
410    "protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc",
411    "protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.h",
412    "protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc",
413    "protobuf/src/google/protobuf/compiler/cpp/cpp_message.h",
414    "protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc",
415    "protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h",
416    "protobuf/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h",
417    "protobuf/src/google/protobuf/compiler/cpp/cpp_options.h",
418    "protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc",
419    "protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h",
420    "protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
421    "protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
422    "protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc",
423    "protobuf/src/google/protobuf/compiler/cpp/cpp_service.h",
424    "protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc",
425    "protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h",
426    "protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
427    "protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.h",
428    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc",
429    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum.h",
430    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
431    "protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.h",
432    "protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
433    "protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.h",
434    "protobuf/src/google/protobuf/compiler/csharp/csharp_generator.cc",
435    "protobuf/src/google/protobuf/compiler/csharp/csharp_generator.h",
436    "protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
437    "protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.h",
438    "protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
439    "protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.h",
440    "protobuf/src/google/protobuf/compiler/csharp/csharp_message.cc",
441    "protobuf/src/google/protobuf/compiler/csharp/csharp_message.h",
442    "protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
443    "protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.h",
444    "protobuf/src/google/protobuf/compiler/csharp/csharp_options.h",
445    "protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
446    "protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.h",
447    "protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
448    "protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.h",
449    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
450    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h",
451    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
452    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h",
453    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
454    "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h",
455    "protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
456    "protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h",
457    "protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
458    "protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h",
459    "protobuf/src/google/protobuf/compiler/java/java_context.cc",
460    "protobuf/src/google/protobuf/compiler/java/java_context.h",
461    "protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc",
462    "protobuf/src/google/protobuf/compiler/java/java_doc_comment.h",
463    "protobuf/src/google/protobuf/compiler/java/java_enum.cc",
464    "protobuf/src/google/protobuf/compiler/java/java_enum.h",
465    "protobuf/src/google/protobuf/compiler/java/java_enum_field.cc",
466    "protobuf/src/google/protobuf/compiler/java/java_enum_field.h",
467    "protobuf/src/google/protobuf/compiler/java/java_enum_field_lite.cc",
468    "protobuf/src/google/protobuf/compiler/java/java_enum_field_lite.h",
469    "protobuf/src/google/protobuf/compiler/java/java_enum_lite.cc",
470    "protobuf/src/google/protobuf/compiler/java/java_enum_lite.h",
471    "protobuf/src/google/protobuf/compiler/java/java_extension.cc",
472    "protobuf/src/google/protobuf/compiler/java/java_extension.h",
473    "protobuf/src/google/protobuf/compiler/java/java_extension_lite.cc",
474    "protobuf/src/google/protobuf/compiler/java/java_extension_lite.h",
475    "protobuf/src/google/protobuf/compiler/java/java_field.cc",
476    "protobuf/src/google/protobuf/compiler/java/java_field.h",
477    "protobuf/src/google/protobuf/compiler/java/java_file.cc",
478    "protobuf/src/google/protobuf/compiler/java/java_file.h",
479    "protobuf/src/google/protobuf/compiler/java/java_generator.cc",
480    "protobuf/src/google/protobuf/compiler/java/java_generator.h",
481    "protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc",
482    "protobuf/src/google/protobuf/compiler/java/java_generator_factory.h",
483    "protobuf/src/google/protobuf/compiler/java/java_helpers.cc",
484    "protobuf/src/google/protobuf/compiler/java/java_helpers.h",
485    "protobuf/src/google/protobuf/compiler/java/java_map_field.cc",
486    "protobuf/src/google/protobuf/compiler/java/java_map_field.h",
487    "protobuf/src/google/protobuf/compiler/java/java_map_field_lite.cc",
488    "protobuf/src/google/protobuf/compiler/java/java_map_field_lite.h",
489    "protobuf/src/google/protobuf/compiler/java/java_message.cc",
490    "protobuf/src/google/protobuf/compiler/java/java_message.h",
491    "protobuf/src/google/protobuf/compiler/java/java_message_builder.cc",
492    "protobuf/src/google/protobuf/compiler/java/java_message_builder.h",
493    "protobuf/src/google/protobuf/compiler/java/java_message_builder_lite.cc",
494    "protobuf/src/google/protobuf/compiler/java/java_message_builder_lite.h",
495    "protobuf/src/google/protobuf/compiler/java/java_message_field.cc",
496    "protobuf/src/google/protobuf/compiler/java/java_message_field.h",
497    "protobuf/src/google/protobuf/compiler/java/java_message_field_lite.cc",
498    "protobuf/src/google/protobuf/compiler/java/java_message_field_lite.h",
499    "protobuf/src/google/protobuf/compiler/java/java_message_lite.cc",
500    "protobuf/src/google/protobuf/compiler/java/java_message_lite.h",
501    "protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc",
502    "protobuf/src/google/protobuf/compiler/java/java_name_resolver.h",
503    "protobuf/src/google/protobuf/compiler/java/java_options.h",
504    "protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc",
505    "protobuf/src/google/protobuf/compiler/java/java_primitive_field.h",
506    "protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
507    "protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.h",
508    "protobuf/src/google/protobuf/compiler/java/java_service.cc",
509    "protobuf/src/google/protobuf/compiler/java/java_service.h",
510    "protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc",
511    "protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.h",
512    "protobuf/src/google/protobuf/compiler/java/java_string_field.cc",
513    "protobuf/src/google/protobuf/compiler/java/java_string_field.h",
514    "protobuf/src/google/protobuf/compiler/java/java_string_field_lite.cc",
515    "protobuf/src/google/protobuf/compiler/java/java_string_field_lite.h",
516    "protobuf/src/google/protobuf/compiler/js/js_generator.cc",
517    "protobuf/src/google/protobuf/compiler/js/js_generator.h",
518    "protobuf/src/google/protobuf/compiler/js/well_known_types_embed.cc",
519    "protobuf/src/google/protobuf/compiler/js/well_known_types_embed.h",
520    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
521    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.h",
522    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
523    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h",
524    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
525    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.h",
526    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.cc",
527    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.h",
528    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.cc",
529    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.h",
530    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
531    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.h",
532    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
533    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.h",
534    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
535    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.h",
536    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc",
537    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.h",
538    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
539    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.h",
540    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
541    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.h",
542    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
543    "protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h",
544    "protobuf/src/google/protobuf/compiler/php/php_generator.cc",
545    "protobuf/src/google/protobuf/compiler/php/php_generator.h",
546    "protobuf/src/google/protobuf/compiler/plugin.cc",
547    "protobuf/src/google/protobuf/compiler/plugin.h",
548    "protobuf/src/google/protobuf/compiler/plugin.pb.cc",
549    "protobuf/src/google/protobuf/compiler/plugin.pb.h",
550    "protobuf/src/google/protobuf/compiler/python/python_generator.cc",
551    "protobuf/src/google/protobuf/compiler/python/python_generator.h",
552    "protobuf/src/google/protobuf/compiler/ruby/ruby_generator.cc",
553    "protobuf/src/google/protobuf/compiler/ruby/ruby_generator.h",
554    "protobuf/src/google/protobuf/compiler/subprocess.cc",
555    "protobuf/src/google/protobuf/compiler/subprocess.h",
556    "protobuf/src/google/protobuf/compiler/zip_writer.cc",
557    "protobuf/src/google/protobuf/compiler/zip_writer.h",
558  ]
559  configs -= [ "//gn/standalone:extra_warnings" ]
560  if (is_win) {
561    # Protobuf does has its own #define WIN32_LEAN_AND_MEAN.
562    configs -= [ "//gn/standalone:win32_lean_and_mean" ]
563  }
564  configs += [ ":protobuf_config" ]
565  public_configs = [
566    "//gn:protobuf_gen_config",
567    ":protobuf_full_public_config",
568  ]
569}
570
571if (current_toolchain == host_toolchain) {
572  executable("protoc") {
573    visibility = _buildtools_visibility
574    deps = [
575      ":protoc_lib",
576      "//gn:default_deps",
577    ]
578    sources = [ "protobuf/src/google/protobuf/compiler/main.cc" ]
579    configs -= [ "//gn/standalone:extra_warnings" ]
580    if (is_win) {
581      # Protobuf does has its own #define WIN32_LEAN_AND_MEAN.
582      configs -= [ "//gn/standalone:win32_lean_and_mean" ]
583    }
584  }
585}  # host_toolchain
586
587if (use_custom_libcxx) {
588  # Config applied to both libc++ and libc++abi targets below.
589  config("libc++config") {
590    visibility = _buildtools_visibility
591    defines = [
592      "LIBCXX_BUILDING_LIBCXXABI",
593      "_LIBCXXABI_NO_EXCEPTIONS",
594      "_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))",
595    ]
596    cflags = [ "-fstrict-aliasing" ]
597  }
598
599  source_set("libunwind") {
600    visibility = _buildtools_visibility
601    cflags = [
602      # libunwind expects to be compiled with unwind tables so it can
603      # unwind its own frames.
604      "-funwind-tables",
605      "-fstrict-aliasing",
606    ]
607    sources = [
608      "libunwind/src/Unwind-EHABI.cpp",
609      "libunwind/src/Unwind-sjlj.c",
610      "libunwind/src/UnwindLevel1-gcc-ext.c",
611      "libunwind/src/UnwindLevel1.c",
612      "libunwind/src/UnwindRegistersRestore.S",
613      "libunwind/src/UnwindRegistersSave.S",
614      "libunwind/src/libunwind.cpp",
615    ]
616    include_dirs = [ "libunwind/include" ]
617    configs -= [
618      "//gn/standalone:extra_warnings",
619      "//gn/standalone:no_exceptions",
620      "//gn/standalone:no_rtti",
621
622      # When building with msan, libunwind itself triggers memory violations
623      # that causes msan to get stuck into an infinite loop. Just don't
624      # instrument libunwind itself.
625      "//gn/standalone/sanitizers:sanitizers_cflags",
626    ]
627    configs += [
628      ":libc++config",
629      "//gn/standalone/sanitizers:sanitizer_options_link_helper",
630    ]
631  }
632
633  source_set("libc++abi") {
634    visibility = _buildtools_visibility
635    sources = [
636      "libcxxabi/src/abort_message.cpp",
637      "libcxxabi/src/cxa_aux_runtime.cpp",
638      "libcxxabi/src/cxa_default_handlers.cpp",
639      "libcxxabi/src/cxa_demangle.cpp",
640      "libcxxabi/src/cxa_exception.cpp",
641      "libcxxabi/src/cxa_exception_storage.cpp",
642      "libcxxabi/src/cxa_guard.cpp",
643      "libcxxabi/src/cxa_handlers.cpp",
644      "libcxxabi/src/cxa_personality.cpp",
645      "libcxxabi/src/cxa_unexpected.cpp",
646      "libcxxabi/src/cxa_vector.cpp",
647      "libcxxabi/src/cxa_virtual.cpp",
648      "libcxxabi/src/fallback_malloc.cpp",
649      "libcxxabi/src/private_typeinfo.cpp",
650      "libcxxabi/src/stdlib_exception.cpp",
651      "libcxxabi/src/stdlib_stdexcept.cpp",
652      "libcxxabi/src/stdlib_typeinfo.cpp",
653    ]
654
655    # On linux this seems to introduce an unwanted glibc 2.18 dependency.
656    if (is_android) {
657      sources += [ "libcxxabi/src/cxa_thread_atexit.cpp" ]
658    }
659    configs -= [
660      "//gn/standalone:extra_warnings",
661      "//gn/standalone:no_exceptions",
662      "//gn/standalone:no_rtti",
663      "//gn/standalone:visibility_hidden",
664    ]
665    configs += [
666      ":libc++config",
667      "//gn/standalone/sanitizers:sanitizer_options_link_helper",
668    ]
669    deps = [ ":libunwind" ]
670  }
671
672  if (custom_libcxx_is_static) {
673    libcxx_target_type = "source_set"
674  } else {
675    libcxx_target_type = "shared_library"
676  }
677
678  target(libcxx_target_type, "libc++") {
679    visibility = _buildtools_visibility
680    visibility += [ "../gn/standalone/libc++:*" ]
681    sources = [
682      "libcxx/src/algorithm.cpp",
683      "libcxx/src/any.cpp",
684      "libcxx/src/bind.cpp",
685      "libcxx/src/charconv.cpp",
686      "libcxx/src/chrono.cpp",
687      "libcxx/src/condition_variable.cpp",
688      "libcxx/src/condition_variable_destructor.cpp",
689      "libcxx/src/debug.cpp",
690      "libcxx/src/exception.cpp",
691      "libcxx/src/functional.cpp",
692      "libcxx/src/future.cpp",
693      "libcxx/src/hash.cpp",
694      "libcxx/src/ios.cpp",
695      "libcxx/src/iostream.cpp",
696      "libcxx/src/locale.cpp",
697      "libcxx/src/memory.cpp",
698      "libcxx/src/mutex.cpp",
699      "libcxx/src/mutex_destructor.cpp",
700      "libcxx/src/new.cpp",
701      "libcxx/src/optional.cpp",
702      "libcxx/src/random.cpp",
703      "libcxx/src/regex.cpp",
704      "libcxx/src/shared_mutex.cpp",
705      "libcxx/src/stdexcept.cpp",
706      "libcxx/src/string.cpp",
707      "libcxx/src/strstream.cpp",
708      "libcxx/src/system_error.cpp",
709      "libcxx/src/thread.cpp",
710      "libcxx/src/typeinfo.cpp",
711      "libcxx/src/utility.cpp",
712      "libcxx/src/valarray.cpp",
713      "libcxx/src/variant.cpp",
714      "libcxx/src/vector.cpp",
715    ]
716    configs -= [
717      "//gn/standalone:extra_warnings",
718      "//gn/standalone:no_exceptions",
719      "//gn/standalone:no_rtti",
720      "//gn/standalone:visibility_hidden",
721    ]
722    configs += [
723      ":libc++config",
724      "//gn/standalone/sanitizers:sanitizer_options_link_helper",
725    ]
726    defines = [ "_LIBCPP_BUILDING_LIBRARY" ]
727    if ((is_linux || is_android) && using_sanitizer &&
728        (is_asan || is_tsan || is_msan)) {
729      # In {a,t,m}san configurations, operator new and operator delete will be
730      # provided by the sanitizer runtime library.  Since libc++ defines these
731      # symbols with weak linkage, and the *san runtime uses strong linkage, it
732      # should technically be OK to omit this, but it's added to be explicit.
733      defines += [ "_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS" ]
734    }
735    deps = [ ":libc++abi" ]
736  }
737}  # if (use_custom_libcxx)
738
739config("benchmark_config") {
740  visibility = _buildtools_visibility
741  include_dirs = [ "benchmark/include" ]
742  configs = [ ":test_warning_suppressions" ]
743}
744
745source_set("benchmark") {
746  visibility = _buildtools_visibility
747  testonly = true
748  sources = [
749    "benchmark/include/benchmark/benchmark.h",
750    "benchmark/src/arraysize.h",
751    "benchmark/src/benchmark.cc",
752    "benchmark/src/benchmark_api_internal.cc",
753    "benchmark/src/benchmark_api_internal.h",
754    "benchmark/src/benchmark_name.cc",
755    "benchmark/src/benchmark_register.cc",
756    "benchmark/src/benchmark_register.h",
757    "benchmark/src/benchmark_runner.cc",
758    "benchmark/src/benchmark_runner.h",
759    "benchmark/src/check.h",
760    "benchmark/src/colorprint.cc",
761    "benchmark/src/colorprint.h",
762    "benchmark/src/commandlineflags.cc",
763    "benchmark/src/commandlineflags.h",
764    "benchmark/src/complexity.cc",
765    "benchmark/src/complexity.h",
766    "benchmark/src/console_reporter.cc",
767    "benchmark/src/counter.cc",
768    "benchmark/src/counter.h",
769    "benchmark/src/csv_reporter.cc",
770    "benchmark/src/cycleclock.h",
771    "benchmark/src/internal_macros.h",
772    "benchmark/src/json_reporter.cc",
773    "benchmark/src/log.h",
774    "benchmark/src/mutex.h",
775    "benchmark/src/re.h",
776    "benchmark/src/reporter.cc",
777    "benchmark/src/sleep.cc",
778    "benchmark/src/sleep.h",
779    "benchmark/src/statistics.cc",
780    "benchmark/src/statistics.h",
781    "benchmark/src/string_util.cc",
782    "benchmark/src/string_util.h",
783    "benchmark/src/sysinfo.cc",
784    "benchmark/src/thread_manager.h",
785    "benchmark/src/thread_timer.h",
786    "benchmark/src/timers.cc",
787    "benchmark/src/timers.h",
788  ]
789  defines = [ "HAVE_POSIX_REGEX" ]
790  public_configs = [ ":benchmark_config" ]
791  all_dependent_configs = [ ":benchmark_config" ]
792  if (!is_win) {
793    cflags = [ "-Wno-deprecated-declarations" ]
794  }
795  configs -= [ "//gn/standalone:extra_warnings" ]
796  deps = [ "//gn:default_deps" ]
797}
798
799# On Linux/Android use libbacktrace in debug builds for better stacktraces.
800if (is_linux || is_android) {
801  config("libbacktrace_config") {
802    visibility = _buildtools_visibility
803    include_dirs = [
804      "libbacktrace_config",
805      "libbacktrace",
806    ]
807    cflags = [
808      # We force include this config file because "config.h" is too generic as a
809      # file name and on some platforms #include "config.h" ends up colliding
810      # importing some other project's config.h.
811      "-include",
812      rebase_path("libbacktrace_config/config.h", root_build_dir),
813    ]
814  }
815
816  source_set("libbacktrace") {
817    visibility = _buildtools_visibility
818    sources = [
819      "libbacktrace/dwarf.c",
820      "libbacktrace/elf.c",
821      "libbacktrace/fileline.c",
822      "libbacktrace/mmap.c",
823      "libbacktrace/mmapio.c",
824      "libbacktrace/posix.c",
825      "libbacktrace/sort.c",
826      "libbacktrace/state.c",
827    ]
828    configs -= [ "//gn/standalone:extra_warnings" ]
829    public_configs = [ ":libbacktrace_config" ]
830    deps = [ "//gn:default_deps" ]
831  }
832}
833
834config("sqlite_config") {
835  visibility = _buildtools_visibility
836  include_dirs = [ "sqlite" ]
837  cflags = [
838    "-DSQLITE_THREADSAFE=0",
839    "-DSQLITE_DEFAULT_MEMSTATUS=0",
840    "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
841    "-DSQLITE_OMIT_DEPRECATED",
842    "-DSQLITE_OMIT_SHARED_CACHE",
843    "-DHAVE_USLEEP",
844    "-DHAVE_UTIME",
845    "-DSQLITE_BYTEORDER=1234",
846    "-DSQLITE_DEFAULT_AUTOVACUUM=0",
847    "-DSQLITE_DEFAULT_MMAP_SIZE=0",
848    "-DSQLITE_CORE",
849    "-DSQLITE_TEMP_STORE=3",
850    "-DSQLITE_OMIT_LOAD_EXTENSION",
851    "-DSQLITE_OMIT_RANDOMNESS",
852    "-DSQLITE_OMIT_AUTOINIT",
853    "-DSQLITE_ENABLE_JSON1",
854  ]
855}
856
857source_set("sqlite") {
858  visibility = _buildtools_visibility
859  sources = [
860    "sqlite/sqlite3.c",
861    "sqlite/sqlite3.h",
862    "sqlite/sqlite3ext.h",
863    "sqlite_src/ext/misc/percentile.c",
864  ]
865  configs -= [ "//gn/standalone:extra_warnings" ]
866  public_configs = [ ":sqlite_config" ]
867  deps = [ "//gn:default_deps" ]
868}
869
870source_set("sqlite_shell") {
871  visibility = _buildtools_visibility
872  testonly = true
873  sources = [ "sqlite/shell.c" ]
874  configs -= [ "//gn/standalone:extra_warnings" ]
875  deps = [
876    ":sqlite",
877    "//gn:default_deps",
878  ]
879}
880
881source_set("lzma") {
882  visibility = _buildtools_visibility
883  defines = [ "_7ZIP_ST" ]
884  sources = [
885    "lzma/C/7zAlloc.c",
886    "lzma/C/7zArcIn.c",
887    "lzma/C/7zBuf.c",
888    "lzma/C/7zBuf2.c",
889    "lzma/C/7zCrc.c",
890    "lzma/C/7zCrcOpt.c",
891    "lzma/C/7zDec.c",
892    "lzma/C/7zFile.c",
893    "lzma/C/7zStream.c",
894    "lzma/C/Aes.c",
895    "lzma/C/AesOpt.c",
896    "lzma/C/Alloc.c",
897    "lzma/C/Bcj2.c",
898    "lzma/C/Bra.c",
899    "lzma/C/Bra86.c",
900    "lzma/C/BraIA64.c",
901    "lzma/C/CpuArch.c",
902    "lzma/C/Delta.c",
903    "lzma/C/LzFind.c",
904    "lzma/C/Lzma2Dec.c",
905    "lzma/C/Lzma2Enc.c",
906    "lzma/C/Lzma86Dec.c",
907    "lzma/C/Lzma86Enc.c",
908    "lzma/C/LzmaDec.c",
909    "lzma/C/LzmaEnc.c",
910    "lzma/C/LzmaLib.c",
911    "lzma/C/Ppmd7.c",
912    "lzma/C/Ppmd7Dec.c",
913    "lzma/C/Ppmd7Enc.c",
914    "lzma/C/Sha256.c",
915    "lzma/C/Sort.c",
916    "lzma/C/Xz.c",
917    "lzma/C/XzCrc64.c",
918    "lzma/C/XzCrc64Opt.c",
919    "lzma/C/XzDec.c",
920    "lzma/C/XzEnc.c",
921    "lzma/C/XzIn.c",
922  ]
923  configs -= [ "//gn/standalone:extra_warnings" ]
924  cflags = [
925    "-Wno-empty-body",
926    "-Wno-enum-conversion",
927  ]
928  deps = [ "//gn:default_deps" ]
929}
930
931source_set("zlib") {
932  visibility = _buildtools_visibility
933  sources = [
934    "zlib/adler32.c",
935    "zlib/compress.c",
936    "zlib/cpu_features.c",
937    "zlib/crc32.c",
938    "zlib/deflate.c",
939    "zlib/gzclose.c",
940    "zlib/gzlib.c",
941    "zlib/gzread.c",
942    "zlib/gzwrite.c",
943    "zlib/infback.c",
944    "zlib/inffast.c",
945    "zlib/inflate.c",
946    "zlib/inftrees.c",
947    "zlib/trees.c",
948    "zlib/uncompr.c",
949    "zlib/zutil.c",
950  ]
951  configs -= [ "//gn/standalone:extra_warnings" ]
952  cflags = []
953  public_configs = [ ":zlib_config" ]
954  deps = [ "//gn:default_deps" ]
955
956  # TODO(primiano): look into ADLER32_SIMD_SSSE3 and other SIMD optimizations
957  # (from chromium's third_party/zlib/BUILD.gn).
958  if (is_win) {
959    defines = [ "X86_WINDOWS" ]
960  }
961}
962
963config("zlib_config") {
964  visibility = _buildtools_visibility
965  if (!is_win) {
966    defines = [ "HAVE_HIDDEN" ]
967  }
968  cflags = [
969    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
970    # warnings coming from third-party headers. Doing so would mask warnings in
971    # our own code.
972    perfetto_isystem_cflag,
973    rebase_path("zlib", root_build_dir),
974  ]
975}
976
977# Here be dragons. Used only by standalone profiler builds, which are
978# considered best effort. Since the headers use c++17 features, this source_set
979# pushes -std=c++17 flags up the dependency tree, whereas the rest of the
980# project continues to build under c++11. So the profilers end up linking
981# together code built under different standards, and rely on that to be ABI
982# compatible.
983source_set("libunwindstack") {
984  visibility = _buildtools_visibility
985  include_dirs = [
986    "android-unwinding/libunwindstack/include",
987    "android-unwinding/libunwindstack",
988    "android-libbase/include",
989    "android-logging/liblog/include",
990    "android-libprocinfo/include",
991    "android-core/include",
992    "android-core/libcutils/include",
993    "bionic/libc/async_safe/include",
994    "bionic/libc/platform/",
995    "lzma/C",
996  ]
997  deps = [
998    ":lzma",
999    "//gn:default_deps",
1000  ]
1001  sources = [
1002    "android-libbase/file.cpp",
1003    "android-libbase/stringprintf.cpp",
1004    "android-libbase/strings.cpp",
1005    "android-unwinding/libunwindstack/ArmExidx.cpp",
1006    "android-unwinding/libunwindstack/DwarfCfa.cpp",
1007    "android-unwinding/libunwindstack/DwarfEhFrameWithHdr.cpp",
1008    "android-unwinding/libunwindstack/DwarfMemory.cpp",
1009    "android-unwinding/libunwindstack/DwarfOp.cpp",
1010    "android-unwinding/libunwindstack/DwarfSection.cpp",
1011    "android-unwinding/libunwindstack/Elf.cpp",
1012    "android-unwinding/libunwindstack/ElfInterface.cpp",
1013    "android-unwinding/libunwindstack/ElfInterfaceArm.cpp",
1014    "android-unwinding/libunwindstack/Global.cpp",
1015    "android-unwinding/libunwindstack/JitDebug.cpp",
1016    "android-unwinding/libunwindstack/MapInfo.cpp",
1017    "android-unwinding/libunwindstack/Maps.cpp",
1018    "android-unwinding/libunwindstack/Memory.cpp",
1019    "android-unwinding/libunwindstack/MemoryXz.cpp",
1020    "android-unwinding/libunwindstack/Regs.cpp",
1021    "android-unwinding/libunwindstack/RegsArm.cpp",
1022    "android-unwinding/libunwindstack/RegsArm64.cpp",
1023    "android-unwinding/libunwindstack/RegsMips.cpp",
1024    "android-unwinding/libunwindstack/RegsMips64.cpp",
1025    "android-unwinding/libunwindstack/RegsX86.cpp",
1026    "android-unwinding/libunwindstack/RegsX86_64.cpp",
1027    "android-unwinding/libunwindstack/Symbols.cpp",
1028    "android-unwinding/libunwindstack/Unwinder.cpp",
1029  ]
1030  if (!is_android) {
1031    sources += [
1032      "android-libbase/liblog_symbols.cpp",
1033      "android-libbase/logging.cpp",
1034      "android-libbase/threads.cpp",
1035      "android-logging/liblog/logger_write.cpp",
1036      "android-logging/liblog/properties.cpp",
1037      "android-unwinding/libunwindstack/LogStdout.cpp",
1038      "android-unwinding/libunwindstack/MemoryMte.cpp",
1039    ]
1040  } else {
1041    sources += [ "android-unwinding/libunwindstack/LogAndroid.cpp" ]
1042  }
1043  if (current_cpu == "x86") {
1044    sources += [ "android-unwinding/libunwindstack/AsmGetRegsX86.S" ]
1045  } else if (current_cpu == "x64") {
1046    sources += [ "android-unwinding/libunwindstack/AsmGetRegsX86_64.S" ]
1047  }
1048  configs -= [
1049    "//gn/standalone:extra_warnings",
1050    "//gn/standalone:c++11",
1051    "//gn/standalone:visibility_hidden",
1052  ]
1053  cflags = [ "-DFAKE_LOG_DEVICE=1" ]
1054  public_configs = [
1055    ":libunwindstack_config",
1056    "//gn/standalone:c++17",
1057  ]
1058}
1059
1060config("bionic_kernel_uapi_headers") {
1061  visibility = _buildtools_visibility
1062  cflags = [
1063    perfetto_isystem_cflag,
1064    rebase_path("bionic/libc/kernel", root_build_dir),
1065  ]
1066}
1067
1068config("jsoncpp_config") {
1069  visibility = _buildtools_visibility
1070  cflags = [ "-DJSON_USE_EXCEPTION=0" ]
1071  if (!is_win) {
1072    cflags += [ "-Wno-deprecated-declarations" ]
1073  }
1074  cflags += [
1075    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
1076    # warnings coming from third-party headers. Doing so would mask warnings in
1077    # our own code.
1078    perfetto_isystem_cflag,
1079    rebase_path("jsoncpp/include", root_build_dir),
1080  ]
1081}
1082
1083source_set("jsoncpp") {
1084  visibility = _buildtools_visibility
1085  sources = [
1086    "jsoncpp/src/lib_json/json_reader.cpp",
1087    "jsoncpp/src/lib_json/json_value.cpp",
1088    "jsoncpp/src/lib_json/json_writer.cpp",
1089  ]
1090  configs -= [ "//gn/standalone:extra_warnings" ]
1091  public_configs = [ ":jsoncpp_config" ]
1092  deps = [ "//gn:default_deps" ]
1093}
1094
1095config("linenoise_config") {
1096  visibility = _buildtools_visibility
1097  cflags = [
1098    # Using -isystem instead of include_dirs (-I), so we don't need to suppress
1099    # warnings coming from third-party headers. Doing so would mask warnings in
1100    # our own code.
1101    perfetto_isystem_cflag,
1102    rebase_path("linenoise", root_build_dir),
1103  ]
1104}
1105
1106source_set("linenoise") {
1107  visibility = _buildtools_visibility
1108  sources = [
1109    "linenoise/linenoise.c",
1110    "linenoise/linenoise.h",
1111  ]
1112  configs -= [ "//gn/standalone:extra_warnings" ]
1113  public_configs = [ ":linenoise_config" ]
1114  cflags = [ "-Wno-tautological-unsigned-zero-compare" ]
1115  deps = [ "//gn:default_deps" ]
1116}
1117
1118if (use_libfuzzer) {
1119  source_set("libfuzzer") {
1120    visibility = _buildtools_visibility
1121    configs -= [
1122      "//gn/standalone:extra_warnings",
1123      "//gn/standalone/sanitizers:sanitizers_cflags",
1124    ]
1125    sources = [
1126      "libfuzzer/FuzzerCrossOver.cpp",
1127      "libfuzzer/FuzzerDataFlowTrace.cpp",
1128      "libfuzzer/FuzzerDriver.cpp",
1129      "libfuzzer/FuzzerExtFunctionsDlsym.cpp",
1130      "libfuzzer/FuzzerExtFunctionsWeak.cpp",
1131      "libfuzzer/FuzzerExtFunctionsWindows.cpp",
1132      "libfuzzer/FuzzerExtraCounters.cpp",
1133      "libfuzzer/FuzzerFork.cpp",
1134      "libfuzzer/FuzzerIO.cpp",
1135      "libfuzzer/FuzzerIOPosix.cpp",
1136      "libfuzzer/FuzzerIOWindows.cpp",
1137      "libfuzzer/FuzzerLoop.cpp",
1138      "libfuzzer/FuzzerMain.cpp",
1139      "libfuzzer/FuzzerMerge.cpp",
1140      "libfuzzer/FuzzerMutate.cpp",
1141      "libfuzzer/FuzzerSHA1.cpp",
1142      "libfuzzer/FuzzerTracePC.cpp",
1143      "libfuzzer/FuzzerUtil.cpp",
1144      "libfuzzer/FuzzerUtilDarwin.cpp",
1145      "libfuzzer/FuzzerUtilFuchsia.cpp",
1146      "libfuzzer/FuzzerUtilLinux.cpp",
1147      "libfuzzer/FuzzerUtilPosix.cpp",
1148      "libfuzzer/FuzzerUtilWindows.cpp",
1149    ]
1150    deps = [ "//gn:default_deps" ]
1151  }
1152}
1153
1154config("llvm_demangle_config") {
1155  visibility = _buildtools_visibility
1156  include_dirs = [ "llvm-project/llvm/include" ]
1157}
1158
1159# NB: this is built under c++14 and linked into code that is c++11 by default.
1160# We rely on the ABIs being compatible for this to be sane. At the time of
1161# writing, the only c++14 specific code is behind an #ifndef NDEBUG, so we
1162# could keep building as c++11 in non-debug builds, but we always use c++14 for
1163# consistency.
1164source_set("llvm_demangle") {
1165  visibility = _buildtools_visibility
1166  configs -= [
1167    "//gn/standalone:extra_warnings",
1168    "//gn/standalone:c++11",
1169  ]
1170  configs += [ "//gn/standalone:c++14" ]
1171  public_configs = [ ":llvm_demangle_config" ]
1172  sources = [
1173    "llvm-project/llvm/include/llvm/Demangle/Demangle.h",
1174    "llvm-project/llvm/include/llvm/Demangle/DemangleConfig.h",
1175    "llvm-project/llvm/include/llvm/Demangle/ItaniumDemangle.h",
1176    "llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangle.h",
1177    "llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h",
1178    "llvm-project/llvm/include/llvm/Demangle/StringView.h",
1179    "llvm-project/llvm/include/llvm/Demangle/Utility.h",
1180    "llvm-project/llvm/lib/Demangle/DLangDemangle.cpp",
1181    "llvm-project/llvm/lib/Demangle/Demangle.cpp",
1182    "llvm-project/llvm/lib/Demangle/ItaniumDemangle.cpp",
1183    "llvm-project/llvm/lib/Demangle/MicrosoftDemangle.cpp",
1184    "llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp",
1185    "llvm-project/llvm/lib/Demangle/RustDemangle.cpp",
1186  ]
1187  deps = [ "//gn:default_deps" ]
1188}
1189