blob: 33203c9161ea940d2a26c384fcd593f9ffb4d8cc [file] [log] [blame]
Primiano Tucciae2879e2017-09-27 11:02:09 +09001# 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
Primiano Tucci7a40e4d2017-12-06 09:51:09 +000015import("//gn/standalone/libc++/libc++.gni")
Florian Mayera2fae262018-08-31 12:10:01 -070016import("../gn/perfetto.gni")
Primiano Tucci0825bc82017-09-28 18:50:23 +010017
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010018# Used to suppress warnings coming from googletest macros expansions.
19config("test_warning_suppressions") {
20 cflags = [
21 "-Wno-unknown-warning-option",
22 "-Wno-global-constructors",
23 "-Wno-covered-switch-default",
24 "-Wno-used-but-marked-unused",
25 "-Wno-covered-switch-default",
26 "-Wno-global-constructors",
27 "-Wno-used-but-marked-unused",
28 "-Wno-inconsistent-missing-override",
29 "-Wno-unused-member-function",
30 "-Wno-zero-as-null-pointer-constant",
31 "-Wno-weak-vtables",
32 ]
33}
34
Primiano Tucci2a29ac72017-10-24 17:47:19 +010035# Mimimal config to be used in production (i.e. non-test) targets. This is
36# really just to allowing include "gtest/gtest_prod.h" for the FRIEND_TEST macro
37# and avoid to pull in warning suppressions that are not really necessary for
38# production code.
39config("googletest_prod_config") {
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010040 cflags = [
41 # Using -isystem instead of include_dirs (-I), so we don't need to suppress
Florian Mayerbda0c442018-09-07 10:53:55 +010042 # warnings coming from third-party headers. Doing so would mask warnings in
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010043 # our own code.
44 "-isystem",
45 rebase_path("googletest/googletest/include", root_build_dir),
46 ]
Primiano Tucci2a29ac72017-10-24 17:47:19 +010047}
48
Florian Mayer475bd7e2018-08-07 20:04:03 +010049config("libunwindstack_config") {
50 cflags = [
51 # Using -isystem instead of include_dirs (-I), so we don't need to suppress
Florian Mayerf8335662018-08-08 11:30:32 +010052 # warnings coming from libunwindstack headers. Doing so would mask warnings
53 # in our own code.
Florian Mayer475bd7e2018-08-07 20:04:03 +010054 "-isystem",
Florian Mayerf8335662018-08-08 11:30:32 +010055 rebase_path("android-core/libunwindstack/include", root_build_dir),
Florian Mayerb64d6b12018-08-30 10:46:30 -070056 "-isystem",
57 rebase_path("android-core/libprocinfo/include", root_build_dir),
58 "-isystem",
59 rebase_path("android-core/base/include", root_build_dir),
Florian Mayer475bd7e2018-08-07 20:04:03 +010060 ]
Florian Mayerb64d6b12018-08-30 10:46:30 -070061 if (is_android) {
62 cflags += [
63 "-isystem",
64 rebase_path("bionic/libc/include", root_build_dir),
65 ]
66 }
Florian Mayer475bd7e2018-08-07 20:04:03 +010067}
68
Primiano Tucci2a29ac72017-10-24 17:47:19 +010069# Config to include gtest.h in test targets.
Primiano Tucciae2879e2017-09-27 11:02:09 +090070config("googletest_config") {
Primiano Tucciae2879e2017-09-27 11:02:09 +090071 defines = [ "GTEST_LANG_CXX11=1" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +090072 cflags = [
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010073 # Using -isystem instead of include_dirs (-I), so we don't need to suppress
Florian Mayerbda0c442018-09-07 10:53:55 +010074 # warnings coming from third-party headers. Doing so would mask warnings in
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010075 # our own code.
76 "-isystem",
77 rebase_path("googletest/googletest/include", root_build_dir),
78 "-isystem",
79 rebase_path("googletest/googlemock/include", root_build_dir),
Primiano Tucciae2879e2017-09-27 11:02:09 +090080 ]
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010081 configs = [ ":test_warning_suppressions" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +090082}
83
84source_set("gtest") {
85 testonly = true
86 include_dirs = [ "googletest/googletest" ]
Primiano Tucci7a40e4d2017-12-06 09:51:09 +000087 configs -= [ "//gn/standalone:extra_warnings" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +090088 public_configs = [ ":googletest_config" ]
89 all_dependent_configs = [ ":googletest_config" ]
90 sources = [
91 "googletest/googletest/src/gtest-all.cc",
92 ]
93}
94
95source_set("gtest_main") {
96 testonly = true
Primiano Tucci7a40e4d2017-12-06 09:51:09 +000097 configs -= [ "//gn/standalone:extra_warnings" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +090098 configs += [ ":googletest_config" ]
99 sources = [
100 "googletest/googletest/src/gtest_main.cc",
101 ]
102}
103
104source_set("gmock") {
105 testonly = true
106 include_dirs = [ "googletest/googlemock" ]
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000107 configs -= [ "//gn/standalone:extra_warnings" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +0900108 public_configs = [ ":googletest_config" ]
109 all_dependent_configs = [ ":googletest_config" ]
110 sources = [
111 "googletest/googlemock/src/gmock-all.cc",
112 ]
113}
114
Primiano Tuccifd484232017-10-25 00:15:39 +0100115# This config is applied to the autogenerated .pb.{cc,h} files in
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000116# //gn/standalone/proto_library.gni. This config is propagated up to the source sets
Primiano Tuccifd484232017-10-25 00:15:39 +0100117# that depend on generated proto headers. Therefore this should stay as lean and
118# clean as possible in terms of -W-no* suppressions. Thankfully the
119# autogenerated .pb.h headers violate less warnings than the libprotobuf_*
120# library itself.
121config("protobuf_gen_config") {
Primiano Tucciae2879e2017-09-27 11:02:09 +0900122 defines = [
123 "GOOGLE_PROTOBUF_NO_RTTI",
124 "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
Primiano Tucciae2879e2017-09-27 11:02:09 +0900125 ]
Primiano Tucciae2879e2017-09-27 11:02:09 +0900126 cflags = [
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100127 # Using -isystem instead of include_dirs (-I), so we don't need to suppress
128 # warnings coming from libprotobuf headers. Doing so would mask warnings in
129 # our own code.
130 "-isystem",
131 rebase_path("protobuf/src", root_build_dir),
132 "-Wno-unknown-warning-option",
Primiano Tucciae2879e2017-09-27 11:02:09 +0900133 "-Wno-deprecated",
Primiano Tuccid7d1be02017-10-30 17:41:34 +0000134 "-Wno-undef",
Primiano Tuccifd484232017-10-25 00:15:39 +0100135 "-Wno-zero-as-null-pointer-constant",
136 ]
Primiano Tuccifd484232017-10-25 00:15:39 +0100137}
138
139# Configuration used to build libprotobuf_* and the protoc compiler.
140config("protobuf_config") {
141 # Apply the lighter supressions and macro definitions from above.
142 configs = [ ":protobuf_gen_config" ]
143
Primiano Tuccifd484232017-10-25 00:15:39 +0100144 defines = [ "HAVE_PTHREAD=1" ]
Hector Dearmanedb3beb2017-10-09 17:53:36 +0100145 if (is_clang) {
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100146 cflags = [
147 "-Wno-unknown-warning-option",
Primiano Tuccib60d4b02017-11-10 11:03:00 +0000148 "-Wno-enum-compare-switch",
Primiano Tuccib60d4b02017-11-10 11:03:00 +0000149 "-Wno-user-defined-warnings",
Florian Mayeraa5316b2018-08-20 17:45:12 -0700150 "-Wno-tautological-constant-compare",
Primiano Tucciae2879e2017-09-27 11:02:09 +0900151 ]
152 }
153}
154
155source_set("protobuf_lite") {
156 sources = [
157 "protobuf/src/google/protobuf/arena.cc",
158 "protobuf/src/google/protobuf/arenastring.cc",
159 "protobuf/src/google/protobuf/extension_set.cc",
160 "protobuf/src/google/protobuf/generated_message_util.cc",
161 "protobuf/src/google/protobuf/io/coded_stream.cc",
162 "protobuf/src/google/protobuf/io/zero_copy_stream.cc",
163 "protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
164 "protobuf/src/google/protobuf/message_lite.cc",
165 "protobuf/src/google/protobuf/repeated_field.cc",
166 "protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
167 "protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
168 "protobuf/src/google/protobuf/stubs/bytestream.cc",
169 "protobuf/src/google/protobuf/stubs/common.cc",
170 "protobuf/src/google/protobuf/stubs/int128.cc",
171 "protobuf/src/google/protobuf/stubs/once.cc",
172 "protobuf/src/google/protobuf/stubs/status.cc",
173 "protobuf/src/google/protobuf/stubs/statusor.cc",
174 "protobuf/src/google/protobuf/stubs/stringpiece.cc",
175 "protobuf/src/google/protobuf/stubs/stringprintf.cc",
176 "protobuf/src/google/protobuf/stubs/structurally_valid.cc",
177 "protobuf/src/google/protobuf/stubs/strutil.cc",
178 "protobuf/src/google/protobuf/stubs/time.cc",
179 "protobuf/src/google/protobuf/wire_format_lite.cc",
180 ]
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000181 configs -= [ "//gn/standalone:extra_warnings" ]
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100182 configs += [ ":protobuf_config" ]
183 public_configs = [ ":protobuf_gen_config" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +0900184}
185
186source_set("protobuf_full") {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800187 deps = [
188 ":protobuf_lite",
189 ]
Primiano Tucciae2879e2017-09-27 11:02:09 +0900190 sources = [
191 "protobuf/src/google/protobuf/any.cc",
192 "protobuf/src/google/protobuf/any.pb.cc",
193 "protobuf/src/google/protobuf/api.pb.cc",
194 "protobuf/src/google/protobuf/compiler/importer.cc",
195 "protobuf/src/google/protobuf/compiler/parser.cc",
196 "protobuf/src/google/protobuf/descriptor.cc",
197 "protobuf/src/google/protobuf/descriptor.pb.cc",
198 "protobuf/src/google/protobuf/descriptor_database.cc",
199 "protobuf/src/google/protobuf/duration.pb.cc",
200 "protobuf/src/google/protobuf/dynamic_message.cc",
201 "protobuf/src/google/protobuf/empty.pb.cc",
202 "protobuf/src/google/protobuf/extension_set_heavy.cc",
203 "protobuf/src/google/protobuf/field_mask.pb.cc",
204 "protobuf/src/google/protobuf/generated_message_reflection.cc",
205 "protobuf/src/google/protobuf/io/gzip_stream.cc",
206 "protobuf/src/google/protobuf/io/printer.cc",
207 "protobuf/src/google/protobuf/io/strtod.cc",
208 "protobuf/src/google/protobuf/io/tokenizer.cc",
209 "protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc",
210 "protobuf/src/google/protobuf/map_field.cc",
211 "protobuf/src/google/protobuf/message.cc",
212 "protobuf/src/google/protobuf/reflection_ops.cc",
213 "protobuf/src/google/protobuf/service.cc",
214 "protobuf/src/google/protobuf/source_context.pb.cc",
215 "protobuf/src/google/protobuf/struct.pb.cc",
216 "protobuf/src/google/protobuf/stubs/mathlimits.cc",
217 "protobuf/src/google/protobuf/stubs/substitute.cc",
218 "protobuf/src/google/protobuf/text_format.cc",
219 "protobuf/src/google/protobuf/timestamp.pb.cc",
220 "protobuf/src/google/protobuf/type.pb.cc",
221 "protobuf/src/google/protobuf/unknown_field_set.cc",
222 "protobuf/src/google/protobuf/util/field_comparator.cc",
223 "protobuf/src/google/protobuf/util/field_mask_util.cc",
224 "protobuf/src/google/protobuf/util/internal/datapiece.cc",
225 "protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc",
226 "protobuf/src/google/protobuf/util/internal/error_listener.cc",
227 "protobuf/src/google/protobuf/util/internal/field_mask_utility.cc",
228 "protobuf/src/google/protobuf/util/internal/json_escaping.cc",
229 "protobuf/src/google/protobuf/util/internal/json_objectwriter.cc",
230 "protobuf/src/google/protobuf/util/internal/json_stream_parser.cc",
231 "protobuf/src/google/protobuf/util/internal/object_writer.cc",
232 "protobuf/src/google/protobuf/util/internal/proto_writer.cc",
233 "protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc",
234 "protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc",
235 "protobuf/src/google/protobuf/util/internal/type_info.cc",
236 "protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc",
237 "protobuf/src/google/protobuf/util/internal/utility.cc",
238 "protobuf/src/google/protobuf/util/json_util.cc",
239 "protobuf/src/google/protobuf/util/message_differencer.cc",
240 "protobuf/src/google/protobuf/util/time_util.cc",
241 "protobuf/src/google/protobuf/util/type_resolver_util.cc",
242 "protobuf/src/google/protobuf/wire_format.cc",
243 "protobuf/src/google/protobuf/wrappers.pb.cc",
244 ]
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000245 configs -= [ "//gn/standalone:extra_warnings" ]
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100246 configs += [ ":protobuf_config" ]
247 public_configs = [ ":protobuf_gen_config" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +0900248}
249
250if (current_toolchain == host_toolchain) {
Primiano Tuccifd484232017-10-25 00:15:39 +0100251 source_set("protoc_lib") {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800252 deps = [
253 ":protobuf_full",
254 ]
Primiano Tucciae2879e2017-09-27 11:02:09 +0900255 sources = [
256 "protobuf/src/google/protobuf/compiler/code_generator.cc",
257 "protobuf/src/google/protobuf/compiler/command_line_interface.cc",
258 "protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc",
259 "protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
260 "protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc",
261 "protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc",
262 "protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc",
263 "protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc",
264 "protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc",
265 "protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc",
266 "protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc",
267 "protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc",
268 "protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
269 "protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc",
270 "protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc",
271 "protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
272 "protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc",
273 "protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
274 "protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
275 "protobuf/src/google/protobuf/compiler/csharp/csharp_generator.cc",
276 "protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
277 "protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
278 "protobuf/src/google/protobuf/compiler/csharp/csharp_message.cc",
279 "protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
280 "protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
281 "protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
282 "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
283 "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
284 "protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
285 "protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
286 "protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
287 "protobuf/src/google/protobuf/compiler/java/java_context.cc",
288 "protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc",
289 "protobuf/src/google/protobuf/compiler/java/java_enum.cc",
290 "protobuf/src/google/protobuf/compiler/java/java_enum_field.cc",
291 "protobuf/src/google/protobuf/compiler/java/java_enum_field_lite.cc",
292 "protobuf/src/google/protobuf/compiler/java/java_enum_lite.cc",
293 "protobuf/src/google/protobuf/compiler/java/java_extension.cc",
294 "protobuf/src/google/protobuf/compiler/java/java_extension_lite.cc",
295 "protobuf/src/google/protobuf/compiler/java/java_field.cc",
296 "protobuf/src/google/protobuf/compiler/java/java_file.cc",
297 "protobuf/src/google/protobuf/compiler/java/java_generator.cc",
298 "protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc",
299 "protobuf/src/google/protobuf/compiler/java/java_helpers.cc",
300 "protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc",
301 "protobuf/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
302 "protobuf/src/google/protobuf/compiler/java/java_map_field.cc",
303 "protobuf/src/google/protobuf/compiler/java/java_map_field_lite.cc",
304 "protobuf/src/google/protobuf/compiler/java/java_message.cc",
305 "protobuf/src/google/protobuf/compiler/java/java_message_builder.cc",
306 "protobuf/src/google/protobuf/compiler/java/java_message_builder_lite.cc",
307 "protobuf/src/google/protobuf/compiler/java/java_message_field.cc",
308 "protobuf/src/google/protobuf/compiler/java/java_message_field_lite.cc",
309 "protobuf/src/google/protobuf/compiler/java/java_message_lite.cc",
310 "protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc",
311 "protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc",
312 "protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
313 "protobuf/src/google/protobuf/compiler/java/java_service.cc",
314 "protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc",
315 "protobuf/src/google/protobuf/compiler/java/java_string_field.cc",
316 "protobuf/src/google/protobuf/compiler/java/java_string_field_lite.cc",
317 "protobuf/src/google/protobuf/compiler/javanano/javanano_enum.cc",
318 "protobuf/src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
319 "protobuf/src/google/protobuf/compiler/javanano/javanano_extension.cc",
320 "protobuf/src/google/protobuf/compiler/javanano/javanano_field.cc",
321 "protobuf/src/google/protobuf/compiler/javanano/javanano_file.cc",
322 "protobuf/src/google/protobuf/compiler/javanano/javanano_generator.cc",
323 "protobuf/src/google/protobuf/compiler/javanano/javanano_helpers.cc",
324 "protobuf/src/google/protobuf/compiler/javanano/javanano_map_field.cc",
325 "protobuf/src/google/protobuf/compiler/javanano/javanano_message.cc",
326 "protobuf/src/google/protobuf/compiler/javanano/javanano_message_field.cc",
327 "protobuf/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
328 "protobuf/src/google/protobuf/compiler/js/js_generator.cc",
Primiano Tucciae2879e2017-09-27 11:02:09 +0900329 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
330 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
331 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
332 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.cc",
333 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.cc",
334 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
335 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
336 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
337 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc",
338 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
339 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
340 "protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
341 "protobuf/src/google/protobuf/compiler/plugin.cc",
342 "protobuf/src/google/protobuf/compiler/plugin.pb.cc",
343 "protobuf/src/google/protobuf/compiler/python/python_generator.cc",
344 "protobuf/src/google/protobuf/compiler/ruby/ruby_generator.cc",
345 "protobuf/src/google/protobuf/compiler/subprocess.cc",
346 "protobuf/src/google/protobuf/compiler/zip_writer.cc",
347 ]
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000348 configs -= [ "//gn/standalone:extra_warnings" ]
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100349 configs += [ ":protobuf_config" ]
350 public_configs = [ ":protobuf_gen_config" ]
Primiano Tucciae2879e2017-09-27 11:02:09 +0900351 }
Primiano Tuccifd484232017-10-25 00:15:39 +0100352
353 executable("protoc") {
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800354 deps = [
355 ":protoc_lib",
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100356 "//gn:default_deps",
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800357 ]
Primiano Tuccifd484232017-10-25 00:15:39 +0100358 sources = [
359 "protobuf/src/google/protobuf/compiler/main.cc",
360 ]
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000361 configs -= [ "//gn/standalone:extra_warnings" ]
Primiano Tuccifd484232017-10-25 00:15:39 +0100362 }
Primiano Tucciae2879e2017-09-27 11:02:09 +0900363} # host_toolchain
Primiano Tucci0825bc82017-09-28 18:50:23 +0100364
365if (use_custom_libcxx) {
366 # Config applied to both libc++ and libc++abi targets below.
367 config("libc++config") {
368 defines = [
369 "LIBCXX_BUILDING_LIBCXXABI",
370 "_LIBCXXABI_NO_EXCEPTIONS",
371 "_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))",
372 ]
373 cflags = [
374 "-fPIC",
375 "-fstrict-aliasing",
376 ]
377 }
378
Primiano Tucci7278dea2017-10-31 11:50:32 +0000379 source_set("libunwind") {
380 sources = [
381 "libunwind/src/Unwind-EHABI.cpp",
382 "libunwind/src/Unwind-sjlj.c",
383 "libunwind/src/UnwindLevel1-gcc-ext.c",
384 "libunwind/src/UnwindLevel1.c",
385 "libunwind/src/UnwindRegistersRestore.S",
386 "libunwind/src/UnwindRegistersSave.S",
387 "libunwind/src/libunwind.cpp",
388 ]
389 include_dirs = [ "libunwind/include" ]
390 configs -= [
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000391 "//gn/standalone:extra_warnings",
392 "//gn/standalone:no_exceptions",
393 "//gn/standalone:no_rtti",
Primiano Tucci7278dea2017-10-31 11:50:32 +0000394
395 # When building with msan, libunwind itself triggers memory violations
396 # that causes msan to get stuck into an infinite loop. Just don't
397 # instrument libunwind itself.
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000398 "//gn/standalone/sanitizers:sanitizers_cflags",
Primiano Tucci7278dea2017-10-31 11:50:32 +0000399 ]
400 configs += [
401 ":libc++config",
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000402 "//gn/standalone/sanitizers:sanitizer_options_link_helper",
Primiano Tucci7278dea2017-10-31 11:50:32 +0000403 ]
404 }
405
Primiano Tucci0825bc82017-09-28 18:50:23 +0100406 source_set("libc++abi") {
407 sources = [
408 "libcxxabi/src/abort_message.cpp",
409 "libcxxabi/src/cxa_aux_runtime.cpp",
410 "libcxxabi/src/cxa_default_handlers.cpp",
411 "libcxxabi/src/cxa_demangle.cpp",
412 "libcxxabi/src/cxa_exception.cpp",
413 "libcxxabi/src/cxa_exception_storage.cpp",
414 "libcxxabi/src/cxa_guard.cpp",
415 "libcxxabi/src/cxa_handlers.cpp",
416 "libcxxabi/src/cxa_personality.cpp",
417 "libcxxabi/src/cxa_unexpected.cpp",
418 "libcxxabi/src/cxa_vector.cpp",
419 "libcxxabi/src/cxa_virtual.cpp",
420 "libcxxabi/src/fallback_malloc.cpp",
421 "libcxxabi/src/private_typeinfo.cpp",
422 "libcxxabi/src/stdlib_exception.cpp",
423 "libcxxabi/src/stdlib_stdexcept.cpp",
424 "libcxxabi/src/stdlib_typeinfo.cpp",
425 ]
426
427 # On linux this seems to introduce an unwanted glibc 2.18 dependency.
428 if (is_android) {
429 sources += [ "libcxxabi/src/cxa_thread_atexit.cpp" ]
430 }
431 configs -= [
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000432 "//gn/standalone:extra_warnings",
433 "//gn/standalone:no_exceptions",
434 "//gn/standalone:no_rtti",
Primiano Tucci5aab7582017-12-07 12:22:03 +0000435 "//gn/standalone:visibility_hidden",
Primiano Tucci0825bc82017-09-28 18:50:23 +0100436 ]
437 configs += [
438 ":libc++config",
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000439 "//gn/standalone/sanitizers:sanitizer_options_link_helper",
Primiano Tucci0825bc82017-09-28 18:50:23 +0100440 ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800441 deps = [
442 ":libunwind",
443 ]
Primiano Tucci0825bc82017-09-28 18:50:23 +0100444 }
445
Primiano Tucci7278dea2017-10-31 11:50:32 +0000446 if (custom_libcxx_is_static) {
447 libcxx_target_type = "source_set"
448 } else {
449 libcxx_target_type = "shared_library"
450 }
451
452 target(libcxx_target_type, "libc++") {
Primiano Tucci0825bc82017-09-28 18:50:23 +0100453 sources = [
454 "libcxx/src/algorithm.cpp",
455 "libcxx/src/any.cpp",
456 "libcxx/src/bind.cpp",
457 "libcxx/src/chrono.cpp",
458 "libcxx/src/condition_variable.cpp",
459 "libcxx/src/debug.cpp",
460 "libcxx/src/exception.cpp",
461 "libcxx/src/functional.cpp",
462 "libcxx/src/future.cpp",
463 "libcxx/src/hash.cpp",
464 "libcxx/src/ios.cpp",
465 "libcxx/src/iostream.cpp",
466 "libcxx/src/locale.cpp",
467 "libcxx/src/memory.cpp",
468 "libcxx/src/mutex.cpp",
469 "libcxx/src/new.cpp",
470 "libcxx/src/optional.cpp",
471 "libcxx/src/random.cpp",
472 "libcxx/src/regex.cpp",
473 "libcxx/src/shared_mutex.cpp",
474 "libcxx/src/stdexcept.cpp",
475 "libcxx/src/string.cpp",
476 "libcxx/src/strstream.cpp",
477 "libcxx/src/system_error.cpp",
478 "libcxx/src/thread.cpp",
479 "libcxx/src/typeinfo.cpp",
480 "libcxx/src/utility.cpp",
481 "libcxx/src/valarray.cpp",
482 "libcxx/src/variant.cpp",
Primiano Tuccic2eb5102018-05-15 10:40:01 +0100483 "libcxx/src/vector.cpp",
Primiano Tucci0825bc82017-09-28 18:50:23 +0100484 ]
485 configs -= [
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000486 "//gn/standalone:extra_warnings",
487 "//gn/standalone:no_exceptions",
488 "//gn/standalone:no_rtti",
Primiano Tucci5aab7582017-12-07 12:22:03 +0000489 "//gn/standalone:visibility_hidden",
Primiano Tucci0825bc82017-09-28 18:50:23 +0100490 ]
491 configs += [
492 ":libc++config",
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000493 "//gn/standalone/sanitizers:sanitizer_options_link_helper",
Primiano Tucci0825bc82017-09-28 18:50:23 +0100494 ]
495 defines = [ "_LIBCPP_BUILDING_LIBRARY" ]
Oystein Eftevaagdd727e42017-12-05 08:49:55 -0800496 deps = [
497 ":libc++abi",
498 ]
Primiano Tucci0825bc82017-09-28 18:50:23 +0100499 }
500} # if (use_custom_libcxx)
Hector Dearman88a10112017-10-12 11:07:10 +0100501
502config("benchmark_config") {
Primiano Tucci2a29ac72017-10-24 17:47:19 +0100503 include_dirs = [ "benchmark/include" ]
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100504 configs = [ ":test_warning_suppressions" ]
Hector Dearman88a10112017-10-12 11:07:10 +0100505}
506
507source_set("benchmark") {
508 testonly = true
509 sources = [
510 "benchmark/include/benchmark/benchmark.h",
511 "benchmark/include/benchmark/benchmark_api.h",
512 "benchmark/include/benchmark/reporter.h",
513 "benchmark/src/arraysize.h",
514 "benchmark/src/benchmark.cc",
515 "benchmark/src/benchmark_api_internal.h",
516 "benchmark/src/benchmark_register.cc",
517 "benchmark/src/check.h",
518 "benchmark/src/colorprint.cc",
519 "benchmark/src/colorprint.h",
520 "benchmark/src/commandlineflags.cc",
521 "benchmark/src/commandlineflags.h",
522 "benchmark/src/complexity.cc",
523 "benchmark/src/complexity.h",
524 "benchmark/src/console_reporter.cc",
525 "benchmark/src/counter.cc",
526 "benchmark/src/counter.h",
527 "benchmark/src/csv_reporter.cc",
528 "benchmark/src/cycleclock.h",
529 "benchmark/src/internal_macros.h",
530 "benchmark/src/json_reporter.cc",
531 "benchmark/src/log.h",
532 "benchmark/src/mutex.h",
533 "benchmark/src/re.h",
534 "benchmark/src/reporter.cc",
535 "benchmark/src/sleep.cc",
536 "benchmark/src/sleep.h",
Lalit Magantic99d93c2018-03-22 15:09:30 +0000537 "benchmark/src/statistics.cc",
538 "benchmark/src/statistics.h",
Hector Dearman88a10112017-10-12 11:07:10 +0100539 "benchmark/src/string_util.cc",
540 "benchmark/src/string_util.h",
541 "benchmark/src/sysinfo.cc",
542 "benchmark/src/sysinfo.h",
543 "benchmark/src/timers.cc",
544 "benchmark/src/timers.h",
545 ]
546 defines = [ "HAVE_POSIX_REGEX" ]
547 public_configs = [ ":benchmark_config" ]
548 all_dependent_configs = [ ":benchmark_config" ]
Primiano Tucci7a40e4d2017-12-06 09:51:09 +0000549 configs -= [ "//gn/standalone:extra_warnings" ]
Hector Dearman88a10112017-10-12 11:07:10 +0100550}
Primiano Tucci38faa6f2018-04-01 20:12:08 +0200551
552# On Linux/Android use libbacktrace in debug builds for better stacktraces.
553if (is_linux || is_android) {
554 config("libbacktrace_config") {
Primiano Tucci38faa6f2018-04-01 20:12:08 +0200555 include_dirs = [
556 "libbacktrace_config",
557 "libbacktrace",
558 ]
559 cflags = [
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100560 # We force include this config file because "config.h" is too generic as a
561 # file name and on some platforms #include "config.h" ends up colliding
562 # importing some other project's config.h.
Primiano Tucci38faa6f2018-04-01 20:12:08 +0200563 "-include",
564 rebase_path("libbacktrace_config/config.h", root_build_dir),
565 ]
566 }
567
568 source_set("libbacktrace") {
569 sources = [
Primiano Tucci38faa6f2018-04-01 20:12:08 +0200570 "libbacktrace/dwarf.c",
571 "libbacktrace/elf.c",
572 "libbacktrace/fileline.c",
573 "libbacktrace/mmap.c",
574 "libbacktrace/mmapio.c",
575 "libbacktrace/posix.c",
Primiano Tucci38faa6f2018-04-01 20:12:08 +0200576 "libbacktrace/sort.c",
577 "libbacktrace/state.c",
578 ]
579 configs -= [ "//gn/standalone:extra_warnings" ]
580 public_configs = [ ":libbacktrace_config" ]
581 }
582}
Lalit Magantib123f262018-05-22 14:05:03 +0100583
584config("sqlite_config") {
585 include_dirs = [ "sqlite" ]
586 cflags = [
587 "-DSQLITE_THREADSAFE=0",
588 "-DQLITE_DEFAULT_MEMSTATUS=0",
589 "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
Lalit Magantib123f262018-05-22 14:05:03 +0100590 "-DSQLITE_OMIT_DEPRECATED",
591 "-DSQLITE_OMIT_SHARED_CACHE",
592 "-DHAVE_USLEEP",
593 "-DHAVE_UTIME",
594 "-DSQLITE_BYTEORDER=1234",
595 "-DSQLITE_DEFAULT_AUTOVACUUM=0",
596 "-DSQLITE_DEFAULT_MMAP_SIZE=0",
597 "-DSQLITE_CORE",
Lalit Maganti8d31c732018-06-21 14:23:04 +0100598 "-DSQLITE_TEMP_STORE=3",
Lalit Magantic6347f02018-06-25 14:03:46 +0100599 "-DSQLITE_OMIT_LOAD_EXTENSION",
Hector Dearman7af33572018-09-19 17:42:25 +0100600 "-DSQLITE_OMIT_RANDOMNESS",
Lalit Magantib123f262018-05-22 14:05:03 +0100601 ]
602}
603
604source_set("sqlite") {
605 sources = [
606 "sqlite/sqlite3.c",
607 "sqlite/sqlite3.h",
608 "sqlite/sqlite3ext.h",
609 ]
610 configs -= [ "//gn/standalone:extra_warnings" ]
611 public_configs = [ ":sqlite_config" ]
612}
613
614source_set("sqlite_shell") {
615 testonly = true
616 sources = [
617 "sqlite/shell.c",
618 ]
619 configs -= [ "//gn/standalone:extra_warnings" ]
620 deps = [
621 ":sqlite",
622 ]
623}
Primiano Tucci0d72a312018-08-07 14:42:45 +0100624
Florian Mayer475bd7e2018-08-07 20:04:03 +0100625source_set("lzma") {
626 defines = [ "_7ZIP_ST" ]
627 sources = [
628 "lzma/C/7zAlloc.c",
629 "lzma/C/7zArcIn.c",
630 "lzma/C/7zBuf.c",
631 "lzma/C/7zBuf2.c",
632 "lzma/C/7zCrc.c",
633 "lzma/C/7zCrcOpt.c",
634 "lzma/C/7zDec.c",
635 "lzma/C/7zFile.c",
636 "lzma/C/7zStream.c",
637 "lzma/C/Aes.c",
638 "lzma/C/AesOpt.c",
639 "lzma/C/Alloc.c",
640 "lzma/C/Bcj2.c",
641 "lzma/C/Bra.c",
642 "lzma/C/Bra86.c",
643 "lzma/C/BraIA64.c",
644 "lzma/C/CpuArch.c",
645 "lzma/C/Delta.c",
646 "lzma/C/LzFind.c",
647 "lzma/C/Lzma2Dec.c",
648 "lzma/C/Lzma2Enc.c",
649 "lzma/C/Lzma86Dec.c",
650 "lzma/C/Lzma86Enc.c",
651 "lzma/C/LzmaDec.c",
652 "lzma/C/LzmaEnc.c",
653 "lzma/C/LzmaLib.c",
654 "lzma/C/Ppmd7.c",
655 "lzma/C/Ppmd7Dec.c",
656 "lzma/C/Ppmd7Enc.c",
657 "lzma/C/Sha256.c",
658 "lzma/C/Sort.c",
659 "lzma/C/Xz.c",
660 "lzma/C/XzCrc64.c",
661 "lzma/C/XzCrc64Opt.c",
662 "lzma/C/XzDec.c",
663 "lzma/C/XzEnc.c",
664 "lzma/C/XzIn.c",
665 ]
666 configs -= [ "//gn/standalone:extra_warnings" ]
667 cflags = [
668 "-Wno-empty-body",
669 "-Wno-enum-conversion",
670 ]
671}
Florian Mayera2fae262018-08-31 12:10:01 -0700672
Florian Mayer475bd7e2018-08-07 20:04:03 +0100673source_set("libunwindstack") {
674 include_dirs = [
Florian Mayerf8335662018-08-08 11:30:32 +0100675 "android-core/libunwindstack/include",
676 "android-core/libunwindstack",
677 "android-core/base/include",
678 "android-core/liblog/include",
679 "android-core/libprocinfo/include",
680 "android-core/include",
Florian Mayer475bd7e2018-08-07 20:04:03 +0100681 "lzma/C",
682 ]
683 deps = [
684 ":lzma",
685 ]
686 defines = [ "NO_LIBDEXFILE_SUPPORT" ]
687 sources = [
Florian Mayerf8335662018-08-08 11:30:32 +0100688 "android-core/base/file.cpp",
689 "android-core/base/logging.cpp",
690 "android-core/base/stringprintf.cpp",
691 "android-core/base/strings.cpp",
692 "android-core/base/threads.cpp",
693 "android-core/libunwindstack/ArmExidx.cpp",
694 "android-core/libunwindstack/DwarfCfa.cpp",
695 "android-core/libunwindstack/DwarfEhFrameWithHdr.cpp",
696 "android-core/libunwindstack/DwarfMemory.cpp",
697 "android-core/libunwindstack/DwarfOp.cpp",
698 "android-core/libunwindstack/DwarfSection.cpp",
699 "android-core/libunwindstack/Elf.cpp",
700 "android-core/libunwindstack/ElfInterface.cpp",
701 "android-core/libunwindstack/ElfInterfaceArm.cpp",
702 "android-core/libunwindstack/JitDebug.cpp",
703 "android-core/libunwindstack/LocalUnwinder.cpp",
704 "android-core/libunwindstack/Log.cpp",
705 "android-core/libunwindstack/MapInfo.cpp",
706 "android-core/libunwindstack/Maps.cpp",
707 "android-core/libunwindstack/Memory.cpp",
708 "android-core/libunwindstack/Regs.cpp",
709 "android-core/libunwindstack/RegsArm.cpp",
710 "android-core/libunwindstack/RegsArm64.cpp",
711 "android-core/libunwindstack/RegsMips.cpp",
712 "android-core/libunwindstack/RegsMips64.cpp",
713 "android-core/libunwindstack/RegsX86.cpp",
714 "android-core/libunwindstack/RegsX86_64.cpp",
715 "android-core/libunwindstack/Symbols.cpp",
716 "android-core/libunwindstack/Unwinder.cpp",
717 "android-core/libunwindstack/tests/LogFake.cpp",
Florian Mayer475bd7e2018-08-07 20:04:03 +0100718 ]
719 if (current_cpu == "x86") {
Florian Mayerf8335662018-08-08 11:30:32 +0100720 sources += [ "android-core/libunwindstack/AsmGetRegsX86.S" ]
Florian Mayer475bd7e2018-08-07 20:04:03 +0100721 } else if (current_cpu == "x64") {
Florian Mayerf8335662018-08-08 11:30:32 +0100722 sources += [ "android-core/libunwindstack/AsmGetRegsX86_64.S" ]
Florian Mayer475bd7e2018-08-07 20:04:03 +0100723 }
724 configs -= [
725 "//gn/standalone:extra_warnings",
726 "//gn/standalone:c++11",
Florian Mayera2fae262018-08-31 12:10:01 -0700727 "//gn/standalone:visibility_hidden",
Florian Mayer475bd7e2018-08-07 20:04:03 +0100728 ]
729 configs += [ "//gn/standalone:c++17" ]
730 public_configs = [ ":libunwindstack_config" ]
731}
732
Primiano Tucci0d72a312018-08-07 14:42:45 +0100733config("jsoncpp_config") {
734 cflags = [
735 "-DJSON_USE_EXCEPTION=0",
736
737 # Using -isystem instead of include_dirs (-I), so we don't need to suppress
Florian Mayerbda0c442018-09-07 10:53:55 +0100738 # warnings coming from third-party headers. Doing so would mask warnings in
Primiano Tucci0d72a312018-08-07 14:42:45 +0100739 # our own code.
740 "-isystem",
741 rebase_path("jsoncpp/include", root_build_dir),
742 ]
743}
744
745source_set("jsoncpp") {
746 sources = [
747 "jsoncpp/src/lib_json/json_reader.cpp",
748 "jsoncpp/src/lib_json/json_value.cpp",
749 "jsoncpp/src/lib_json/json_writer.cpp",
750 ]
751 configs -= [ "//gn/standalone:extra_warnings" ]
752 public_configs = [ ":jsoncpp_config" ]
753}