| # Copyright 2017 The Fuchsia Authors. All rights reserved. |
| # |
| # Redistribution and use in source and binary forms, with or without |
| # modification, are permitted provided that the following conditions are |
| # met: |
| # |
| # * Redistributions of source code must retain the above copyright |
| # notice, this list of conditions and the following disclaimer. |
| # * Redistributions in binary form must reproduce the above |
| # copyright notice, this list of conditions and the following disclaimer |
| # in the documentation and/or other materials provided with the |
| # distribution. |
| # * Neither the name of Google Inc. nor the names of its |
| # contributors may be used to endorse or promote products derived from |
| # this software without specific prior written permission. |
| # |
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| import("//build/test.gni") |
| import("//third_party/protobuf/proto_library.gni") |
| |
| visibility = [ "//third_party/protobuf/*" ] |
| |
| # Please do not add more entries to this list. Proto depends on abseil-cpp, |
| # which is not intended to be widely used in Fuchsia platform components. |
| visibility_protobuf = [ |
| "$cobalt_root/*", |
| "//src/connectivity/bluetooth/testing/pandora/bt-pandora-server:*", |
| "//src/lib/fidl_codec:*", |
| "//src/performance/experimental/profiler/samples_to_pprof:*", |
| "//src/sensors/playback/*", |
| "//src/virtualization/bin/termina_guest_manager:*", |
| "//src/virtualization/lib/*", |
| "//src/virtualization/third_party/*", |
| "//third_party/grpc:*", |
| "//third_party/perfetto/*", |
| "//third_party/spirv-tools:*", |
| "//third_party/tink/*", |
| "//tools/fidlcat/*", |
| "//vendor/third_party/*", |
| ] |
| |
| visibility_protoc = [ |
| "$cobalt_root/*", |
| "//src/connectivity/bluetooth/testing/pandora/bt-pandora-server:*", |
| "//src/lib/fidl_codec:*", |
| "//src/developer/ffx/lib/profiler:*", |
| "//src/performance/*", |
| "//src/starnix/lib/perfetto:*", |
| "//src/sensors/playback/proto:*", |
| "//src/virtualization/third_party/vm_tools:*", |
| "//src/virtualization/lib/*", |
| "//third_party/luci-go/resultdb/*", |
| "//third_party/perfetto/*", |
| "//third_party/pigweed/backends/pw_protobuf_compiler:*", |
| "//third_party/pigweed/src/pw_log:*", |
| "//third_party/pigweed/src/pw_protobuf:*", |
| "//third_party/pigweed/src/pw_tokenizer:*", |
| "//third_party/tink/cc/proto:*", |
| "//tools/bazel-docgen:*", |
| "//tools/build/fx-set:*", |
| "//tools/debug/covargs/*", |
| "//tools/fidlcat/lib:*", |
| "//tools/integration/fint:*", |
| "//tools/integration/testsharder:*", |
| "//tools/metadata/proto:*", |
| "//tools/testing/resultdb:*", |
| "//tools/virtual_device/*", |
| "//vendor/google/*", |
| "//vendor/third_party/*", |
| ] |
| |
| config("protobuf_config") { |
| visibility += [ "//third_party/grpc:*" ] |
| include_dirs = [ |
| "src", |
| "third_party/utf8_range/", |
| "//third_party/abseil-cpp", |
| ] |
| defines = [ |
| "GOOGLE_PROTOBUF_NO_RTTI", |
| "HAVE_PTHREAD", |
| ] |
| cflags = [] |
| if (is_clang) { |
| cflags += [ |
| # Needed to support PROTOBUF_INTERNAL_CHECK_CLASS_SIZE in descriptor.h |
| "-Wno-c++98-compat-extra-semi", |
| |
| # There are implicit conversions in parse_context.h |
| "-Wno-shorten-64-to-32", |
| ] |
| } |
| } |
| |
| config("protobuf_warnings") { |
| visibility += visibility_protoc |
| cflags = [] |
| |
| if (is_clang) { |
| # These are all needed as of https://github.com/protocolbuffers/protobuf/releases/tag/v3.21.12 |
| cflags += [ |
| "-Wno-deprecated-pragma", |
| "-Wno-enum-enum-conversion", |
| "-Wno-extra-semi", |
| "-Wno-float-conversion", |
| "-Wno-implicit-float-conversion", |
| "-Wno-implicit-int-conversion", |
| "-Wno-implicit-int-float-conversion", |
| "-Wno-invalid-noreturn", |
| "-Wno-missing-field-initializers", |
| "-Wno-sign-compare", |
| "-Wno-unused-function", |
| "-Wno-unused-private-field", |
| "-Wno-deprecated-declarations", # Mac deprecated sprintf |
| "-Wno-deprecated-this-capture", |
| "-Wno-unnecessary-virtual-specifier", |
| ] |
| } |
| } |
| |
| # This config should be applied to targets using generated code from the proto |
| # compiler. It sets up the include directories properly. |
| config("using_proto") { |
| visibility += visibility_protoc |
| include_dirs = [ |
| "src", |
| "$root_gen_dir", |
| ] |
| } |
| |
| static_library("protobuf_lite") { |
| visibility += visibility_protobuf |
| sources = [ |
| "src/google/protobuf/any_lite.cc", |
| "src/google/protobuf/arena.cc", |
| "src/google/protobuf/arenastring.cc", |
| "src/google/protobuf/arenaz_sampler.cc", |
| "src/google/protobuf/extension_set.cc", |
| "src/google/protobuf/generated_enum_util.cc", |
| "src/google/protobuf/generated_message_tctable_lite.cc", |
| "src/google/protobuf/generated_message_util.cc", |
| "src/google/protobuf/implicit_weak_message.cc", |
| "src/google/protobuf/inlined_string_field.cc", |
| "src/google/protobuf/io/coded_stream.cc", |
| "src/google/protobuf/io/io_win32.cc", |
| "src/google/protobuf/io/strtod.cc", |
| "src/google/protobuf/io/zero_copy_stream.cc", |
| "src/google/protobuf/io/zero_copy_stream_impl.cc", |
| "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", |
| "src/google/protobuf/map.cc", |
| "src/google/protobuf/message_lite.cc", |
| "src/google/protobuf/parse_context.cc", |
| "src/google/protobuf/port.cc", |
| "src/google/protobuf/raw_ptr.cc", |
| "src/google/protobuf/repeated_field.cc", |
| "src/google/protobuf/repeated_ptr_field.cc", |
| "src/google/protobuf/stubs/common.cc", |
| "src/google/protobuf/wire_format_lite.cc", |
| "third_party/utf8_range/utf8_range.c", |
| "third_party/utf8_range/utf8_validity.cc", |
| ] |
| |
| # git ls-files -- ':!*/compiler/*' ':!*/testing/*' ':!*/util/*' 'src/google/protobuf/*.h' 'src/google/protobuf/*.inc' | sed 's/^/"/' | sed 's/$/",/' |
| public = [ PROTOBUF_LITE_PUBLIC ] |
| configs += [ ":protobuf_warnings" ] |
| public_configs = [ ":protobuf_config" ] |
| deps = [ "//third_party/abseil-cpp:absl" ] |
| } |
| |
| # This is the full, heavy protobuf lib that's needed for c++ .protos that don't |
| # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls |
| # into that category. |
| static_library("protobuf_full") { |
| visibility += visibility_protobuf |
| sources = [ |
| "src/google/protobuf/any.cc", |
| "src/google/protobuf/any.pb.cc", |
| "src/google/protobuf/api.pb.cc", |
| "src/google/protobuf/compiler/importer.cc", |
| "src/google/protobuf/compiler/parser.cc", |
| "src/google/protobuf/cpp_features.pb.cc", |
| "src/google/protobuf/descriptor.cc", |
| "src/google/protobuf/descriptor.pb.cc", |
| "src/google/protobuf/descriptor_database.cc", |
| "src/google/protobuf/duration.pb.cc", |
| "src/google/protobuf/dynamic_message.cc", |
| "src/google/protobuf/empty.pb.cc", |
| "src/google/protobuf/extension_set_heavy.cc", |
| "src/google/protobuf/feature_resolver.cc", |
| "src/google/protobuf/field_mask.pb.cc", |
| "src/google/protobuf/generated_message_bases.cc", |
| "src/google/protobuf/generated_message_reflection.cc", |
| "src/google/protobuf/generated_message_tctable_full.cc", |
| "src/google/protobuf/generated_message_tctable_gen.cc", |
| |
| # gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just |
| # by test code, so instead of compiling zlib for the host, let's just |
| # exclude this. |
| # "src/google/protobuf/io/gzip_stream.cc", |
| |
| "src/google/protobuf/io/printer.cc", |
| "src/google/protobuf/io/tokenizer.cc", |
| "src/google/protobuf/io/zero_copy_sink.cc", |
| "src/google/protobuf/map_field.cc", |
| "src/google/protobuf/message.cc", |
| "src/google/protobuf/reflection_mode.cc", |
| "src/google/protobuf/reflection_ops.cc", |
| "src/google/protobuf/service.cc", |
| "src/google/protobuf/source_context.pb.cc", |
| "src/google/protobuf/struct.pb.cc", |
| "src/google/protobuf/text_format.cc", |
| "src/google/protobuf/timestamp.pb.cc", |
| "src/google/protobuf/type.pb.cc", |
| "src/google/protobuf/unknown_field_set.cc", |
| "src/google/protobuf/util/delimited_message_util.cc", |
| "src/google/protobuf/util/field_comparator.cc", |
| "src/google/protobuf/util/field_mask_util.cc", |
| "src/google/protobuf/util/message_differencer.cc", |
| "src/google/protobuf/util/time_util.cc", |
| "src/google/protobuf/util/type_resolver_util.cc", |
| "src/google/protobuf/wire_format.cc", |
| "src/google/protobuf/wrappers.pb.cc", |
| ] |
| |
| # git ls-files -- ':!*/compiler/*' ':!*/testing/*' 'src/google/protobuf/*.h' 'src/google/protobuf/*.inc' | sed 's/^/"/' | sed 's/$/",/' |
| public = [ PROTOBUF_FULL_PUBLIC ] |
| configs += [ ":protobuf_warnings" ] |
| public_configs = [ ":protobuf_config" ] |
| deps = [ ":protobuf_lite" ] |
| } |
| |
| # Only compile the compiler for the host architecture. |
| if (current_toolchain == host_toolchain) { |
| # Only the minimal upb files required to build the protoc compiler. |
| # |
| # git ls-files -- ':!*_test.cc' 'upb/port/*.h' 'upb/port/*.inc' 'upb/port/*.cc' 'upb/base/*.h' 'upb/base/*.cc' 'upb/mem/*.h' 'upb/mem/*.cc' | sed 's/^/"/' | sed 's/$/",/' |
| static_library("upb") { |
| sources = [ UPB_LIB_SOURCES ] |
| include_dirs = [ "//third_party/protobuf" ] |
| deps = [ "//third_party/abseil-cpp" ] |
| } |
| |
| # protoc compiler is separated into protoc library and executable targets to |
| # support protoc plugins that need to link libprotoc, but not the main() |
| # itself. See src/google/protobuf/compiler/plugin.h |
| # |
| # git ls-files -- ':!*/main.cc' ':!*test*' ':!*mock*' ':!src/google/protobuf/compiler/cpp/tools/*' 'src/google/protobuf/compiler/*.cc' | sed 's/^/"/' | sed 's/$/",/' |
| static_library("protoc_lib") { |
| visibility += [ |
| "//third_party/grpc:*", |
| "//third_party/perfetto/gn:*", |
| ] |
| sources = [ PROTOC_LIB_SOURCES ] |
| include_dirs = [ "//third_party/protobuf" ] |
| configs += [ ":protobuf_warnings" ] |
| public_deps = [ |
| ":protobuf_full", |
| ":upb", |
| ] |
| } |
| |
| executable("protoc") { |
| visibility += visibility_protoc |
| sources = [ "src/google/protobuf/compiler/main.cc" ] |
| deps = [ ":protoc_lib" ] |
| } |
| } else { |
| group("protoc") { |
| visibility += visibility_protoc |
| deps = [ ":protoc($host_toolchain)" ] |
| } |
| } |