blob: 33d83a09151670f6a8d9d22c7e9c6a2e3b1a1b02 [file] [log] [blame]
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//gn/standalone/libc++/libc++.gni")
# Mimimal config to be used in production (i.e. non-test) targets. This is
# really just to allowing include "gtest/gtest_prod.h" for the FRIEND_TEST macro
# and avoid to pull in warning suppressions that are not really necessary for
# production code.
config("googletest_prod_config") {
visibility = [ ":*" ]
include_dirs = [ "googletest/googletest/include" ]
}
# Config to include gtest.h in test targets.
config("googletest_config") {
visibility = [ ":*" ]
defines = [ "GTEST_LANG_CXX11=1" ]
include_dirs = [
"googletest/googletest/include",
"googletest/googlemock/include",
]
cflags = [
"-Wno-covered-switch-default",
"-Wno-deprecated",
"-Wno-global-constructors",
"-Wno-inconsistent-missing-override",
"-Wno-missing-noreturn",
"-Wno-overloaded-virtual",
"-Wno-shift-sign-overflow",
"-Wno-sign-conversion",
"-Wno-undef",
"-Wno-unused-member-function",
"-Wno-used-but-marked-unused",
"-Wno-zero-as-null-pointer-constant",
]
}
source_set("gtest") {
testonly = true
include_dirs = [ "googletest/googletest" ]
configs -= [ "//gn/standalone:extra_warnings" ]
public_configs = [ ":googletest_config" ]
all_dependent_configs = [ ":googletest_config" ]
sources = [
"googletest/googletest/src/gtest-all.cc",
]
}
source_set("gtest_main") {
testonly = true
configs -= [ "//gn/standalone:extra_warnings" ]
configs += [ ":googletest_config" ]
sources = [
"googletest/googletest/src/gtest_main.cc",
]
}
source_set("gmock") {
testonly = true
include_dirs = [ "googletest/googlemock" ]
configs -= [ "//gn/standalone:extra_warnings" ]
public_configs = [ ":googletest_config" ]
all_dependent_configs = [ ":googletest_config" ]
sources = [
"googletest/googlemock/src/gmock-all.cc",
]
}
# This config is applied to the autogenerated .pb.{cc,h} files in
# //gn/standalone/proto_library.gni. This config is propagated up to the source sets
# that depend on generated proto headers. Therefore this should stay as lean and
# clean as possible in terms of -W-no* suppressions. Thankfully the
# autogenerated .pb.h headers violate less warnings than the libprotobuf_*
# library itself.
config("protobuf_gen_config") {
visibility = [ ":*" ]
defines = [
"GOOGLE_PROTOBUF_NO_RTTI",
"GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
]
include_dirs = [ "protobuf/src" ]
cflags = [
"-Wno-deprecated",
"-Wno-disabled-macro-expansion",
"-Wno-int-to-void-pointer-cast",
"-Wno-missing-variable-declarations",
"-Wno-old-style-cast",
"-Wno-shorten-64-to-32",
"-Wno-sign-conversion",
"-Wno-undef",
"-Wno-zero-as-null-pointer-constant",
]
if (!is_clang) {
cflags += [
"-Wno-sign-compare",
"-Wno-maybe-uninitialized",
]
}
}
# Configuration used to build libprotobuf_* and the protoc compiler.
config("protobuf_config") {
# Apply the lighter supressions and macro definitions from above.
configs = [ ":protobuf_gen_config" ]
visibility = [ ":*" ]
defines = [ "HAVE_PTHREAD=1" ]
cflags = [
"-Wno-ignored-qualifiers",
"-Wno-missing-noreturn",
"-Wno-undef",
"-Wno-unused-parameter",
"-Wno-unused",
]
if (is_clang) {
cflags += [
"-Wno-enum-compare-switch",
"-Wno-global-constructors",
"-Wno-shift-sign-overflow",
"-Wno-used-but-marked-unused",
"-Wno-user-defined-warnings",
]
} else {
cflags += [
"-Wno-misleading-indentation",
"-Wno-return-type",
]
}
}
source_set("protobuf_lite") {
sources = [
"protobuf/src/google/protobuf/arena.cc",
"protobuf/src/google/protobuf/arenastring.cc",
"protobuf/src/google/protobuf/extension_set.cc",
"protobuf/src/google/protobuf/generated_message_util.cc",
"protobuf/src/google/protobuf/io/coded_stream.cc",
"protobuf/src/google/protobuf/io/zero_copy_stream.cc",
"protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
"protobuf/src/google/protobuf/message_lite.cc",
"protobuf/src/google/protobuf/repeated_field.cc",
"protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
"protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
"protobuf/src/google/protobuf/stubs/bytestream.cc",
"protobuf/src/google/protobuf/stubs/common.cc",
"protobuf/src/google/protobuf/stubs/int128.cc",
"protobuf/src/google/protobuf/stubs/once.cc",
"protobuf/src/google/protobuf/stubs/status.cc",
"protobuf/src/google/protobuf/stubs/statusor.cc",
"protobuf/src/google/protobuf/stubs/stringpiece.cc",
"protobuf/src/google/protobuf/stubs/stringprintf.cc",
"protobuf/src/google/protobuf/stubs/structurally_valid.cc",
"protobuf/src/google/protobuf/stubs/strutil.cc",
"protobuf/src/google/protobuf/stubs/time.cc",
"protobuf/src/google/protobuf/wire_format_lite.cc",
]
configs -= [ "//gn/standalone:extra_warnings" ]
public_configs = [ ":protobuf_config" ]
}
source_set("protobuf_full") {
deps = [
":protobuf_lite",
]
sources = [
"protobuf/src/google/protobuf/any.cc",
"protobuf/src/google/protobuf/any.pb.cc",
"protobuf/src/google/protobuf/api.pb.cc",
"protobuf/src/google/protobuf/compiler/importer.cc",
"protobuf/src/google/protobuf/compiler/parser.cc",
"protobuf/src/google/protobuf/descriptor.cc",
"protobuf/src/google/protobuf/descriptor.pb.cc",
"protobuf/src/google/protobuf/descriptor_database.cc",
"protobuf/src/google/protobuf/duration.pb.cc",
"protobuf/src/google/protobuf/dynamic_message.cc",
"protobuf/src/google/protobuf/empty.pb.cc",
"protobuf/src/google/protobuf/extension_set_heavy.cc",
"protobuf/src/google/protobuf/field_mask.pb.cc",
"protobuf/src/google/protobuf/generated_message_reflection.cc",
"protobuf/src/google/protobuf/io/gzip_stream.cc",
"protobuf/src/google/protobuf/io/printer.cc",
"protobuf/src/google/protobuf/io/strtod.cc",
"protobuf/src/google/protobuf/io/tokenizer.cc",
"protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc",
"protobuf/src/google/protobuf/map_field.cc",
"protobuf/src/google/protobuf/message.cc",
"protobuf/src/google/protobuf/reflection_ops.cc",
"protobuf/src/google/protobuf/service.cc",
"protobuf/src/google/protobuf/source_context.pb.cc",
"protobuf/src/google/protobuf/struct.pb.cc",
"protobuf/src/google/protobuf/stubs/mathlimits.cc",
"protobuf/src/google/protobuf/stubs/substitute.cc",
"protobuf/src/google/protobuf/text_format.cc",
"protobuf/src/google/protobuf/timestamp.pb.cc",
"protobuf/src/google/protobuf/type.pb.cc",
"protobuf/src/google/protobuf/unknown_field_set.cc",
"protobuf/src/google/protobuf/util/field_comparator.cc",
"protobuf/src/google/protobuf/util/field_mask_util.cc",
"protobuf/src/google/protobuf/util/internal/datapiece.cc",
"protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc",
"protobuf/src/google/protobuf/util/internal/error_listener.cc",
"protobuf/src/google/protobuf/util/internal/field_mask_utility.cc",
"protobuf/src/google/protobuf/util/internal/json_escaping.cc",
"protobuf/src/google/protobuf/util/internal/json_objectwriter.cc",
"protobuf/src/google/protobuf/util/internal/json_stream_parser.cc",
"protobuf/src/google/protobuf/util/internal/object_writer.cc",
"protobuf/src/google/protobuf/util/internal/proto_writer.cc",
"protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc",
"protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc",
"protobuf/src/google/protobuf/util/internal/type_info.cc",
"protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc",
"protobuf/src/google/protobuf/util/internal/utility.cc",
"protobuf/src/google/protobuf/util/json_util.cc",
"protobuf/src/google/protobuf/util/message_differencer.cc",
"protobuf/src/google/protobuf/util/time_util.cc",
"protobuf/src/google/protobuf/util/type_resolver_util.cc",
"protobuf/src/google/protobuf/wire_format.cc",
"protobuf/src/google/protobuf/wrappers.pb.cc",
]
configs -= [ "//gn/standalone:extra_warnings" ]
public_configs = [ ":protobuf_config" ]
}
if (current_toolchain == host_toolchain) {
source_set("protoc_lib") {
deps = [
":protobuf_full",
]
sources = [
"protobuf/src/google/protobuf/compiler/code_generator.cc",
"protobuf/src/google/protobuf/compiler/command_line_interface.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_generator.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_message.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_context.cc",
"protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_extension.cc",
"protobuf/src/google/protobuf/compiler/java/java_extension_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_file.cc",
"protobuf/src/google/protobuf/compiler/java/java_generator.cc",
"protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc",
"protobuf/src/google/protobuf/compiler/java/java_helpers.cc",
"protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_map_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_map_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_message.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_builder.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_builder_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc",
"protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_service.cc",
"protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc",
"protobuf/src/google/protobuf/compiler/java/java_string_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_string_field_lite.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_enum.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_extension.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_file.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_generator.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_helpers.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_map_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_message.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_message_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/js/js_generator.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/plugin.cc",
"protobuf/src/google/protobuf/compiler/plugin.pb.cc",
"protobuf/src/google/protobuf/compiler/python/python_generator.cc",
"protobuf/src/google/protobuf/compiler/ruby/ruby_generator.cc",
"protobuf/src/google/protobuf/compiler/subprocess.cc",
"protobuf/src/google/protobuf/compiler/zip_writer.cc",
]
configs -= [ "//gn/standalone:extra_warnings" ]
public_configs = [ ":protobuf_config" ]
}
executable("protoc") {
deps = [
":protoc_lib",
"../gn:default_deps",
]
sources = [
"protobuf/src/google/protobuf/compiler/main.cc",
]
configs -= [ "//gn/standalone:extra_warnings" ]
}
} # host_toolchain
if (use_custom_libcxx) {
# Config applied to both libc++ and libc++abi targets below.
config("libc++config") {
defines = [
"LIBCXX_BUILDING_LIBCXXABI",
"_LIBCXXABI_NO_EXCEPTIONS",
"_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))",
]
cflags = [
"-fPIC",
"-fstrict-aliasing",
]
}
source_set("libunwind") {
sources = [
"libunwind/src/Unwind-EHABI.cpp",
"libunwind/src/Unwind-sjlj.c",
"libunwind/src/UnwindLevel1-gcc-ext.c",
"libunwind/src/UnwindLevel1.c",
"libunwind/src/UnwindRegistersRestore.S",
"libunwind/src/UnwindRegistersSave.S",
"libunwind/src/libunwind.cpp",
]
include_dirs = [ "libunwind/include" ]
configs -= [
"//gn/standalone:extra_warnings",
"//gn/standalone:no_exceptions",
"//gn/standalone:no_rtti",
# When building with msan, libunwind itself triggers memory violations
# that causes msan to get stuck into an infinite loop. Just don't
# instrument libunwind itself.
"//gn/standalone/sanitizers:sanitizers_cflags",
]
configs += [
":libc++config",
"//gn/standalone/sanitizers:sanitizer_options_link_helper",
]
}
source_set("libc++abi") {
sources = [
"libcxxabi/src/abort_message.cpp",
"libcxxabi/src/cxa_aux_runtime.cpp",
"libcxxabi/src/cxa_default_handlers.cpp",
"libcxxabi/src/cxa_demangle.cpp",
"libcxxabi/src/cxa_exception.cpp",
"libcxxabi/src/cxa_exception_storage.cpp",
"libcxxabi/src/cxa_guard.cpp",
"libcxxabi/src/cxa_handlers.cpp",
"libcxxabi/src/cxa_personality.cpp",
"libcxxabi/src/cxa_unexpected.cpp",
"libcxxabi/src/cxa_vector.cpp",
"libcxxabi/src/cxa_virtual.cpp",
"libcxxabi/src/fallback_malloc.cpp",
"libcxxabi/src/private_typeinfo.cpp",
"libcxxabi/src/stdlib_exception.cpp",
"libcxxabi/src/stdlib_stdexcept.cpp",
"libcxxabi/src/stdlib_typeinfo.cpp",
]
# On linux this seems to introduce an unwanted glibc 2.18 dependency.
if (is_android) {
sources += [ "libcxxabi/src/cxa_thread_atexit.cpp" ]
}
configs -= [
"//gn/standalone:extra_warnings",
"//gn/standalone:no_exceptions",
"//gn/standalone:no_rtti",
"//gn/standalone:visibility_hidden",
]
configs += [
":libc++config",
"//gn/standalone/sanitizers:sanitizer_options_link_helper",
]
deps = [
":libunwind",
]
}
if (custom_libcxx_is_static) {
libcxx_target_type = "source_set"
} else {
libcxx_target_type = "shared_library"
}
target(libcxx_target_type, "libc++") {
sources = [
"libcxx/src/algorithm.cpp",
"libcxx/src/any.cpp",
"libcxx/src/bind.cpp",
"libcxx/src/chrono.cpp",
"libcxx/src/condition_variable.cpp",
"libcxx/src/debug.cpp",
"libcxx/src/exception.cpp",
"libcxx/src/functional.cpp",
"libcxx/src/future.cpp",
"libcxx/src/hash.cpp",
"libcxx/src/ios.cpp",
"libcxx/src/iostream.cpp",
"libcxx/src/locale.cpp",
"libcxx/src/memory.cpp",
"libcxx/src/mutex.cpp",
"libcxx/src/new.cpp",
"libcxx/src/optional.cpp",
"libcxx/src/random.cpp",
"libcxx/src/regex.cpp",
"libcxx/src/shared_mutex.cpp",
"libcxx/src/stdexcept.cpp",
"libcxx/src/string.cpp",
"libcxx/src/strstream.cpp",
"libcxx/src/system_error.cpp",
"libcxx/src/thread.cpp",
"libcxx/src/typeinfo.cpp",
"libcxx/src/utility.cpp",
"libcxx/src/valarray.cpp",
"libcxx/src/variant.cpp",
]
configs -= [
"//gn/standalone:extra_warnings",
"//gn/standalone:no_exceptions",
"//gn/standalone:no_rtti",
"//gn/standalone:visibility_hidden",
]
configs += [
":libc++config",
"//gn/standalone/sanitizers:sanitizer_options_link_helper",
]
defines = [ "_LIBCPP_BUILDING_LIBRARY" ]
deps = [
":libc++abi",
]
}
} # if (use_custom_libcxx)
config("benchmark_config") {
visibility = [ ":*" ]
include_dirs = [ "benchmark/include" ]
cflags = [
"-Wno-global-constructors",
"-Wno-covered-switch-default",
]
}
source_set("benchmark") {
testonly = true
sources = [
"benchmark/include/benchmark/benchmark.h",
"benchmark/include/benchmark/benchmark_api.h",
"benchmark/include/benchmark/reporter.h",
"benchmark/src/arraysize.h",
"benchmark/src/benchmark.cc",
"benchmark/src/benchmark_api_internal.h",
"benchmark/src/benchmark_register.cc",
"benchmark/src/check.h",
"benchmark/src/colorprint.cc",
"benchmark/src/colorprint.h",
"benchmark/src/commandlineflags.cc",
"benchmark/src/commandlineflags.h",
"benchmark/src/complexity.cc",
"benchmark/src/complexity.h",
"benchmark/src/console_reporter.cc",
"benchmark/src/counter.cc",
"benchmark/src/counter.h",
"benchmark/src/csv_reporter.cc",
"benchmark/src/cycleclock.h",
"benchmark/src/internal_macros.h",
"benchmark/src/json_reporter.cc",
"benchmark/src/log.h",
"benchmark/src/mutex.h",
"benchmark/src/re.h",
"benchmark/src/reporter.cc",
"benchmark/src/sleep.cc",
"benchmark/src/sleep.h",
"benchmark/src/stat.h",
"benchmark/src/string_util.cc",
"benchmark/src/string_util.h",
"benchmark/src/sysinfo.cc",
"benchmark/src/sysinfo.h",
"benchmark/src/timers.cc",
"benchmark/src/timers.h",
]
defines = [ "HAVE_POSIX_REGEX" ]
public_configs = [ ":benchmark_config" ]
all_dependent_configs = [ ":benchmark_config" ]
configs -= [ "//gn/standalone:extra_warnings" ]
}