Source release 18.1.0
This commit is contained in:
173
third_party/protobuf/build_defs/BUILD.bazel
vendored
Normal file
173
third_party/protobuf/build_defs/BUILD.bazel
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
# Internal Starlark definitions for Protobuf.
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", starlark_cc_proto_library = "cc_proto_library")
|
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||||
load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
|
||||
load(":compiler_config_setting.bzl", "create_compiler_config_setting")
|
||||
|
||||
package(
|
||||
default_visibility = [
|
||||
# Public, but Protobuf only visibility.
|
||||
"//:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
create_compiler_config_setting(
|
||||
name = "config_msvc",
|
||||
value = "msvc-cl",
|
||||
)
|
||||
|
||||
# Android NDK builds can specify different crosstool_top flags to choose which
|
||||
# STL they use for C++. We need these multiple variants to catch all of those
|
||||
# versions of crosstool_top and reliably detect Android.
|
||||
#
|
||||
# For more info on the various crosstool_tops used by NDK Bazel builds, see:
|
||||
# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl
|
||||
|
||||
config_setting(
|
||||
name = "config_android",
|
||||
values = {
|
||||
"crosstool_top": "//external:android/crosstool",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "config_android-stlport",
|
||||
values = {
|
||||
"crosstool_top": "@androidndk//:toolchain-stlport",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "config_android-libcpp",
|
||||
values = {
|
||||
"crosstool_top": "@androidndk//:toolchain-libcpp",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "config_android-gnu-libstdcpp",
|
||||
values = {
|
||||
"crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "config_android-default",
|
||||
values = {
|
||||
"crosstool_top": "@androidndk//:default_crosstool",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "config_win32",
|
||||
values = {
|
||||
"cpu": "win32",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "config_win64",
|
||||
values = {
|
||||
"cpu": "win64",
|
||||
},
|
||||
)
|
||||
|
||||
# Internal testing:
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "any_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:any_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "api_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:api_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "compiler_plugin_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:compiler_plugin_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "descriptor_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:descriptor_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "duration_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:duration_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "empty_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:empty_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "field_mask_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:field_mask_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "source_context_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:source_context_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "struct_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:struct_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "timestamp_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:timestamp_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "type_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:type_proto"],
|
||||
)
|
||||
|
||||
starlark_cc_proto_library(
|
||||
name = "wrappers_cc_proto",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = ["//:wrappers_proto"],
|
||||
)
|
||||
|
||||
cc_proto_blacklist_test(
|
||||
name = "cc_proto_blacklist_test",
|
||||
deps = [
|
||||
":any_cc_proto",
|
||||
":api_cc_proto",
|
||||
":compiler_plugin_cc_proto",
|
||||
":descriptor_cc_proto",
|
||||
":duration_cc_proto",
|
||||
":empty_cc_proto",
|
||||
":field_mask_cc_proto",
|
||||
":source_context_cc_proto",
|
||||
":struct_cc_proto",
|
||||
":timestamp_cc_proto",
|
||||
":type_cc_proto",
|
||||
":wrappers_cc_proto",
|
||||
],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "dist_files",
|
||||
srcs = glob(["*"]),
|
||||
strip_prefix = strip_prefix.from_root(""),
|
||||
visibility = ["//pkg:__pkg__"],
|
||||
)
|
||||
38
third_party/protobuf/build_defs/cc_proto_blacklist_test.bzl
vendored
Normal file
38
third_party/protobuf/build_defs/cc_proto_blacklist_test.bzl
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Contains a unittest to verify that `cc_proto_library` does not generate code for blacklisted `.proto` sources (i.e. WKPs)."""
|
||||
|
||||
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
|
||||
|
||||
def _cc_proto_blacklist_test_impl(ctx):
|
||||
"""Verifies that there are no C++ compile actions for Well-Known-Protos.
|
||||
|
||||
Args:
|
||||
ctx: The rule context.
|
||||
|
||||
Returns: A (not further specified) sequence of providers.
|
||||
"""
|
||||
|
||||
env = unittest.begin(ctx)
|
||||
|
||||
for dep in ctx.attr.deps:
|
||||
files = dep.files.to_list()
|
||||
asserts.equals(
|
||||
env,
|
||||
[],
|
||||
files,
|
||||
"Expected that target '{}' does not provide files, got {}".format(
|
||||
dep.label,
|
||||
len(files),
|
||||
),
|
||||
)
|
||||
|
||||
return unittest.end(env)
|
||||
|
||||
cc_proto_blacklist_test = unittest.make(
|
||||
impl = _cc_proto_blacklist_test_impl,
|
||||
attrs = {
|
||||
"deps": attr.label_list(
|
||||
mandatory = True,
|
||||
providers = [CcInfo],
|
||||
),
|
||||
},
|
||||
)
|
||||
23
third_party/protobuf/build_defs/compiler_config_setting.bzl
vendored
Normal file
23
third_party/protobuf/build_defs/compiler_config_setting.bzl
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"""Creates config_setting that allows selecting based on 'compiler' value."""
|
||||
|
||||
def create_compiler_config_setting(name, value, visibility = None):
|
||||
# The "do_not_use_tools_cpp_compiler_present" attribute exists to
|
||||
# distinguish between older versions of Bazel that do not support
|
||||
# "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do.
|
||||
# In the future, the only way to select on the compiler will be through
|
||||
# flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
|
||||
# be removed.
|
||||
if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
|
||||
native.config_setting(
|
||||
name = name,
|
||||
flag_values = {
|
||||
"@bazel_tools//tools/cpp:compiler": value,
|
||||
},
|
||||
visibility = visibility,
|
||||
)
|
||||
else:
|
||||
native.config_setting(
|
||||
name = name,
|
||||
values = {"compiler": value},
|
||||
visibility = visibility,
|
||||
)
|
||||
47
third_party/protobuf/build_defs/cpp_opts.bzl
vendored
Normal file
47
third_party/protobuf/build_defs/cpp_opts.bzl
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# C++ compile/link options for Protobuf.
|
||||
|
||||
COPTS = select({
|
||||
"//build_defs:config_msvc": [
|
||||
"/wd4065", # switch statement contains 'default' but no 'case' labels
|
||||
"/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
|
||||
"/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
|
||||
"/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
|
||||
"/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
|
||||
"/wd4307", # 'operator' : integral constant overflow
|
||||
"/wd4309", # 'conversion' : truncation of constant value
|
||||
"/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
|
||||
"/wd4355", # 'this' : used in base member initializer list
|
||||
"/wd4506", # no definition for inline function 'function'
|
||||
"/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
|
||||
"/wd4996", # The compiler encountered a deprecated declaration.
|
||||
],
|
||||
"//conditions:default": [
|
||||
"-DHAVE_ZLIB",
|
||||
"-Woverloaded-virtual",
|
||||
"-Wno-sign-compare",
|
||||
],
|
||||
})
|
||||
|
||||
# Android and MSVC builds do not need to link in a separate pthread library.
|
||||
LINK_OPTS = select({
|
||||
"//build_defs:config_android": [],
|
||||
"//build_defs:config_android-stlport": [],
|
||||
"//build_defs:config_android-libcpp": [],
|
||||
"//build_defs:config_android-gnu-libstdcpp": [],
|
||||
"//build_defs:config_android-default": [],
|
||||
"//build_defs:config_msvc": [
|
||||
# Suppress linker warnings about files with no symbols defined.
|
||||
"-ignore:4221",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"-lpthread",
|
||||
"-lm",
|
||||
],
|
||||
})
|
||||
|
||||
# When cross-compiling for Windows we need to statically link pthread and the C++ library.
|
||||
PROTOC_LINK_OPTS = select({
|
||||
"//build_defs:config_win32": ["-static"],
|
||||
"//build_defs:config_win64": ["-static"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
Reference in New Issue
Block a user