mirror of https://github.com/mongodb/mongo
SERVER-88784 port GRPC to Bazel (#27150)
GitOrigin-RevId: f0700ed9a9673947f688e9fa1a0289f6324c662a
This commit is contained in:
parent
29641ad5c2
commit
159c935665
|
|
@ -92,21 +92,6 @@ load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitiv
|
|||
|
||||
hedron_compile_commands_setup_transitive_transitive_transitive()
|
||||
|
||||
http_archive(
|
||||
name = "rules_python",
|
||||
sha256 = "be04b635c7be4604be1ef20542e9870af3c49778ce841ee2d92fcb42f9d9516a",
|
||||
strip_prefix = "rules_python-0.35.0",
|
||||
urls = [
|
||||
# Implements retry by relisting each url multiple times to be used as a failover.
|
||||
# TODO(SERVER-86719): Re-implement http_archive to allow sleeping between retries
|
||||
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.35.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.35.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.35.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.35.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.35.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "platforms",
|
||||
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
|
||||
|
|
@ -211,3 +196,55 @@ npm_translate_lock(
|
|||
load("@npm//:repositories.bzl", "npm_repositories")
|
||||
|
||||
npm_repositories()
|
||||
|
||||
# Sub in the system openssl for boringssl since we don't want two implementations of
|
||||
# ssl in the same address space.
|
||||
new_local_repository(
|
||||
name = "boringssl",
|
||||
build_file_content = """
|
||||
cc_library(
|
||||
name = "crypto",
|
||||
linkopts = ["-lcrypto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
cc_library(
|
||||
name = "ssl",
|
||||
linkopts = ["-lssl"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
path = "bazel/_openssl_placeholder_for_grpc",
|
||||
)
|
||||
|
||||
# Overloads for the vendored repositories.
|
||||
#
|
||||
# WARNING: Don't change the order of the deps() calls and local_repositories.
|
||||
# They're read linearly dependencies that come first override later
|
||||
# ones. Dependency updates might change the correct order, though it's
|
||||
# unlikely. This is obviously a temporary solution and will no longer
|
||||
# be necessary once migration to bzlmod is complete.
|
||||
|
||||
# Note: rules_python is implicitly loaded with a grpc-compatible version.
|
||||
|
||||
local_repository(
|
||||
name = "com_google_absl",
|
||||
path = "src/third_party/abseil-cpp/dist",
|
||||
)
|
||||
|
||||
local_repository(
|
||||
name = "com_google_protobuf",
|
||||
path = "src/third_party/protobuf/dist",
|
||||
)
|
||||
|
||||
local_repository(
|
||||
name = "com_github_grpc_grpc",
|
||||
path = "src/third_party/grpc/dist",
|
||||
)
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
|
||||
|
||||
grpc_deps()
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
|
||||
|
||||
grpc_extra_deps()
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
# placeholder
|
||||
|
|
@ -4,6 +4,10 @@ BUILD files in the "src/" subtree.
|
|||
|
||||
load("@poetry//:dependencies.bzl", "dependency")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@com_github_grpc_grpc//bazel:generate_cc.bzl", "generate_cc")
|
||||
load("@com_github_grpc_grpc//bazel:protobuf.bzl", "well_known_proto_libs")
|
||||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
|
||||
load(
|
||||
"//bazel:header_deps.bzl",
|
||||
"HEADER_DEP_SUFFIX",
|
||||
|
|
@ -1328,6 +1332,7 @@ def mongo_cc_library(
|
|||
hdrs = [],
|
||||
textual_hdrs = [],
|
||||
deps = [],
|
||||
cc_deps = [],
|
||||
header_deps = [],
|
||||
testonly = False,
|
||||
visibility = None,
|
||||
|
|
@ -1354,6 +1359,7 @@ def mongo_cc_library(
|
|||
textual_hdrs: Textual headers. Might be used to include cpp files without
|
||||
compiling them.
|
||||
deps: The targets the library depends on.
|
||||
cc_deps: Same as deps, but doesn't get added as shared library dep.
|
||||
header_deps: The targets the library depends on only for headers, omits
|
||||
linking.
|
||||
testonly: Whether or not the target is purely for tests.
|
||||
|
|
@ -1461,7 +1467,7 @@ def mongo_cc_library(
|
|||
create_link_deps(
|
||||
name = name + LINK_DEP_SUFFIX,
|
||||
target_name = name,
|
||||
link_deps = [name] + deps,
|
||||
link_deps = [name] + deps + cc_deps,
|
||||
tags = ["scons_link_lists"],
|
||||
target_compatible_with = target_compatible_with + enterprise_compatible,
|
||||
)
|
||||
|
|
@ -1471,7 +1477,7 @@ def mongo_cc_library(
|
|||
name = name + SHARED_ARCHIVE_SUFFIX,
|
||||
srcs = srcs + SANITIZER_DENYLIST_HEADERS,
|
||||
hdrs = hdrs + fincludes_hdr + MONGO_GLOBAL_ACCESSIBLE_HEADERS,
|
||||
deps = deps + [name + HEADER_DEP_SUFFIX],
|
||||
deps = deps + cc_deps + [name + HEADER_DEP_SUFFIX],
|
||||
textual_hdrs = textual_hdrs,
|
||||
visibility = visibility,
|
||||
testonly = testonly,
|
||||
|
|
@ -1494,7 +1500,7 @@ def mongo_cc_library(
|
|||
name = name + WITH_DEBUG_SUFFIX,
|
||||
srcs = srcs + SANITIZER_DENYLIST_HEADERS,
|
||||
hdrs = hdrs + fincludes_hdr + MONGO_GLOBAL_ACCESSIBLE_HEADERS,
|
||||
deps = deps + [name + HEADER_DEP_SUFFIX],
|
||||
deps = deps + cc_deps + [name + HEADER_DEP_SUFFIX],
|
||||
textual_hdrs = textual_hdrs,
|
||||
visibility = visibility,
|
||||
testonly = testonly,
|
||||
|
|
@ -1509,7 +1515,7 @@ def mongo_cc_library(
|
|||
features = MONGO_GLOBAL_FEATURES + select({
|
||||
"//bazel/config:linkstatic_disabled": ["supports_pic", "pic"],
|
||||
"//bazel/config:shared_archive_enabled": ["supports_pic", "pic"],
|
||||
"//conditions:default": ["pie"],
|
||||
"//conditions:default": ["-pic", "pie"],
|
||||
}) + features,
|
||||
target_compatible_with = target_compatible_with + enterprise_compatible,
|
||||
additional_linker_inputs = additional_linker_inputs + MONGO_GLOBAL_ADDITIONAL_LINKER_INPUTS,
|
||||
|
|
@ -1552,7 +1558,7 @@ def mongo_cc_library(
|
|||
"//conditions:default": None,
|
||||
}),
|
||||
visibility = visibility,
|
||||
deps = deps + [name + HEADER_DEP_SUFFIX],
|
||||
deps = deps + cc_deps + [name + HEADER_DEP_SUFFIX],
|
||||
)
|
||||
|
||||
def _mongo_cc_binary_and_program(
|
||||
|
|
@ -1634,7 +1640,7 @@ def _mongo_cc_binary_and_program(
|
|||
"local_defines": MONGO_GLOBAL_DEFINES + local_defines,
|
||||
"defines": defines,
|
||||
"includes": includes,
|
||||
"features": MONGO_GLOBAL_FEATURES + ["pie"] + features + select({
|
||||
"features": MONGO_GLOBAL_FEATURES + ["-pic", "pie"] + features + select({
|
||||
"@platforms//os:windows": ["generate_pdb_file"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
|
|
@ -1914,3 +1920,118 @@ symlink = rule(
|
|||
),
|
||||
},
|
||||
)
|
||||
|
||||
def strip_deps_impl(ctx):
|
||||
cc_toolchain = find_cpp_toolchain(ctx)
|
||||
feature_configuration = cc_common.configure_features(
|
||||
ctx = ctx,
|
||||
cc_toolchain = cc_toolchain,
|
||||
requested_features = ctx.features,
|
||||
unsupported_features = ctx.disabled_features,
|
||||
)
|
||||
|
||||
linker_input = ctx.attr.input[CcInfo].linking_context.linker_inputs.to_list()[0]
|
||||
linking_context = cc_common.create_linking_context(linker_inputs = depset(direct = [linker_input], transitive = []))
|
||||
|
||||
return [DefaultInfo(files = ctx.attr.input.files), CcInfo(
|
||||
compilation_context = ctx.attr.input[CcInfo].compilation_context,
|
||||
linking_context = linking_context,
|
||||
)]
|
||||
|
||||
strip_deps = rule(
|
||||
strip_deps_impl,
|
||||
attrs = {
|
||||
"input": attr.label(
|
||||
providers = [CcInfo],
|
||||
),
|
||||
},
|
||||
provides = [CcInfo],
|
||||
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
|
||||
fragments = ["cpp"],
|
||||
)
|
||||
|
||||
def dummy_file_impl(ctx):
|
||||
ctx.actions.write(
|
||||
output = ctx.outputs.output,
|
||||
content = "",
|
||||
)
|
||||
|
||||
return [DefaultInfo(files = depset([ctx.outputs.output]))]
|
||||
|
||||
dummy_file = rule(
|
||||
dummy_file_impl,
|
||||
attrs = {
|
||||
"output": attr.output(
|
||||
doc = "The output of this rule.",
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
def mongo_proto_library(
|
||||
name,
|
||||
srcs,
|
||||
**kwargs):
|
||||
proto_library(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
dummy_file(
|
||||
name = name + "_dummy_debug_symbol",
|
||||
output = "lib" + name + ".so.debug",
|
||||
)
|
||||
|
||||
def mongo_cc_proto_library(
|
||||
name,
|
||||
deps,
|
||||
**kwargs):
|
||||
native.cc_proto_library(
|
||||
name = name,
|
||||
deps = deps,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
dummy_file(
|
||||
name = name + "_dummy_debug_symbol",
|
||||
output = "lib" + name + ".so.debug",
|
||||
)
|
||||
|
||||
def mongo_cc_grpc_library(
|
||||
name,
|
||||
srcs,
|
||||
cc_proto,
|
||||
deps = [],
|
||||
grpc_only = True,
|
||||
proto_only = False,
|
||||
well_known_protos = False,
|
||||
generate_mocks = False,
|
||||
**kwargs):
|
||||
codegen_grpc_target = "_" + name + "_grpc_codegen"
|
||||
generate_cc(
|
||||
name = codegen_grpc_target,
|
||||
srcs = srcs,
|
||||
plugin = "//src/third_party/grpc:grpc_cpp_plugin",
|
||||
well_known_protos = well_known_protos,
|
||||
generate_mocks = generate_mocks,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
# cc_proto_library tacks on unnecessary link-time dependencies to
|
||||
# @com_google_protobuf and @com_google_absl, forcefully remove them
|
||||
# to avoid intefering with thin targets link line generation.
|
||||
cc_proto_target = "_" + name + "_cc_proto_stripped_deps"
|
||||
strip_deps(
|
||||
name = cc_proto_target,
|
||||
input = cc_proto,
|
||||
)
|
||||
|
||||
mongo_cc_library(
|
||||
name = name,
|
||||
srcs = [":" + codegen_grpc_target],
|
||||
hdrs = [":" + codegen_grpc_target],
|
||||
deps = deps +
|
||||
["//src/third_party/grpc:grpc++_codegen_proto"],
|
||||
cc_deps = [":" + cc_proto_target],
|
||||
**kwargs
|
||||
)
|
||||
|
|
|
|||
|
|
@ -389,12 +389,12 @@ def _impl(ctx):
|
|||
|
||||
supports_pic_feature = feature(
|
||||
name = "supports_pic",
|
||||
enabled = False,
|
||||
enabled = True,
|
||||
)
|
||||
|
||||
pic_feature = feature(
|
||||
name = "pic",
|
||||
enabled = False,
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = [
|
||||
|
|
@ -603,6 +603,42 @@ def _impl(ctx):
|
|||
],
|
||||
)
|
||||
|
||||
# Warn when hiding a virtual function.
|
||||
overloaded_virtual_warning_feature = feature(
|
||||
name = "overloaded_virtual_warning",
|
||||
enabled = False,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_cpp_compile_actions,
|
||||
flag_groups = [flag_group(flags = ["-Woverloaded-virtual"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# Warn when hiding a virtual function.
|
||||
no_overloaded_virtual_warning_feature = feature(
|
||||
name = "no_overloaded_virtual_warning",
|
||||
enabled = False,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_cpp_compile_actions,
|
||||
flag_groups = [flag_group(flags = ["-Wno-overloaded-virtual"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# Warn about moves of prvalues, which can inhibit copy elision.
|
||||
pessimizing_move_warning_feature = feature(
|
||||
name = "pessimizing_move_warning",
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_cpp_compile_actions,
|
||||
flag_groups = [flag_group(flags = ["-Wpessimizing-move"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
features = [
|
||||
bin_dirs_feature,
|
||||
default_compile_flags_feature,
|
||||
|
|
@ -636,6 +672,9 @@ def _impl(ctx):
|
|||
no_deprecated_enum_enum_conversion_feature,
|
||||
no_volatile_feature,
|
||||
fsized_deallocation_feature,
|
||||
overloaded_virtual_warning_feature,
|
||||
no_overloaded_virtual_warning_feature,
|
||||
pessimizing_move_warning_feature,
|
||||
]
|
||||
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -119,8 +119,6 @@ def protoc_emitter(target, source, env):
|
|||
|
||||
new_targets += [env.File(f"{base_file_name}{ext}") for ext in exts]
|
||||
|
||||
env.Alias("generated-sources", new_targets)
|
||||
|
||||
return new_targets, source
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,8 @@ tlEnv.CppUnitTest(
|
|||
"$BUILD_DIR/mongo/util/concurrency/thread_pool",
|
||||
"$BUILD_DIR/mongo/util/periodic_runner_factory" if shouldBuildGRPC(tlEnv) else [],
|
||||
"$BUILD_DIR/third_party/asio-master/asio",
|
||||
"$BUILD_DIR/third_party/shim_grpc" if shouldBuildGRPC(tlEnv) else [],
|
||||
"$BUILD_DIR/third_party/grpc/grpc++_reflection" if shouldBuildGRPC(tlEnv) else [],
|
||||
"$BUILD_DIR/third_party/protobuf/protobuf" if shouldBuildGRPC(tlEnv) else [],
|
||||
"message_compressor",
|
||||
"message_compressor_options_server",
|
||||
"service_executor",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_library")
|
||||
load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_grpc_library", "mongo_cc_library", "mongo_cc_proto_library", "mongo_proto_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
|
@ -9,6 +9,11 @@ exports_files(
|
|||
]),
|
||||
)
|
||||
|
||||
GRPC_TARGET_COMPATIBLE_WITH = select({
|
||||
"//bazel/config:build_grpc_enabled": [],
|
||||
"//conditions:default": ["@platforms//:incompatible"],
|
||||
})
|
||||
|
||||
idl_generator(
|
||||
name = "grpc_feature_flag_gen",
|
||||
src = "grpc_feature_flag.idl",
|
||||
|
|
@ -21,3 +26,25 @@ idl_generator(
|
|||
name = "grpc_parameters_gen",
|
||||
src = "grpc_parameters.idl",
|
||||
)
|
||||
|
||||
mongo_proto_library(
|
||||
name = "core_test_proto",
|
||||
srcs = [
|
||||
"core_test.proto",
|
||||
],
|
||||
target_compatible_with = GRPC_TARGET_COMPATIBLE_WITH,
|
||||
)
|
||||
|
||||
mongo_cc_proto_library(
|
||||
name = "core_test_cc_proto",
|
||||
target_compatible_with = GRPC_TARGET_COMPATIBLE_WITH,
|
||||
deps = [":core_test_proto"],
|
||||
)
|
||||
|
||||
mongo_cc_grpc_library(
|
||||
name = "core_test_grpc_proto",
|
||||
srcs = [":core_test_proto"],
|
||||
cc_proto = ":core_test_cc_proto",
|
||||
generate_mocks = True,
|
||||
target_compatible_with = GRPC_TARGET_COMPATIBLE_WITH,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ env.Library(
|
|||
"$BUILD_DIR/mongo/util/options_parser/options_parser",
|
||||
],
|
||||
LIBDEPS=[
|
||||
"$BUILD_DIR/third_party/shim_grpc",
|
||||
"$BUILD_DIR/third_party/grpc/grpc++_reflection",
|
||||
"$BUILD_DIR/third_party/protobuf/protobuf",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -61,7 +62,8 @@ env.Library(
|
|||
"$BUILD_DIR/mongo/base",
|
||||
"$BUILD_DIR/mongo/db/service_context",
|
||||
"$BUILD_DIR/mongo/rpc/client_metadata",
|
||||
"$BUILD_DIR/third_party/shim_grpc",
|
||||
"$BUILD_DIR/third_party/grpc/grpc++_reflection",
|
||||
"$BUILD_DIR/third_party/protobuf/protobuf",
|
||||
"grpc_transport_layer",
|
||||
],
|
||||
)
|
||||
|
|
@ -89,7 +91,8 @@ env.CppUnitTest(
|
|||
"$BUILD_DIR/mongo/transport/service_executor",
|
||||
"$BUILD_DIR/mongo/util/clock_source_mock",
|
||||
"$BUILD_DIR/mongo/util/periodic_runner_factory",
|
||||
"$BUILD_DIR/third_party/shim_grpc",
|
||||
"$BUILD_DIR/third_party/grpc/grpc++_reflection",
|
||||
"$BUILD_DIR/third_party/protobuf/protobuf",
|
||||
"grpc_transport_layer",
|
||||
"grpc_transport_mock",
|
||||
],
|
||||
|
|
@ -112,6 +115,7 @@ protoEnv.AppendUnique(
|
|||
protoEnv.Append(
|
||||
CPPPATH=[
|
||||
"$BUILD_DIR/third_party/protobuf/dist/src",
|
||||
"#/bazel-bin",
|
||||
]
|
||||
)
|
||||
|
||||
|
|
@ -119,10 +123,11 @@ protoEnv.CppUnitTest(
|
|||
target="grpc_core_test",
|
||||
source=[
|
||||
"core_test.cpp",
|
||||
"core_test.proto",
|
||||
],
|
||||
LIBDEPS=[
|
||||
"$BUILD_DIR/mongo/base",
|
||||
"$BUILD_DIR/third_party/shim_grpc",
|
||||
"$BUILD_DIR/third_party/grpc/grpc++_reflection",
|
||||
"$BUILD_DIR/third_party/protobuf/protobuf",
|
||||
"core_test_grpc_proto",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2017 gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Contains build targets used by Starlark files in the bazel/ directory.
|
||||
"""
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
package(default_visibility = ["//:__subpackages__"])
|
||||
|
||||
filegroup(
|
||||
name = "_gevent_test_main",
|
||||
srcs = ["_gevent_test_main.py"],
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
set noparent
|
||||
@jtattermusch
|
||||
@veblush
|
||||
@gnossen
|
||||
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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 gevent
|
||||
from gevent import monkey
|
||||
|
||||
monkey.patch_all()
|
||||
threadpool = gevent.hub.get_hub().threadpool
|
||||
|
||||
# Currently, each channel corresponds to a single native thread in the
|
||||
# gevent threadpool. Thus, when the unit test suite spins up hundreds of
|
||||
# channels concurrently, some will be starved out, causing the test to
|
||||
# increase in duration. We increase the max size here so this does not
|
||||
# happen.
|
||||
threadpool.maxsize = 1024
|
||||
threadpool.size = 32
|
||||
|
||||
import traceback, signal
|
||||
from typing import Sequence
|
||||
|
||||
|
||||
import grpc.experimental.gevent
|
||||
grpc.experimental.gevent.init_gevent()
|
||||
|
||||
import gevent
|
||||
import greenlet
|
||||
import datetime
|
||||
|
||||
import grpc
|
||||
import unittest
|
||||
import sys
|
||||
import os
|
||||
import pkgutil
|
||||
import importlib
|
||||
|
||||
def trace_callback(event, args):
|
||||
if event in ("switch", "throw"):
|
||||
origin, target = args
|
||||
sys.stderr.write("{} Transfer from {} to {} with {}\n".format(datetime.datetime.now(), origin, target, event))
|
||||
else:
|
||||
sys.stderr.write("Unknown event {}.\n".format(event))
|
||||
sys.stderr.flush()
|
||||
|
||||
if os.getenv("GREENLET_TRACE") is not None:
|
||||
greenlet.settrace(trace_callback)
|
||||
|
||||
def debug(sig, frame):
|
||||
d={'_frame':frame}
|
||||
d.update(frame.f_globals)
|
||||
d.update(frame.f_locals)
|
||||
|
||||
sys.stderr.write("Traceback:\n{}".format("\n".join(traceback.format_stack(frame))))
|
||||
import gevent.util; gevent.util.print_run_info()
|
||||
sys.stderr.flush()
|
||||
|
||||
signal.signal(signal.SIGTERM, debug)
|
||||
|
||||
|
||||
class SingleLoader(object):
|
||||
def __init__(self, pattern: str):
|
||||
loader = unittest.TestLoader()
|
||||
self.suite = unittest.TestSuite()
|
||||
tests = []
|
||||
for importer, module_name, is_package in pkgutil.walk_packages([os.path.dirname(os.path.relpath(__file__))]):
|
||||
if pattern in module_name:
|
||||
spec = importer.find_spec(module_name)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
tests.append(loader.loadTestsFromModule(module))
|
||||
if len(tests) != 1:
|
||||
raise AssertionError("Expected only 1 test module. Found {}".format(tests))
|
||||
self.suite.addTest(tests[0])
|
||||
|
||||
|
||||
def loadTestsFromNames(self, names: Sequence[str], module: str = None) -> unittest.TestSuite:
|
||||
return self.suite
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print(f"USAGE: {sys.argv[0]} TARGET_MODULE", file=sys.stderr)
|
||||
|
||||
target_module = sys.argv[1]
|
||||
|
||||
loader = SingleLoader(target_module)
|
||||
runner = unittest.TextTestRunner()
|
||||
|
||||
result = gevent.spawn(runner.run, loader.suite)
|
||||
result.join()
|
||||
if not result.value.wasSuccessful():
|
||||
sys.exit("Test failure.")
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Generates and compiles C++ grpc stubs from proto_library rules."""
|
||||
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("//bazel:generate_cc.bzl", "generate_cc")
|
||||
load("//bazel:protobuf.bzl", "well_known_proto_libs")
|
||||
|
||||
def cc_grpc_library(
|
||||
name,
|
||||
srcs,
|
||||
deps,
|
||||
proto_only = False,
|
||||
well_known_protos = False,
|
||||
generate_mocks = False,
|
||||
use_external = False,
|
||||
grpc_only = False,
|
||||
**kwargs):
|
||||
"""Generates C++ grpc classes for services defined in a proto file.
|
||||
|
||||
If grpc_only is True, this rule is compatible with proto_library and
|
||||
cc_proto_library native rules such that it expects proto_library target
|
||||
as srcs argument and generates only grpc library classes, expecting
|
||||
protobuf messages classes library (cc_proto_library target) to be passed in
|
||||
deps argument. By default grpc_only is False which makes this rule to behave
|
||||
in a backwards-compatible mode (trying to generate both proto and grpc
|
||||
classes).
|
||||
|
||||
Assumes the generated classes will be used in cc_api_version = 2.
|
||||
|
||||
Args:
|
||||
name (str): Name of rule.
|
||||
srcs (list): A single .proto file which contains services definitions,
|
||||
or if grpc_only parameter is True, a single proto_library which
|
||||
contains services descriptors.
|
||||
deps (list): A list of C++ proto_library (or cc_proto_library) which
|
||||
provides the compiled code of any message that the services depend on.
|
||||
proto_only (bool): If True, create only C++ proto classes library,
|
||||
avoid creating C++ grpc classes library (expect it in deps).
|
||||
Deprecated, use native cc_proto_library instead. False by default.
|
||||
well_known_protos (bool): Should this library additionally depend on
|
||||
well known protos. Deprecated, the well known protos should be
|
||||
specified as explicit dependencies of the proto_library target
|
||||
(passed in srcs parameter) instead. False by default.
|
||||
generate_mocks (bool): when True, Google Mock code for client stub is
|
||||
generated. False by default.
|
||||
use_external (bool): Not used.
|
||||
grpc_only (bool): if True, generate only grpc library, expecting
|
||||
protobuf messages library (cc_proto_library target) to be passed as
|
||||
deps. False by default (will become True by default eventually).
|
||||
**kwargs: rest of arguments, e.g., compatible_with and visibility
|
||||
"""
|
||||
if len(srcs) > 1:
|
||||
fail("Only one srcs value supported", "srcs")
|
||||
if grpc_only and proto_only:
|
||||
fail("A mutualy exclusive configuration is specified: grpc_only = True and proto_only = True")
|
||||
|
||||
extra_deps = []
|
||||
proto_targets = []
|
||||
|
||||
if not grpc_only:
|
||||
proto_target = "_" + name + "_only"
|
||||
cc_proto_target = name if proto_only else "_" + name + "_cc_proto"
|
||||
|
||||
proto_deps = ["_" + dep + "_only" for dep in deps if dep.find(":") == -1]
|
||||
proto_deps += [dep.split(":")[0] + ":" + "_" + dep.split(":")[1] + "_only" for dep in deps if dep.find(":") != -1 and dep.find("com_google_googleapis") == -1]
|
||||
proto_deps += [dep for dep in deps if dep.find("com_google_googleapis") != -1]
|
||||
if well_known_protos:
|
||||
proto_deps += well_known_proto_libs()
|
||||
proto_library(
|
||||
name = proto_target,
|
||||
srcs = srcs,
|
||||
deps = proto_deps,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
native.cc_proto_library(
|
||||
name = cc_proto_target,
|
||||
deps = [":" + proto_target],
|
||||
**kwargs
|
||||
)
|
||||
extra_deps.append(":" + cc_proto_target)
|
||||
proto_targets.append(proto_target)
|
||||
else:
|
||||
if not srcs:
|
||||
fail("srcs cannot be empty", "srcs")
|
||||
proto_targets += srcs
|
||||
|
||||
if not proto_only:
|
||||
codegen_grpc_target = "_" + name + "_grpc_codegen"
|
||||
generate_cc(
|
||||
name = codegen_grpc_target,
|
||||
srcs = proto_targets,
|
||||
plugin = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin",
|
||||
well_known_protos = well_known_protos,
|
||||
generate_mocks = generate_mocks,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
native.cc_library(
|
||||
name = name,
|
||||
srcs = [":" + codegen_grpc_target],
|
||||
hdrs = [":" + codegen_grpc_target],
|
||||
deps = deps +
|
||||
extra_deps +
|
||||
["@com_github_grpc_grpc//:grpc++_codegen_proto"],
|
||||
**kwargs
|
||||
)
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
# Copyright 2021 the gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Includes default copts.
|
||||
"""
|
||||
|
||||
# This is a list of llvm flags to be used when being built with use_strict_warning=1
|
||||
GRPC_LLVM_WARNING_FLAGS = [
|
||||
# Enable all & extra warnings
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
# Avoid some known traps
|
||||
"-Wimplicit-fallthrough",
|
||||
# Consider warnings as errors
|
||||
"-Werror",
|
||||
# Ignore unknown warning flags
|
||||
"-Wno-unknown-warning-option",
|
||||
# A list of enabled flags coming from internal build system
|
||||
"-Wc++20-extensions",
|
||||
"-Wctad-maybe-unsupported",
|
||||
"-Wdeprecated-increment-bool",
|
||||
"-Wfloat-overflow-conversion",
|
||||
"-Wfloat-zero-conversion",
|
||||
"-Wfor-loop-analysis",
|
||||
"-Wformat-security",
|
||||
"-Wgnu-redeclared-enum",
|
||||
"-Winfinite-recursion",
|
||||
"-Wliteral-conversion",
|
||||
"-Wnon-virtual-dtor",
|
||||
"-Woverloaded-virtual",
|
||||
"-Wself-assign",
|
||||
"-Wstring-conversion",
|
||||
"-Wtautological-overlap-compare",
|
||||
"-Wthread-safety-analysis",
|
||||
"-Wthread-safety-beta",
|
||||
"-Wunused-but-set-variable",
|
||||
"-Wunused-comparison",
|
||||
"-Wvla",
|
||||
# -Wextra compatibility between gcc and clang
|
||||
"-Wtype-limits",
|
||||
# A list of disabled flags coming from internal build system
|
||||
"-Wno-string-concatenation",
|
||||
# Exceptions but will be removed
|
||||
"-Wno-deprecated-declarations",
|
||||
"-Wno-unused-function",
|
||||
]
|
||||
|
||||
GRPC_DEFAULT_COPTS = select({
|
||||
"//:use_strict_warning": GRPC_LLVM_WARNING_FLAGS + ["-DUSE_STRICT_WARNING=1"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2019 The gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Reimports constants from the grpc_custom_exec_properties repo.
|
||||
"""
|
||||
|
||||
load("@grpc_custom_exec_properties//:constants.bzl", _LARGE_MACHINE = "LARGE_MACHINE")
|
||||
|
||||
LARGE_MACHINE = _LARGE_MACHINE
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Custom rules for gRPC Python"""
|
||||
|
||||
# Adapted with modifications from
|
||||
# tensorflow/tensorflow/core/platform/default/build_config.bzl
|
||||
# Native Bazel rules don't exist yet to compile Cython code, but rules have
|
||||
# been written at cython/cython and tensorflow/tensorflow. We branch from
|
||||
# Tensorflow's version as it is more actively maintained and works for gRPC
|
||||
# Python's needs.
|
||||
def pyx_library(name, deps = [], py_deps = [], srcs = [], **kwargs):
|
||||
"""Compiles a group of .pyx / .pxd / .py files.
|
||||
|
||||
First runs Cython to create .cpp files for each input .pyx or .py + .pxd
|
||||
pair. Then builds a shared object for each, passing "deps" to each cc_binary
|
||||
rule (includes Python headers by default). Finally, creates a py_library rule
|
||||
with the shared objects and any pure Python "srcs", with py_deps as its
|
||||
dependencies; the shared objects can be imported like normal Python files.
|
||||
|
||||
Args:
|
||||
name: Name for the rule.
|
||||
deps: C/C++ dependencies of the Cython (e.g. Numpy headers).
|
||||
py_deps: Pure Python dependencies of the final library.
|
||||
srcs: .py, .pyx, or .pxd files to either compile or pass through.
|
||||
**kwargs: Extra keyword arguments passed to the py_library.
|
||||
"""
|
||||
|
||||
# First filter out files that should be run compiled vs. passed through.
|
||||
py_srcs = []
|
||||
pyx_srcs = []
|
||||
pxd_srcs = []
|
||||
for src in srcs:
|
||||
if src.endswith(".pyx") or (src.endswith(".py") and
|
||||
src[:-3] + ".pxd" in srcs):
|
||||
pyx_srcs.append(src)
|
||||
elif src.endswith(".py"):
|
||||
py_srcs.append(src)
|
||||
else:
|
||||
pxd_srcs.append(src)
|
||||
if src.endswith("__init__.py"):
|
||||
pxd_srcs.append(src)
|
||||
|
||||
# Invoke cython to produce the shared object libraries.
|
||||
for filename in pyx_srcs:
|
||||
native.genrule(
|
||||
name = filename + "_cython_translation",
|
||||
srcs = [filename],
|
||||
outs = [filename.split(".")[0] + ".cpp"],
|
||||
# Optionally use PYTHON_BIN_PATH on Linux platforms so that python 3
|
||||
# works. Windows has issues with cython_binary so skip PYTHON_BIN_PATH.
|
||||
cmd =
|
||||
"PYTHONHASHSEED=0 $(location @cython//:cython_binary) --cplus $(SRCS) --output-file $(OUTS)",
|
||||
tools = ["@cython//:cython_binary"] + pxd_srcs,
|
||||
)
|
||||
|
||||
shared_objects = []
|
||||
defines = kwargs.pop("defines", [])
|
||||
for src in pyx_srcs:
|
||||
stem = src.split(".")[0]
|
||||
shared_object_name = stem + ".so"
|
||||
native.cc_binary(
|
||||
name = shared_object_name,
|
||||
srcs = [stem + ".cpp"],
|
||||
deps = deps + ["@local_config_python//:python_headers"],
|
||||
defines = defines,
|
||||
linkshared = 1,
|
||||
)
|
||||
shared_objects.append(shared_object_name)
|
||||
|
||||
data = shared_objects[:]
|
||||
data += kwargs.pop("data", [])
|
||||
|
||||
# Now create a py_library with these shared objects as data.
|
||||
native.py_library(
|
||||
name = name,
|
||||
srcs = py_srcs,
|
||||
deps = py_deps,
|
||||
srcs_version = "PY2AND3",
|
||||
data = data,
|
||||
**kwargs
|
||||
)
|
||||
|
|
@ -0,0 +1,270 @@
|
|||
# Copyright 2023 gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Auto generated by tools/codegen/core/gen_experiments.py
|
||||
|
||||
"""Dictionary of tags to experiments so we know when to test different experiments."""
|
||||
|
||||
EXPERIMENTS = {
|
||||
"windows": {
|
||||
"dbg": {
|
||||
},
|
||||
"off": {
|
||||
"core_end2end_test": [
|
||||
"event_engine_listener",
|
||||
"promise_based_client_call",
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"cpp_end2end_test": [
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"endpoint_test": [
|
||||
"tcp_frame_size_tuning",
|
||||
"tcp_rcv_lowat",
|
||||
],
|
||||
"event_engine_listener_test": [
|
||||
"event_engine_listener",
|
||||
],
|
||||
"flow_control_test": [
|
||||
"multiping",
|
||||
"peer_state_based_framing",
|
||||
"red_max_concurrent_streams",
|
||||
"rstpit",
|
||||
"tcp_frame_size_tuning",
|
||||
"tcp_rcv_lowat",
|
||||
],
|
||||
"lame_client_test": [
|
||||
"promise_based_client_call",
|
||||
],
|
||||
"lb_unit_test": [
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"logging_test": [
|
||||
"promise_based_server_call",
|
||||
],
|
||||
"resource_quota_test": [
|
||||
"free_large_allocator",
|
||||
"memory_pressure_controller",
|
||||
"unconstrained_max_quota_buffer_size",
|
||||
],
|
||||
"xds_end2end_test": [
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
},
|
||||
"on": {
|
||||
"bad_client_test": [
|
||||
"block_excessive_requests_before_settings_ack",
|
||||
"tarpit",
|
||||
],
|
||||
"cpp_end2end_test": [
|
||||
"chttp2_offload_on_rst_stream",
|
||||
],
|
||||
"cpp_lb_end2end_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
"flow_control_test": [
|
||||
"chttp2_offload_on_rst_stream",
|
||||
"lazier_stream_updates",
|
||||
"overload_protection",
|
||||
"write_size_cap",
|
||||
"write_size_policy",
|
||||
],
|
||||
"lb_unit_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
"surface_registered_method_lookup": [
|
||||
"registered_method_lookup_in_transport",
|
||||
],
|
||||
"xds_end2end_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
},
|
||||
},
|
||||
"ios": {
|
||||
"dbg": {
|
||||
},
|
||||
"off": {
|
||||
"core_end2end_test": [
|
||||
"event_engine_listener",
|
||||
"promise_based_client_call",
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"cpp_end2end_test": [
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"endpoint_test": [
|
||||
"tcp_frame_size_tuning",
|
||||
"tcp_rcv_lowat",
|
||||
],
|
||||
"event_engine_listener_test": [
|
||||
"event_engine_listener",
|
||||
],
|
||||
"flow_control_test": [
|
||||
"multiping",
|
||||
"peer_state_based_framing",
|
||||
"red_max_concurrent_streams",
|
||||
"rstpit",
|
||||
"tcp_frame_size_tuning",
|
||||
"tcp_rcv_lowat",
|
||||
],
|
||||
"lame_client_test": [
|
||||
"promise_based_client_call",
|
||||
],
|
||||
"lb_unit_test": [
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"logging_test": [
|
||||
"promise_based_server_call",
|
||||
],
|
||||
"resource_quota_test": [
|
||||
"free_large_allocator",
|
||||
"memory_pressure_controller",
|
||||
"unconstrained_max_quota_buffer_size",
|
||||
],
|
||||
"xds_end2end_test": [
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
},
|
||||
"on": {
|
||||
"bad_client_test": [
|
||||
"block_excessive_requests_before_settings_ack",
|
||||
"tarpit",
|
||||
],
|
||||
"cpp_end2end_test": [
|
||||
"chttp2_offload_on_rst_stream",
|
||||
],
|
||||
"cpp_lb_end2end_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
"flow_control_test": [
|
||||
"chttp2_offload_on_rst_stream",
|
||||
"lazier_stream_updates",
|
||||
"overload_protection",
|
||||
"write_size_cap",
|
||||
"write_size_policy",
|
||||
],
|
||||
"lb_unit_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
"surface_registered_method_lookup": [
|
||||
"registered_method_lookup_in_transport",
|
||||
],
|
||||
"xds_end2end_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
},
|
||||
},
|
||||
"posix": {
|
||||
"dbg": {
|
||||
},
|
||||
"off": {
|
||||
"cancel_ares_query_test": [
|
||||
"event_engine_dns",
|
||||
],
|
||||
"core_end2end_test": [
|
||||
"event_engine_client",
|
||||
"event_engine_listener",
|
||||
"promise_based_client_call",
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"cpp_end2end_test": [
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"endpoint_test": [
|
||||
"tcp_frame_size_tuning",
|
||||
"tcp_rcv_lowat",
|
||||
],
|
||||
"event_engine_client_test": [
|
||||
"event_engine_client",
|
||||
],
|
||||
"event_engine_listener_test": [
|
||||
"event_engine_listener",
|
||||
],
|
||||
"flow_control_test": [
|
||||
"multiping",
|
||||
"peer_state_based_framing",
|
||||
"red_max_concurrent_streams",
|
||||
"rstpit",
|
||||
"tcp_frame_size_tuning",
|
||||
"tcp_rcv_lowat",
|
||||
],
|
||||
"lame_client_test": [
|
||||
"promise_based_client_call",
|
||||
],
|
||||
"lb_unit_test": [
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
"logging_test": [
|
||||
"promise_based_server_call",
|
||||
],
|
||||
"resolver_component_tests_runner_invoker": [
|
||||
"event_engine_dns",
|
||||
],
|
||||
"resource_quota_test": [
|
||||
"free_large_allocator",
|
||||
"memory_pressure_controller",
|
||||
"unconstrained_max_quota_buffer_size",
|
||||
],
|
||||
"xds_end2end_test": [
|
||||
"promise_based_server_call",
|
||||
"work_serializer_dispatch",
|
||||
],
|
||||
},
|
||||
"on": {
|
||||
"bad_client_test": [
|
||||
"block_excessive_requests_before_settings_ack",
|
||||
"tarpit",
|
||||
],
|
||||
"cpp_end2end_test": [
|
||||
"chttp2_offload_on_rst_stream",
|
||||
],
|
||||
"cpp_lb_end2end_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
"flow_control_test": [
|
||||
"chttp2_offload_on_rst_stream",
|
||||
"lazier_stream_updates",
|
||||
"overload_protection",
|
||||
"write_size_cap",
|
||||
"write_size_policy",
|
||||
],
|
||||
"lb_unit_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
"surface_registered_method_lookup": [
|
||||
"registered_method_lookup_in_transport",
|
||||
],
|
||||
"xds_end2end_test": [
|
||||
"round_robin_delegate_to_pick_first",
|
||||
"wrr_delegate_to_pick_first",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Generates C++ grpc stubs from proto_library rules.
|
||||
|
||||
This is an internal rule used by cc_grpc_library, and shouldn't be used
|
||||
directly.
|
||||
"""
|
||||
|
||||
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
|
||||
load(
|
||||
"//bazel:protobuf.bzl",
|
||||
"get_include_directory",
|
||||
"get_plugin_args",
|
||||
"get_proto_root",
|
||||
"proto_path_to_generated_filename",
|
||||
)
|
||||
|
||||
_GRPC_PROTO_HEADER_FMT = "{}.grpc.pb.h"
|
||||
_GRPC_PROTO_SRC_FMT = "{}.grpc.pb.cc"
|
||||
_GRPC_PROTO_MOCK_HEADER_FMT = "{}_mock.grpc.pb.h"
|
||||
_PROTO_HEADER_FMT = "{}.pb.h"
|
||||
_PROTO_SRC_FMT = "{}.pb.cc"
|
||||
|
||||
def _strip_package_from_path(label_package, file):
|
||||
prefix_len = 0
|
||||
if not file.is_source and file.path.startswith(file.root.path):
|
||||
prefix_len = len(file.root.path) + 1
|
||||
|
||||
path = file.path
|
||||
if len(label_package) == 0:
|
||||
return path
|
||||
if not path.startswith(label_package + "/", prefix_len):
|
||||
fail("'{}' does not lie within '{}'.".format(path, label_package))
|
||||
return path[prefix_len + len(label_package + "/"):]
|
||||
|
||||
def _get_srcs_file_path(file):
|
||||
if not file.is_source and file.path.startswith(file.root.path):
|
||||
return file.path[len(file.root.path) + 1:]
|
||||
return file.path
|
||||
|
||||
def _join_directories(directories):
|
||||
massaged_directories = [directory for directory in directories if len(directory) != 0]
|
||||
return "/".join(massaged_directories)
|
||||
|
||||
def generate_cc_impl(ctx):
|
||||
"""Implementation of the generate_cc rule.
|
||||
|
||||
Args:
|
||||
ctx: The context object.
|
||||
Returns:
|
||||
The provider for the generated files.
|
||||
"""
|
||||
protos = [f for src in ctx.attr.srcs for f in src[ProtoInfo].check_deps_sources.to_list()]
|
||||
includes = [
|
||||
f
|
||||
for src in ctx.attr.srcs
|
||||
for f in src[ProtoInfo].transitive_imports.to_list()
|
||||
]
|
||||
outs = []
|
||||
proto_root = get_proto_root(
|
||||
ctx.label.workspace_root,
|
||||
)
|
||||
|
||||
label_package = _join_directories([ctx.label.workspace_root, ctx.label.package])
|
||||
if ctx.executable.plugin:
|
||||
outs += [
|
||||
proto_path_to_generated_filename(
|
||||
_strip_package_from_path(label_package, proto),
|
||||
_GRPC_PROTO_HEADER_FMT,
|
||||
)
|
||||
for proto in protos
|
||||
]
|
||||
outs += [
|
||||
proto_path_to_generated_filename(
|
||||
_strip_package_from_path(label_package, proto),
|
||||
_GRPC_PROTO_SRC_FMT,
|
||||
)
|
||||
for proto in protos
|
||||
]
|
||||
if ctx.attr.generate_mocks:
|
||||
outs += [
|
||||
proto_path_to_generated_filename(
|
||||
_strip_package_from_path(label_package, proto),
|
||||
_GRPC_PROTO_MOCK_HEADER_FMT,
|
||||
)
|
||||
for proto in protos
|
||||
]
|
||||
else:
|
||||
outs += [
|
||||
proto_path_to_generated_filename(
|
||||
_strip_package_from_path(label_package, proto),
|
||||
_PROTO_HEADER_FMT,
|
||||
)
|
||||
for proto in protos
|
||||
]
|
||||
outs += [
|
||||
proto_path_to_generated_filename(
|
||||
_strip_package_from_path(label_package, proto),
|
||||
_PROTO_SRC_FMT,
|
||||
)
|
||||
for proto in protos
|
||||
]
|
||||
out_files = [ctx.actions.declare_file(out) for out in outs]
|
||||
dir_out = str(ctx.genfiles_dir.path + proto_root)
|
||||
|
||||
arguments = []
|
||||
if ctx.executable.plugin:
|
||||
arguments += get_plugin_args(
|
||||
ctx.executable.plugin,
|
||||
ctx.attr.flags,
|
||||
dir_out,
|
||||
ctx.attr.generate_mocks,
|
||||
)
|
||||
tools = [ctx.executable.plugin]
|
||||
else:
|
||||
arguments.append("--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out)
|
||||
tools = []
|
||||
|
||||
arguments += [
|
||||
"--proto_path={}".format(get_include_directory(i))
|
||||
for i in includes
|
||||
]
|
||||
|
||||
# Include the output directory so that protoc puts the generated code in the
|
||||
# right directory.
|
||||
arguments.append("--proto_path={0}{1}".format(dir_out, proto_root))
|
||||
arguments += [_get_srcs_file_path(proto) for proto in protos]
|
||||
|
||||
# create a list of well known proto files if the argument is non-None
|
||||
well_known_proto_files = []
|
||||
if ctx.attr.well_known_protos:
|
||||
f = ctx.attr.well_known_protos.files.to_list()[0].dirname
|
||||
if f != "external/com_google_protobuf/src/google/protobuf":
|
||||
print(
|
||||
"Error: Only @com_google_protobuf//:well_known_type_protos is supported",
|
||||
) # buildifier: disable=print
|
||||
else:
|
||||
# f points to "external/com_google_protobuf/src/google/protobuf"
|
||||
# add -I argument to protoc so it knows where to look for the proto files.
|
||||
arguments.append("-I{0}".format(f + "/../.."))
|
||||
well_known_proto_files = [
|
||||
f
|
||||
for f in ctx.attr.well_known_protos.files.to_list()
|
||||
]
|
||||
|
||||
ctx.actions.run(
|
||||
inputs = protos + includes + well_known_proto_files,
|
||||
tools = tools,
|
||||
outputs = out_files,
|
||||
executable = ctx.executable._protoc,
|
||||
arguments = arguments,
|
||||
use_default_shell_env = True,
|
||||
)
|
||||
|
||||
return DefaultInfo(files = depset(out_files))
|
||||
|
||||
_generate_cc = rule(
|
||||
attrs = {
|
||||
"srcs": attr.label_list(
|
||||
mandatory = True,
|
||||
allow_empty = False,
|
||||
providers = [ProtoInfo],
|
||||
),
|
||||
"plugin": attr.label(
|
||||
executable = True,
|
||||
providers = ["files_to_run"],
|
||||
cfg = "host",
|
||||
),
|
||||
"flags": attr.string_list(
|
||||
mandatory = False,
|
||||
allow_empty = True,
|
||||
),
|
||||
"well_known_protos": attr.label(mandatory = False),
|
||||
"generate_mocks": attr.bool(
|
||||
default = False,
|
||||
mandatory = False,
|
||||
),
|
||||
"_protoc": attr.label(
|
||||
default = Label("//external:protocol_compiler"),
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
),
|
||||
},
|
||||
# We generate .h files, so we need to output to genfiles.
|
||||
output_to_genfiles = True,
|
||||
implementation = generate_cc_impl,
|
||||
)
|
||||
|
||||
def generate_cc(well_known_protos, **kwargs):
|
||||
if well_known_protos:
|
||||
_generate_cc(
|
||||
well_known_protos = "@com_google_protobuf//:well_known_type_protos",
|
||||
**kwargs
|
||||
)
|
||||
else:
|
||||
_generate_cc(**kwargs)
|
||||
|
|
@ -0,0 +1,243 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
This module contains build rules relating to gRPC Objective-C.
|
||||
"""
|
||||
|
||||
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
|
||||
load(
|
||||
"//bazel:protobuf.bzl",
|
||||
"get_include_directory",
|
||||
"get_plugin_args",
|
||||
"proto_path_to_generated_filename",
|
||||
)
|
||||
load(":grpc_util.bzl", "to_upper_camel_with_extension")
|
||||
|
||||
_GRPC_PROTO_HEADER_FMT = "{}.pbrpc.h"
|
||||
_GRPC_PROTO_SRC_FMT = "{}.pbrpc.m"
|
||||
_PROTO_HEADER_FMT = "{}.pbobjc.h"
|
||||
_PROTO_SRC_FMT = "{}.pbobjc.m"
|
||||
_GENERATED_PROTOS_DIR = "_generated_protos"
|
||||
|
||||
_GENERATE_HDRS = 1
|
||||
_GENERATE_SRCS = 2
|
||||
_GENERATE_NON_ARC_SRCS = 3
|
||||
|
||||
def _generate_objc_impl(ctx):
|
||||
"""Implementation of the generate_objc rule."""
|
||||
protos = [
|
||||
f
|
||||
for src in ctx.attr.deps
|
||||
for f in src[ProtoInfo].transitive_imports.to_list()
|
||||
]
|
||||
|
||||
target_package = _join_directories([ctx.label.workspace_root, ctx.label.package])
|
||||
|
||||
files_with_rpc = [_label_to_full_file_path(f, target_package) for f in ctx.attr.srcs]
|
||||
|
||||
outs = []
|
||||
for proto in protos:
|
||||
outs.append(_get_output_file_name_from_proto(proto, _PROTO_HEADER_FMT))
|
||||
outs.append(_get_output_file_name_from_proto(proto, _PROTO_SRC_FMT))
|
||||
|
||||
file_path = _get_full_path_from_file(proto)
|
||||
if file_path in files_with_rpc:
|
||||
outs.append(_get_output_file_name_from_proto(proto, _GRPC_PROTO_HEADER_FMT))
|
||||
outs.append(_get_output_file_name_from_proto(proto, _GRPC_PROTO_SRC_FMT))
|
||||
|
||||
out_files = [ctx.actions.declare_file(out) for out in outs]
|
||||
dir_out = _join_directories([
|
||||
str(ctx.genfiles_dir.path),
|
||||
target_package,
|
||||
_GENERATED_PROTOS_DIR,
|
||||
])
|
||||
|
||||
arguments = []
|
||||
tools = []
|
||||
if ctx.executable.plugin:
|
||||
arguments += get_plugin_args(
|
||||
ctx.executable.plugin,
|
||||
[],
|
||||
dir_out,
|
||||
False,
|
||||
)
|
||||
tools = [ctx.executable.plugin]
|
||||
arguments.append("--objc_out=" + dir_out)
|
||||
|
||||
arguments.append("--proto_path=.")
|
||||
arguments += [
|
||||
"--proto_path={}".format(get_include_directory(i))
|
||||
for i in protos
|
||||
]
|
||||
|
||||
# Include the output directory so that protoc puts the generated code in the
|
||||
# right directory.
|
||||
arguments.append("--proto_path={}".format(dir_out))
|
||||
arguments += ["--proto_path={}".format(_get_directory_from_proto(proto)) for proto in protos]
|
||||
arguments += [_get_full_path_from_file(proto) for proto in protos]
|
||||
|
||||
# create a list of well known proto files if the argument is non-None
|
||||
well_known_proto_files = []
|
||||
if ctx.attr.use_well_known_protos:
|
||||
f = ctx.attr.well_known_protos.files.to_list()[0].dirname
|
||||
|
||||
# go two levels up so that #import "google/protobuf/..." is correct
|
||||
arguments.append("-I{0}".format(f + "/../.."))
|
||||
well_known_proto_files = ctx.attr.well_known_protos.files.to_list()
|
||||
ctx.actions.run(
|
||||
inputs = protos + well_known_proto_files,
|
||||
tools = tools,
|
||||
outputs = out_files,
|
||||
executable = ctx.executable._protoc,
|
||||
arguments = arguments,
|
||||
)
|
||||
|
||||
return struct(files = depset(out_files)) # buildifier: disable=rule-impl-return
|
||||
|
||||
def _label_to_full_file_path(src, package):
|
||||
if not src.startswith("//"):
|
||||
# Relative from current package
|
||||
if not src.startswith(":"):
|
||||
# "a.proto" -> ":a.proto"
|
||||
src = ":" + src
|
||||
src = "//" + package + src
|
||||
|
||||
# Converts //path/to/package:File.ext to path/to/package/File.ext.
|
||||
src = src.replace("//", "")
|
||||
src = src.replace(":", "/")
|
||||
if src.startswith("/"):
|
||||
# "//:a.proto" -> "/a.proto" so remove the initial slash
|
||||
return src[1:]
|
||||
else:
|
||||
return src
|
||||
|
||||
def _get_output_file_name_from_proto(proto, fmt):
|
||||
return proto_path_to_generated_filename(
|
||||
_GENERATED_PROTOS_DIR + "/" +
|
||||
_get_directory_from_proto(proto) + _get_slash_or_null_from_proto(proto) +
|
||||
to_upper_camel_with_extension(_get_file_name_from_proto(proto), "proto"),
|
||||
fmt,
|
||||
)
|
||||
|
||||
def _get_file_name_from_proto(proto):
|
||||
return proto.path.rpartition("/")[2]
|
||||
|
||||
def _get_slash_or_null_from_proto(proto):
|
||||
"""Potentially returns empty (if the file is in the root directory)"""
|
||||
return proto.path.rpartition("/")[1]
|
||||
|
||||
def _get_directory_from_proto(proto):
|
||||
return proto.path.rpartition("/")[0]
|
||||
|
||||
def _get_full_path_from_file(file):
|
||||
gen_dir_length = 0
|
||||
|
||||
# if file is generated, then prepare to remote its root
|
||||
# (including CPU architecture...)
|
||||
if not file.is_source:
|
||||
gen_dir_length = len(file.root.path) + 1
|
||||
|
||||
return file.path[gen_dir_length:]
|
||||
|
||||
def _join_directories(directories):
|
||||
massaged_directories = [directory for directory in directories if len(directory) != 0]
|
||||
return "/".join(massaged_directories)
|
||||
|
||||
generate_objc = rule(
|
||||
attrs = {
|
||||
"deps": attr.label_list(
|
||||
mandatory = True,
|
||||
allow_empty = False,
|
||||
providers = [ProtoInfo],
|
||||
),
|
||||
"plugin": attr.label(
|
||||
default = "@com_github_grpc_grpc//src/compiler:grpc_objective_c_plugin",
|
||||
executable = True,
|
||||
providers = ["files_to_run"],
|
||||
cfg = "host",
|
||||
),
|
||||
"srcs": attr.string_list(
|
||||
mandatory = False,
|
||||
allow_empty = True,
|
||||
),
|
||||
"use_well_known_protos": attr.bool(
|
||||
mandatory = False,
|
||||
default = False,
|
||||
),
|
||||
"well_known_protos": attr.label(
|
||||
default = "@com_google_protobuf//:well_known_type_protos",
|
||||
),
|
||||
"_protoc": attr.label(
|
||||
default = Label("//external:protocol_compiler"),
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
),
|
||||
},
|
||||
output_to_genfiles = True,
|
||||
implementation = _generate_objc_impl,
|
||||
)
|
||||
|
||||
def _group_objc_files_impl(ctx):
|
||||
suffix = ""
|
||||
if ctx.attr.gen_mode == _GENERATE_HDRS:
|
||||
suffix = "h"
|
||||
elif ctx.attr.gen_mode == _GENERATE_SRCS:
|
||||
suffix = "pbrpc.m"
|
||||
elif ctx.attr.gen_mode == _GENERATE_NON_ARC_SRCS:
|
||||
suffix = "pbobjc.m"
|
||||
else:
|
||||
fail("Undefined gen_mode")
|
||||
out_files = [
|
||||
file
|
||||
for file in ctx.attr.src.files.to_list()
|
||||
if file.basename.endswith(suffix)
|
||||
]
|
||||
return struct(files = depset(out_files)) # buildifier: disable=rule-impl-return
|
||||
|
||||
generate_objc_hdrs = rule(
|
||||
attrs = {
|
||||
"src": attr.label(
|
||||
mandatory = True,
|
||||
),
|
||||
"gen_mode": attr.int(
|
||||
default = _GENERATE_HDRS,
|
||||
),
|
||||
},
|
||||
implementation = _group_objc_files_impl,
|
||||
)
|
||||
|
||||
generate_objc_srcs = rule(
|
||||
attrs = {
|
||||
"src": attr.label(
|
||||
mandatory = True,
|
||||
),
|
||||
"gen_mode": attr.int(
|
||||
default = _GENERATE_SRCS,
|
||||
),
|
||||
},
|
||||
implementation = _group_objc_files_impl,
|
||||
)
|
||||
|
||||
generate_objc_non_arc_srcs = rule(
|
||||
attrs = {
|
||||
"src": attr.label(
|
||||
mandatory = True,
|
||||
),
|
||||
"gen_mode": attr.int(
|
||||
default = _GENERATE_NON_ARC_SRCS,
|
||||
),
|
||||
},
|
||||
implementation = _group_objc_files_impl,
|
||||
)
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""
|
||||
Houses py_grpc_gevent_test.
|
||||
"""
|
||||
|
||||
load("@grpc_python_dependencies//:requirements.bzl", "requirement")
|
||||
|
||||
_GRPC_LIB = "//src/python/grpcio/grpc:grpcio"
|
||||
|
||||
_COPIED_MAIN_SUFFIX = ".gevent.main"
|
||||
|
||||
def py_grpc_gevent_test(
|
||||
name,
|
||||
srcs,
|
||||
main = None,
|
||||
deps = None,
|
||||
data = None,
|
||||
**kwargs):
|
||||
"""Runs a Python test with gevent monkeypatched in.
|
||||
|
||||
Args:
|
||||
name: The name of the test.
|
||||
srcs: The source files.
|
||||
main: The main file of the test.
|
||||
deps: The dependencies of the test.
|
||||
data: The data dependencies of the test.
|
||||
**kwargs: Any other test arguments.
|
||||
"""
|
||||
if main == None:
|
||||
if len(srcs) != 1:
|
||||
fail("When main is not provided, srcs must be of size 1.")
|
||||
main = srcs[0]
|
||||
deps = [] if deps == None else deps
|
||||
data = [] if data == None else data
|
||||
lib_name = name + ".gevent.lib"
|
||||
supplied_python_version = kwargs.pop("python_version", "")
|
||||
if supplied_python_version and supplied_python_version != "PY3":
|
||||
fail("py_grpc_gevent_test only supports python_version=PY3")
|
||||
native.py_library(
|
||||
name = lib_name,
|
||||
srcs = srcs,
|
||||
)
|
||||
augmented_deps = deps + [
|
||||
":{}".format(lib_name),
|
||||
requirement("gevent"),
|
||||
]
|
||||
if _GRPC_LIB not in augmented_deps:
|
||||
augmented_deps.append(_GRPC_LIB)
|
||||
|
||||
# The main file needs to be in the same package as the test file.
|
||||
copied_main_name = name + _COPIED_MAIN_SUFFIX
|
||||
copied_main_filename = copied_main_name + ".py"
|
||||
native.genrule(
|
||||
name = copied_main_name,
|
||||
srcs = ["//bazel:_gevent_test_main.py"],
|
||||
outs = [copied_main_filename],
|
||||
cmd = "cp $< $@",
|
||||
)
|
||||
|
||||
# TODO(https://github.com/grpc/grpc/issues/27542): Remove once gevent is deemed non-flaky.
|
||||
if "flaky" in kwargs:
|
||||
kwargs.pop("flaky")
|
||||
|
||||
native.py_test(
|
||||
name = name + ".gevent",
|
||||
args = [name],
|
||||
data = data,
|
||||
deps = augmented_deps,
|
||||
srcs = [copied_main_filename],
|
||||
main = copied_main_filename,
|
||||
python_version = "PY3",
|
||||
flaky = False,
|
||||
**kwargs
|
||||
)
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright 2023 gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"]
|
||||
)
|
||||
|
||||
# This is needed for the dependency on google_cloud_cpp to work.
|
||||
# Taken from https://github.com/googleapis/google-cloud-cpp/blob/2839e9dba793ca023e11ea67f201f66f74fa7d3e/bazel/googleapis.BUILD
|
||||
cc_library(
|
||||
name = "googleapis_system_includes",
|
||||
includes = [
|
||||
".",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,727 @@
|
|||
# Copyright 2016 gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
#
|
||||
# This is for the gRPC build system. This isn't intended to be used outsite of
|
||||
# the BUILD file for gRPC. It contains the mapping for the template system we
|
||||
# use to generate other platform's build system files.
|
||||
#
|
||||
# Please consider that there should be a high bar for additions and changes to
|
||||
# this file.
|
||||
# Each rule listed must be re-written for Google's internal build system, and
|
||||
# each change must be ported from one to the other.
|
||||
#
|
||||
|
||||
"""
|
||||
Contains macros used throughout the repo.
|
||||
"""
|
||||
|
||||
load("//bazel:cc_grpc_library.bzl", "cc_grpc_library")
|
||||
load("//bazel:copts.bzl", "GRPC_DEFAULT_COPTS")
|
||||
load("//bazel:experiments.bzl", "EXPERIMENTS")
|
||||
load("//bazel:test_experiments.bzl", "TEST_EXPERIMENTS")
|
||||
load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library", "upb_proto_reflection_library")
|
||||
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
|
||||
load("@build_bazel_rules_apple//apple/testing/default_runner:ios_test_runner.bzl", "ios_test_runner")
|
||||
|
||||
# The set of pollers to test against if a test exercises polling
|
||||
POLLERS = ["epoll1", "poll"]
|
||||
|
||||
# The set of known EventEngines to test
|
||||
EVENT_ENGINES = {"default": {"tags": []}}
|
||||
|
||||
def if_not_windows(a):
|
||||
return select({
|
||||
"//:windows": [],
|
||||
"//:windows_msvc": [],
|
||||
"//conditions:default": a,
|
||||
})
|
||||
|
||||
def if_windows(a):
|
||||
return select({
|
||||
"//:windows": a,
|
||||
"//:windows_msvc": a,
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
def _get_external_deps(external_deps):
|
||||
ret = []
|
||||
for dep in external_deps:
|
||||
if dep == "address_sorting":
|
||||
ret.append("//third_party/address_sorting")
|
||||
elif dep == "xxhash":
|
||||
ret.append("//third_party/xxhash")
|
||||
elif dep == "cares":
|
||||
ret += select({
|
||||
"//:grpc_no_ares": [],
|
||||
"//conditions:default": ["//external:cares"],
|
||||
})
|
||||
elif dep == "cronet_c_for_grpc":
|
||||
ret.append("//third_party/objective_c/Cronet:cronet_c_for_grpc")
|
||||
elif dep.startswith("absl/"):
|
||||
ret.append("@com_google_absl//" + dep)
|
||||
elif dep.startswith("google/"):
|
||||
ret.append("@com_google_googleapis//" + dep)
|
||||
elif dep.startswith("otel/"):
|
||||
ret.append(dep.replace("otel/", "@io_opentelemetry_cpp//"))
|
||||
elif dep.startswith("google_cloud_cpp"):
|
||||
ret.append(dep.replace("google_cloud_cpp", "@google_cloud_cpp//"))
|
||||
else:
|
||||
ret.append("//external:" + dep)
|
||||
return ret
|
||||
|
||||
def _update_visibility(visibility):
|
||||
if visibility == None:
|
||||
return None
|
||||
|
||||
# Visibility rules prefixed with '@grpc:' are used to flag different visibility rule
|
||||
# classes upstream.
|
||||
PUBLIC = ["//visibility:public"]
|
||||
PRIVATE = ["//:__subpackages__"]
|
||||
VISIBILITY_TARGETS = {
|
||||
"alt_grpc++_base_legacy": PRIVATE,
|
||||
"alt_grpc_base_legacy": PRIVATE,
|
||||
"alt_grpc++_base_unsecure_legacy": PRIVATE,
|
||||
"alts_frame_protector": PRIVATE,
|
||||
"channelz": PRIVATE,
|
||||
"client_channel": PRIVATE,
|
||||
"cli": PRIVATE,
|
||||
"debug_location": PRIVATE,
|
||||
"endpoint_tests": PRIVATE,
|
||||
"exec_ctx": PRIVATE,
|
||||
"grpclb": PRIVATE,
|
||||
"grpc_experiments": PRIVATE,
|
||||
"grpc_opencensus_plugin": PUBLIC,
|
||||
"grpcpp_gcp_observability": PUBLIC,
|
||||
"grpc_resolver_fake": PRIVATE,
|
||||
"grpc++_test": PRIVATE,
|
||||
"http": PRIVATE,
|
||||
"httpcli": PRIVATE,
|
||||
"iomgr_timer": PRIVATE,
|
||||
"iomgr_internal_errqueue": PRIVATE,
|
||||
"iomgr_buffer_list": PRIVATE,
|
||||
"json_reader_legacy": PRIVATE,
|
||||
"public": PUBLIC,
|
||||
"ref_counted_ptr": PRIVATE,
|
||||
"trace": PRIVATE,
|
||||
"tsi_interface": PRIVATE,
|
||||
"tsi": PRIVATE,
|
||||
"xds": PRIVATE,
|
||||
"xds_client_core": PRIVATE,
|
||||
"grpc_python_observability": PRIVATE,
|
||||
}
|
||||
final_visibility = []
|
||||
for rule in visibility:
|
||||
if rule.startswith("@grpc:"):
|
||||
for replacement in VISIBILITY_TARGETS[rule[len("@grpc:"):]]:
|
||||
final_visibility.append(replacement)
|
||||
else:
|
||||
final_visibility.append(rule)
|
||||
return [x for x in final_visibility]
|
||||
|
||||
def grpc_cc_library(
|
||||
name,
|
||||
srcs = [],
|
||||
public_hdrs = [],
|
||||
hdrs = [],
|
||||
external_deps = [],
|
||||
defines = [],
|
||||
deps = [],
|
||||
select_deps = None,
|
||||
standalone = False,
|
||||
language = "C++",
|
||||
testonly = False,
|
||||
visibility = None,
|
||||
alwayslink = 0,
|
||||
data = [],
|
||||
tags = [],
|
||||
linkopts = [],
|
||||
linkstatic = False):
|
||||
"""An internal wrapper around cc_library.
|
||||
|
||||
Args:
|
||||
name: The name of the library.
|
||||
srcs: The source files.
|
||||
public_hdrs: The public headers.
|
||||
hdrs: The headers.
|
||||
external_deps: External depdendencies to be resolved.
|
||||
defines: Build defines to use.
|
||||
deps: cc_library deps.
|
||||
select_deps: deps included conditionally.
|
||||
standalone: Unused.
|
||||
language: The language of the library, e.g. C, C++.
|
||||
testonly: Whether the target is for tests only.
|
||||
visibility: The visibility of the target.
|
||||
alwayslink: Whether to enable alwayslink on the cc_library.
|
||||
data: Data dependencies.
|
||||
tags: Tags to apply to the rule.
|
||||
linkopts: Extra libraries to link.
|
||||
linkstatic: Whether to enable linkstatic on the cc_library.
|
||||
"""
|
||||
visibility = _update_visibility(visibility)
|
||||
copts = []
|
||||
if language.upper() == "C":
|
||||
copts = copts + if_not_windows(["-std=c11"])
|
||||
linkopts = linkopts + if_not_windows(["-pthread"]) + if_windows(["-defaultlib:ws2_32.lib"])
|
||||
if select_deps:
|
||||
for select_deps_entry in select_deps:
|
||||
deps += select(select_deps_entry)
|
||||
native.cc_library(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
defines = defines +
|
||||
select({
|
||||
"//:grpc_no_ares": ["GRPC_ARES=0"],
|
||||
"//conditions:default": [],
|
||||
}) +
|
||||
select({
|
||||
"//:remote_execution": ["GRPC_PORT_ISOLATED_RUNTIME=1"],
|
||||
"//conditions:default": [],
|
||||
}) +
|
||||
select({
|
||||
"//:grpc_allow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=1"],
|
||||
"//:grpc_disallow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=0"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
hdrs = hdrs + public_hdrs,
|
||||
deps = deps + _get_external_deps(external_deps),
|
||||
copts = GRPC_DEFAULT_COPTS + copts,
|
||||
visibility = visibility,
|
||||
testonly = testonly,
|
||||
linkopts = linkopts,
|
||||
includes = [
|
||||
"api/include",
|
||||
"include",
|
||||
"src/core/ext/upb-generated", # Once upb code-gen issue is resolved, remove this.
|
||||
"src/core/ext/upbdefs-generated", # Once upb code-gen issue is resolved, remove this.
|
||||
],
|
||||
alwayslink = alwayslink,
|
||||
data = data,
|
||||
tags = tags,
|
||||
linkstatic = linkstatic,
|
||||
)
|
||||
|
||||
def grpc_proto_plugin(name, srcs = [], deps = []):
|
||||
native.cc_binary(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
deps = deps,
|
||||
)
|
||||
|
||||
def grpc_proto_library(
|
||||
name,
|
||||
srcs = [],
|
||||
deps = [],
|
||||
well_known_protos = False,
|
||||
has_services = True,
|
||||
use_external = False,
|
||||
generate_mocks = False):
|
||||
cc_grpc_library(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
deps = deps,
|
||||
well_known_protos = well_known_protos,
|
||||
proto_only = not has_services,
|
||||
use_external = use_external,
|
||||
generate_mocks = generate_mocks,
|
||||
)
|
||||
|
||||
def ios_cc_test(
|
||||
name,
|
||||
tags = [],
|
||||
**kwargs):
|
||||
"""An ios C++ test target.
|
||||
|
||||
Args:
|
||||
name: The name of the test.
|
||||
tags: The tags to apply to the test.
|
||||
**kwargs: All other arguments to apply.
|
||||
"""
|
||||
test_lib_ios = name + "_test_lib_ios"
|
||||
ios_tags = tags + ["manual", "ios_cc_test"]
|
||||
test_runner = "ios_x86_64_sim_runner_" + name
|
||||
ios_test_runner(
|
||||
name = test_runner,
|
||||
device_type = "iPhone X",
|
||||
)
|
||||
if not any([t for t in tags if t.startswith("no_test_ios")]):
|
||||
native.objc_library(
|
||||
name = test_lib_ios,
|
||||
srcs = kwargs.get("srcs"),
|
||||
deps = kwargs.get("deps"),
|
||||
copts = kwargs.get("copts"),
|
||||
data = kwargs.get("data"),
|
||||
tags = ios_tags,
|
||||
alwayslink = 1,
|
||||
testonly = 1,
|
||||
)
|
||||
ios_test_deps = [":" + test_lib_ios]
|
||||
ios_unit_test(
|
||||
name = name + "_on_ios",
|
||||
size = kwargs.get("size"),
|
||||
data = kwargs.get("data"),
|
||||
tags = ios_tags,
|
||||
minimum_os_version = "9.0",
|
||||
runner = test_runner,
|
||||
deps = ios_test_deps,
|
||||
)
|
||||
|
||||
def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, uses_event_engine, flaky):
|
||||
"""Common logic used to parameterize tests for every poller and EventEngine and experiment.
|
||||
|
||||
Args:
|
||||
name: base name of the test
|
||||
srcs: source files
|
||||
deps: base deps
|
||||
tags: base tags
|
||||
args: base args
|
||||
flaky: base flaky
|
||||
exclude_pollers: list of poller names to exclude for this set of tests.
|
||||
uses_polling: set to False if the test is not sensitive to polling methodology.
|
||||
uses_event_engine: set to False if the test is not sensitive to
|
||||
EventEngine implementation differences
|
||||
|
||||
Returns:
|
||||
A list of dictionaries containing modified values of name, srcs, deps, tags, and args.
|
||||
"""
|
||||
poller_config = []
|
||||
|
||||
if not uses_polling:
|
||||
tags = tags + ["no_uses_polling"]
|
||||
|
||||
poller_config.append({
|
||||
"name": name,
|
||||
"srcs": srcs,
|
||||
"deps": deps,
|
||||
"tags": tags,
|
||||
"args": args,
|
||||
"flaky": flaky,
|
||||
"env": {},
|
||||
})
|
||||
else:
|
||||
# On linux we run the same test with the default EventEngine, once for each
|
||||
# poller
|
||||
for poller in POLLERS:
|
||||
if poller in exclude_pollers:
|
||||
continue
|
||||
poller_config.append({
|
||||
"name": name + "@poller=" + poller,
|
||||
"srcs": srcs,
|
||||
"deps": deps,
|
||||
"tags": (tags + EVENT_ENGINES["default"]["tags"] + [
|
||||
"no_windows",
|
||||
"no_mac",
|
||||
"bazel_only",
|
||||
]),
|
||||
"args": args,
|
||||
"env": {
|
||||
"GRPC_POLL_STRATEGY": poller,
|
||||
},
|
||||
"flaky": flaky,
|
||||
})
|
||||
|
||||
# Now generate one test for each subsequent EventEngine, all using the
|
||||
# default poller. These tests will have `@engine=<name>` appended to the
|
||||
# test target name. If a test target name has no `@engine=<name>` component,
|
||||
# that indicates that the default EventEngine is being used.
|
||||
if not uses_event_engine:
|
||||
# The poller tests exercise the default engine on Linux. This test
|
||||
# handles other platforms.
|
||||
poller_config.append({
|
||||
"name": name,
|
||||
"srcs": srcs,
|
||||
"deps": deps,
|
||||
"tags": tags + ["no_linux"],
|
||||
"args": args,
|
||||
"env": {},
|
||||
"flaky": flaky,
|
||||
})
|
||||
else:
|
||||
for engine_name, engine in EVENT_ENGINES.items():
|
||||
test_name = name + "@engine=" + engine_name
|
||||
test_tags = tags + engine["tags"] + ["bazel_only"]
|
||||
test_args = args + ["--engine=" + engine_name]
|
||||
if engine_name == "default":
|
||||
# The poller tests exercise the default engine on Linux.
|
||||
# This test handles other platforms.
|
||||
test_name = name
|
||||
test_tags = tags + engine["tags"] + ["no_linux"]
|
||||
test_args = args
|
||||
poller_config.append({
|
||||
"name": test_name,
|
||||
"srcs": srcs,
|
||||
"deps": deps,
|
||||
"tags": test_tags,
|
||||
"args": test_args,
|
||||
"env": {},
|
||||
"flaky": flaky,
|
||||
})
|
||||
|
||||
experiments = {}
|
||||
|
||||
# buildifier: disable=uninitialized
|
||||
def _populate_experiments_platform_config(config, platform_experiments_map):
|
||||
for platform, experiments_on_platform in platform_experiments_map.items():
|
||||
for mode, tag_to_experiments in experiments_on_platform.items():
|
||||
if mode not in config:
|
||||
config[mode] = {}
|
||||
for tag in tags:
|
||||
if tag not in tag_to_experiments:
|
||||
continue
|
||||
for experiment in tag_to_experiments[tag]:
|
||||
if experiment not in config[mode]:
|
||||
config[mode][experiment] = []
|
||||
config[mode][experiment].append(platform)
|
||||
|
||||
_populate_experiments_platform_config(experiments, EXPERIMENTS)
|
||||
_populate_experiments_platform_config(experiments, TEST_EXPERIMENTS)
|
||||
|
||||
mode_config = {
|
||||
# format: <mode>: (enabled_target_tags, disabled_target_tags)
|
||||
"on": (None, []),
|
||||
"off": ([], None),
|
||||
}
|
||||
|
||||
must_have_tags = [
|
||||
# We don't run experiments on cmake builds
|
||||
"bazel_only",
|
||||
# Nor on mac
|
||||
"no_mac",
|
||||
# Nor on arm64
|
||||
"no_arm64",
|
||||
]
|
||||
|
||||
def _update_experiments_platform_test_tags(tags, platforms):
|
||||
if "posix" not in platforms:
|
||||
if "no_linux" not in tags:
|
||||
tags.append("no_linux")
|
||||
if "no_mac" not in tags:
|
||||
tags.append("no_mac")
|
||||
if "windows" not in platforms:
|
||||
if "no_windows" not in tags:
|
||||
tags.append("no_windows")
|
||||
if "ios" not in platforms:
|
||||
if "no_test_ios" not in tags:
|
||||
tags.append("no_test_ios")
|
||||
return tags
|
||||
|
||||
experiment_config = list(poller_config)
|
||||
for mode, config in mode_config.items():
|
||||
enabled_tags, disabled_tags = config
|
||||
if enabled_tags != None:
|
||||
for experiment in experiments[mode].keys():
|
||||
for config in poller_config:
|
||||
config = dict(config)
|
||||
config["name"] = config["name"] + "@experiment=" + experiment
|
||||
env = dict(config["env"])
|
||||
env["GRPC_EXPERIMENTS"] = experiment
|
||||
env["GRPC_CI_EXPERIMENTS"] = "1"
|
||||
config["env"] = env
|
||||
tags = config["tags"]
|
||||
for tag in must_have_tags + enabled_tags:
|
||||
if tag not in tags:
|
||||
tags = tags + [tag]
|
||||
config["tags"] = _update_experiments_platform_test_tags(tags, experiments[mode][experiment])
|
||||
config["flaky"] = True
|
||||
experiment_config.append(config)
|
||||
if disabled_tags != None:
|
||||
for experiment in experiments[mode].keys():
|
||||
for config in poller_config:
|
||||
config = dict(config)
|
||||
config["name"] = config["name"] + "@experiment=no_" + experiment
|
||||
env = dict(config["env"])
|
||||
env["GRPC_EXPERIMENTS"] = "-" + experiment
|
||||
env["GRPC_CI_EXPERIMENTS"] = "1"
|
||||
config["env"] = env
|
||||
tags = config["tags"]
|
||||
for tag in must_have_tags + disabled_tags:
|
||||
if tag not in tags:
|
||||
tags = tags + [tag]
|
||||
config["tags"] = _update_experiments_platform_test_tags(tags, experiments[mode][experiment])
|
||||
experiment_config.append(config)
|
||||
return experiment_config
|
||||
|
||||
def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++", size = "medium", timeout = None, tags = [], exec_compatible_with = [], exec_properties = {}, shard_count = None, flaky = None, copts = [], linkstatic = None, exclude_pollers = [], uses_event_engine = True):
|
||||
"""A cc_test target for use in the gRPC repo.
|
||||
|
||||
Args:
|
||||
name: The name of the test.
|
||||
srcs: The source files.
|
||||
deps: The target deps.
|
||||
external_deps: The external deps.
|
||||
args: The args to supply to the test binary.
|
||||
data: Data dependencies.
|
||||
uses_polling: Whether the test uses polling.
|
||||
language: The language of the test, e.g C, C++.
|
||||
size: The size of the test.
|
||||
timeout: The test timeout.
|
||||
tags: The tags for the test.
|
||||
exec_compatible_with: A list of constraint values that must be
|
||||
satisifed for the platform.
|
||||
exec_properties: A dictionary of strings that will be added to the
|
||||
exec_properties of a platform selected for this target.
|
||||
shard_count: The number of shards for this test.
|
||||
flaky: Whether this test is flaky.
|
||||
copts: Add these to the compiler invocation.
|
||||
linkstatic: link the binary in static mode
|
||||
exclude_pollers: list of poller names to exclude for this set of tests.
|
||||
uses_event_engine: set to False if the test is not sensitive to
|
||||
EventEngine implementation differences
|
||||
"""
|
||||
if language.upper() == "C":
|
||||
copts = copts + if_not_windows(["-std=c11"])
|
||||
|
||||
core_deps = deps + _get_external_deps(external_deps) + ["//test/core/util:grpc_suppressions"]
|
||||
|
||||
# Test args for all tests
|
||||
test_args = {
|
||||
"data": data,
|
||||
"copts": GRPC_DEFAULT_COPTS + copts,
|
||||
"linkopts": if_not_windows(["-pthread"]) + if_windows(["-defaultlib:ws2_32.lib"]),
|
||||
"size": size,
|
||||
"timeout": timeout,
|
||||
"exec_compatible_with": exec_compatible_with,
|
||||
"exec_properties": exec_properties,
|
||||
"shard_count": shard_count,
|
||||
"linkstatic": linkstatic,
|
||||
}
|
||||
|
||||
if "grpc-fuzzer" not in tags and "no_test_ios" not in tags:
|
||||
ios_cc_test(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
tags = tags,
|
||||
deps = core_deps,
|
||||
args = args,
|
||||
flaky = True,
|
||||
**test_args
|
||||
)
|
||||
|
||||
for poller_config in expand_tests(name, srcs, core_deps, tags, args, exclude_pollers, uses_polling, uses_event_engine, flaky):
|
||||
native.cc_test(
|
||||
name = poller_config["name"],
|
||||
srcs = poller_config["srcs"],
|
||||
deps = poller_config["deps"],
|
||||
tags = poller_config["tags"],
|
||||
args = poller_config["args"],
|
||||
env = poller_config["env"],
|
||||
flaky = poller_config["flaky"],
|
||||
**test_args
|
||||
)
|
||||
|
||||
def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = [], features = [], visibility = None):
|
||||
"""Generates a cc_binary for use in the gRPC repo.
|
||||
|
||||
Args:
|
||||
name: The name of the target.
|
||||
srcs: The source files.
|
||||
deps: The dependencies.
|
||||
external_deps: The external dependencies.
|
||||
args: The arguments to supply to the binary.
|
||||
data: The data dependencies.
|
||||
language: The language of the binary, e.g. C, C++.
|
||||
testonly: Whether the binary is for tests only.
|
||||
linkshared: Enables linkshared on the binary.
|
||||
linkopts: linkopts to supply to the cc_binary.
|
||||
tags: Tags to apply to the target.
|
||||
features: features to be supplied to the cc_binary.
|
||||
visibility: The visibility of the target.
|
||||
"""
|
||||
visibility = _update_visibility(visibility)
|
||||
copts = []
|
||||
if language.upper() == "C":
|
||||
copts = ["-std=c11"]
|
||||
native.cc_binary(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
args = args,
|
||||
data = data,
|
||||
testonly = testonly,
|
||||
linkshared = linkshared,
|
||||
deps = deps + _get_external_deps(external_deps) + ["//test/core/util:grpc_suppressions"],
|
||||
copts = GRPC_DEFAULT_COPTS + copts,
|
||||
linkopts = if_not_windows(["-pthread"]) + linkopts,
|
||||
tags = tags,
|
||||
features = features,
|
||||
)
|
||||
|
||||
# buildifier: disable=unnamed-macro
|
||||
def grpc_generate_one_off_targets():
|
||||
# In open-source, grpc_objc* libraries depend directly on //:grpc
|
||||
native.alias(
|
||||
name = "grpc_objc",
|
||||
actual = "//:grpc",
|
||||
)
|
||||
native.config_setting(
|
||||
name = "windows_other",
|
||||
values = {"define": "GRPC_WINDOWS_OTHER=1"},
|
||||
)
|
||||
|
||||
def grpc_generate_objc_one_off_targets():
|
||||
pass
|
||||
|
||||
def grpc_generate_one_off_internal_targets():
|
||||
pass
|
||||
|
||||
def grpc_sh_test(name, srcs = [], args = [], data = [], uses_polling = True, size = "medium", timeout = None, tags = [], exec_compatible_with = [], exec_properties = {}, shard_count = None, flaky = None, exclude_pollers = [], uses_event_engine = True):
|
||||
"""Execute an sh_test for every <poller> x <EventEngine> combination
|
||||
|
||||
Args:
|
||||
name: The name of the test.
|
||||
srcs: The source files.
|
||||
args: The args to supply to the test binary.
|
||||
data: Data dependencies.
|
||||
uses_polling: Whether the test uses polling.
|
||||
size: The size of the test.
|
||||
timeout: The test timeout.
|
||||
tags: The tags for the test.
|
||||
exec_compatible_with: A list of constraint values that must be
|
||||
satisifed for the platform.
|
||||
exec_properties: A dictionary of strings that will be added to the
|
||||
exec_properties of a platform selected for this target.
|
||||
shard_count: The number of shards for this test.
|
||||
flaky: Whether this test is flaky.
|
||||
exclude_pollers: list of poller names to exclude for this set of tests.
|
||||
uses_event_engine: set to False if the test is not sensitive to
|
||||
EventEngine implementation differences
|
||||
"""
|
||||
test_args = {
|
||||
"data": data,
|
||||
"size": size,
|
||||
"timeout": timeout,
|
||||
"exec_compatible_with": exec_compatible_with,
|
||||
"exec_properties": exec_properties,
|
||||
"shard_count": shard_count,
|
||||
}
|
||||
|
||||
for poller_config in expand_tests(name, srcs, [], tags, args, exclude_pollers, uses_polling, uses_event_engine, flaky):
|
||||
native.sh_test(
|
||||
name = poller_config["name"],
|
||||
srcs = poller_config["srcs"],
|
||||
deps = poller_config["deps"],
|
||||
tags = poller_config["tags"],
|
||||
args = poller_config["args"],
|
||||
env = poller_config["env"],
|
||||
flaky = poller_config["flaky"],
|
||||
**test_args
|
||||
)
|
||||
|
||||
def grpc_sh_binary(name, srcs, data = []):
|
||||
native.sh_binary(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
data = data,
|
||||
)
|
||||
|
||||
def grpc_py_binary(
|
||||
name,
|
||||
srcs,
|
||||
data = [],
|
||||
deps = [],
|
||||
external_deps = [],
|
||||
testonly = False,
|
||||
python_version = "PY2",
|
||||
**kwargs):
|
||||
native.py_binary(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
testonly = testonly,
|
||||
data = data,
|
||||
deps = deps + _get_external_deps(external_deps),
|
||||
python_version = python_version,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def grpc_package(name, visibility = "private", features = []):
|
||||
"""Creates a package.
|
||||
|
||||
Args:
|
||||
name: The name of the target
|
||||
visibility: The visibility of the target.
|
||||
features: The features to enable.
|
||||
"""
|
||||
if visibility == "tests":
|
||||
visibility = ["//test:__subpackages__"]
|
||||
elif visibility == "public":
|
||||
visibility = ["//visibility:public"]
|
||||
elif visibility == "private":
|
||||
visibility = []
|
||||
else:
|
||||
fail("Unknown visibility " + visibility)
|
||||
|
||||
if len(visibility) != 0:
|
||||
# buildifier: disable=native-package
|
||||
native.package(
|
||||
default_visibility = visibility,
|
||||
features = features,
|
||||
)
|
||||
|
||||
def grpc_objc_library(
|
||||
name,
|
||||
srcs = [],
|
||||
hdrs = [],
|
||||
non_arc_srcs = [],
|
||||
textual_hdrs = [],
|
||||
testonly = False,
|
||||
data = [],
|
||||
deps = [],
|
||||
defines = [],
|
||||
sdk_frameworks = [],
|
||||
includes = [],
|
||||
visibility = ["//visibility:public"]):
|
||||
"""The grpc version of objc_library, only used for the Objective-C library compilation
|
||||
|
||||
Args:
|
||||
name: name of target
|
||||
hdrs: public headers
|
||||
srcs: all source files (.m)
|
||||
non_arc_srcs: list of Objective-C files that DO NOT use ARC.
|
||||
textual_hdrs: private headers
|
||||
testonly: Whether the binary is for tests only.
|
||||
data: any other bundle resources
|
||||
defines: preprocessors
|
||||
sdk_frameworks: sdks
|
||||
includes: added to search path, always [the path to objc directory]
|
||||
deps: dependencies
|
||||
visibility: visibility, default to public
|
||||
"""
|
||||
|
||||
native.objc_library(
|
||||
name = name,
|
||||
hdrs = hdrs,
|
||||
srcs = srcs,
|
||||
non_arc_srcs = non_arc_srcs,
|
||||
textual_hdrs = textual_hdrs,
|
||||
copts = GRPC_DEFAULT_COPTS + ["-ObjC++", "-std=gnu++14"],
|
||||
testonly = testonly,
|
||||
data = data,
|
||||
deps = deps,
|
||||
defines = defines,
|
||||
includes = includes,
|
||||
sdk_frameworks = sdk_frameworks,
|
||||
visibility = visibility,
|
||||
)
|
||||
|
||||
def grpc_upb_proto_library(name, deps):
|
||||
upb_proto_library(name = name, deps = deps)
|
||||
|
||||
def grpc_upb_proto_reflection_library(name, deps):
|
||||
upb_proto_reflection_library(name = name, deps = deps)
|
||||
|
||||
# buildifier: disable=unnamed-macro
|
||||
def python_config_settings():
|
||||
native.config_setting(
|
||||
name = "python3",
|
||||
flag_values = {"@bazel_tools//tools/python:python_version": "PY3"},
|
||||
)
|
||||
|
|
@ -0,0 +1,620 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Load dependencies needed to compile and test the grpc library as a 3rd-party consumer."""
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps")
|
||||
|
||||
# buildifier: disable=unnamed-macro
|
||||
def grpc_deps():
|
||||
"""Loads dependencies need to compile and test the grpc library."""
|
||||
|
||||
native.bind(
|
||||
name = "upb_lib",
|
||||
actual = "@upb//:upb",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "upb_collections_lib",
|
||||
actual = "@upb//:collections",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "upb_reflection",
|
||||
actual = "@upb//:reflection",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "upb_lib_descriptor",
|
||||
actual = "@upb//:descriptor_upb_proto",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "upb_lib_descriptor_reflection",
|
||||
actual = "@upb//:descriptor_upb_proto_reflection",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "upb_textformat_lib",
|
||||
actual = "@upb//:textformat",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "upb_json_lib",
|
||||
actual = "@upb//:json",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
|
||||
actual = "@upb//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "libssl",
|
||||
actual = "@boringssl//:ssl",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "libcrypto",
|
||||
actual = "@boringssl//:crypto",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "madler_zlib",
|
||||
actual = "@zlib//:zlib",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "protobuf",
|
||||
actual = "@com_google_protobuf//:protobuf",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "protobuf_clib",
|
||||
actual = "@com_google_protobuf//:protoc_lib",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "protobuf_headers",
|
||||
actual = "@com_google_protobuf//:protobuf_headers",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "protocol_compiler",
|
||||
actual = "@com_google_protobuf//:protoc",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "cares",
|
||||
actual = "@com_github_cares_cares//:ares",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "gtest",
|
||||
actual = "@com_google_googletest//:gtest",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "fuzztest",
|
||||
actual = "@com_google_fuzztest//fuzztest",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "fuzztest_main",
|
||||
actual = "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "benchmark",
|
||||
actual = "@com_github_google_benchmark//:benchmark",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "re2",
|
||||
actual = "@com_googlesource_code_re2//:re2",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "grpc_cpp_plugin",
|
||||
actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "grpc++_codegen_proto",
|
||||
actual = "@com_github_grpc_grpc//:grpc++_codegen_proto",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-context",
|
||||
actual = "@io_opencensus_cpp//opencensus/context:context",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-trace",
|
||||
actual = "@io_opencensus_cpp//opencensus/trace:trace",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-trace-context_util",
|
||||
actual = "@io_opencensus_cpp//opencensus/trace:context_util",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-trace-propagation",
|
||||
actual = "@io_opencensus_cpp//opencensus/trace:grpc_trace_bin",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-trace-span_context",
|
||||
actual = "@io_opencensus_cpp//opencensus/trace:span_context",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-stats",
|
||||
actual = "@io_opencensus_cpp//opencensus/stats:stats",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-stats-test",
|
||||
actual = "@io_opencensus_cpp//opencensus/stats:test_utils",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-with-tag-map",
|
||||
actual = "@io_opencensus_cpp//opencensus/tags:with_tag_map",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-tags",
|
||||
actual = "@io_opencensus_cpp//opencensus/tags:tags",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-tags-context_util",
|
||||
actual = "@io_opencensus_cpp//opencensus/tags:context_util",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-trace-stackdriver_exporter",
|
||||
actual = "@io_opencensus_cpp//opencensus/exporters/trace/stackdriver:stackdriver_exporter",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "opencensus-stats-stackdriver_exporter",
|
||||
actual = "@io_opencensus_cpp//opencensus/exporters/stats/stackdriver:stackdriver_exporter",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "googleapis_trace_grpc_service",
|
||||
actual = "@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "googleapis_monitoring_grpc_service",
|
||||
actual = "@com_google_googleapis//google/monitoring/v3:monitoring_cc_grpc",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "googleapis_logging_grpc_service",
|
||||
actual = "@com_google_googleapis//google/logging/v2:logging_cc_grpc",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "googleapis_logging_cc_proto",
|
||||
actual = "@com_google_googleapis//google/logging/v2:logging_cc_proto",
|
||||
)
|
||||
|
||||
if "boringssl" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "boringssl",
|
||||
# Use github mirror instead of https://boringssl.googlesource.com/boringssl
|
||||
# to obtain a boringssl archive with consistent sha256
|
||||
sha256 = "b21994a857a7aa6d5256ffe355c735ad4c286de44c6c81dfc04edc41a8feaeef",
|
||||
strip_prefix = "boringssl-2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/boringssl/archive/2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b.tar.gz",
|
||||
"https://github.com/google/boringssl/archive/2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "zlib" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "zlib",
|
||||
build_file = "@com_github_grpc_grpc//third_party:zlib.BUILD",
|
||||
sha256 = "90f43a9c998740e8a0db24b0af0147033db2aaaa99423129abbd76640757cac9",
|
||||
strip_prefix = "zlib-04f42ceca40f73e2978b50e93806c2a18c1281fc",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/madler/zlib/archive/04f42ceca40f73e2978b50e93806c2a18c1281fc.tar.gz",
|
||||
"https://github.com/madler/zlib/archive/04f42ceca40f73e2978b50e93806c2a18c1281fc.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_google_protobuf" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_google_protobuf",
|
||||
sha256 = "660ce016f987550bc1ccec4a6ee4199afb871799b696227098e3641476a7d566",
|
||||
strip_prefix = "protobuf-b2b7a51158418f41cff0520894836c15b1738721",
|
||||
urls = [
|
||||
# https://github.com/protocolbuffers/protobuf/commits/v24.3
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/b2b7a51158418f41cff0520894836c15b1738721.tar.gz",
|
||||
"https://github.com/protocolbuffers/protobuf/archive/b2b7a51158418f41cff0520894836c15b1738721.tar.gz",
|
||||
],
|
||||
patches = [
|
||||
"@com_github_grpc_grpc//third_party:protobuf.patch",
|
||||
],
|
||||
patch_args = ["-p1"],
|
||||
)
|
||||
|
||||
if "com_google_googletest" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_google_googletest",
|
||||
sha256 = "c8de6c60e12ad014a28225c5247ee735861d85cf906df617f6a29954ca05f547",
|
||||
strip_prefix = "googletest-0e402173c97aea7a00749e825b194bfede4f2e45",
|
||||
urls = [
|
||||
# 2022-02-09
|
||||
"https://github.com/google/googletest/archive/0e402173c97aea7a00749e825b194bfede4f2e45.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_google_fuzztest" not in native.existing_rules():
|
||||
# when updating this remember to run:
|
||||
# bazel run @com_google_fuzztest//bazel:setup_configs > tools/fuzztest.bazelrc
|
||||
http_archive(
|
||||
name = "com_google_fuzztest",
|
||||
sha256 = "cdf8d8cd3cdc77280a7c59b310edf234e489a96b6e727cb271e7dfbeb9bcca8d",
|
||||
strip_prefix = "fuzztest-4ecaeb5084a061a862af8f86789ee184cd3d3f18",
|
||||
urls = [
|
||||
# 2023-05-16
|
||||
"https://github.com/google/fuzztest/archive/4ecaeb5084a061a862af8f86789ee184cd3d3f18.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "rules_cc" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "rules_cc",
|
||||
sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40",
|
||||
strip_prefix = "rules_cc-0.0.6",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_github_google_benchmark" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_google_benchmark",
|
||||
sha256 = "4e47ca279d5ae967c506c136bd8afb42eedcaf010aebb48a0e87790cae4b488a",
|
||||
strip_prefix = "benchmark-015d1a091af6937488242b70121858bce8fd40e9",
|
||||
urls = [
|
||||
# v1.8.2
|
||||
"https://github.com/google/benchmark/archive/015d1a091af6937488242b70121858bce8fd40e9.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_googlesource_code_re2" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_googlesource_code_re2",
|
||||
sha256 = "1ae8ccfdb1066a731bba6ee0881baad5efd2cd661acd9569b689f2586e1a50e9",
|
||||
strip_prefix = "re2-2022-04-01",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/re2/archive/2022-04-01.tar.gz",
|
||||
"https://github.com/google/re2/archive/2022-04-01.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_github_cares_cares" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_cares_cares",
|
||||
build_file = "@com_github_grpc_grpc//third_party:cares/cares.BUILD",
|
||||
sha256 = "bf26e5b25e259911914a85ae847b6d723488adb5af4f8bdeb9d0871a318476e3",
|
||||
strip_prefix = "c-ares-6360e96b5cf8e5980c887ce58ef727e53d77243a",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/c-ares/c-ares/archive/6360e96b5cf8e5980c887ce58ef727e53d77243a.tar.gz",
|
||||
"https://github.com/c-ares/c-ares/archive/6360e96b5cf8e5980c887ce58ef727e53d77243a.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_google_absl" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_google_absl",
|
||||
sha256 = "59d2976af9d6ecf001a81a35749a6e551a335b949d34918cfade07737b9d93c5",
|
||||
strip_prefix = "abseil-cpp-20230802.0",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20230802.0.tar.gz",
|
||||
"https://github.com/abseil/abseil-cpp/archive/20230802.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "bazel_toolchains" not in native.existing_rules():
|
||||
# list of releases is at https://github.com/bazelbuild/bazel-toolchains/releases
|
||||
http_archive(
|
||||
name = "bazel_toolchains",
|
||||
sha256 = "179ec02f809e86abf56356d8898c8bd74069f1bd7c56044050c2cd3d79d0e024",
|
||||
strip_prefix = "bazel-toolchains-4.1.0",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/4.1.0/bazel-toolchains-4.1.0.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-toolchains/releases/download/4.1.0/bazel-toolchains-4.1.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "bazel_skylib" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
|
||||
],
|
||||
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
|
||||
)
|
||||
|
||||
if "bazel_compdb" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "bazel_compdb",
|
||||
sha256 = "bcecfd622c4ef272fd4ba42726a52e140b961c4eac23025f18b346c968a8cfb4",
|
||||
strip_prefix = "bazel-compilation-database-0.4.5",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/grailbio/bazel-compilation-database/archive/0.4.5.tar.gz",
|
||||
"https://github.com/grailbio/bazel-compilation-database/archive/0.4.5.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "io_opencensus_cpp" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "io_opencensus_cpp",
|
||||
sha256 = "46b3b5812c150a21bacf860c2f76fc42b89773ed77ee954c32adeb8593aa2a8e",
|
||||
strip_prefix = "opencensus-cpp-5501a1a255805e0be83a41348bb5f2630d5ed6b3",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/census-instrumentation/opencensus-cpp/archive/5501a1a255805e0be83a41348bb5f2630d5ed6b3.tar.gz",
|
||||
"https://github.com/census-instrumentation/opencensus-cpp/archive/5501a1a255805e0be83a41348bb5f2630d5ed6b3.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "upb" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "upb",
|
||||
sha256 = "5147e0ab6a28421d1e49004f4a205d84f06b924585e15eaa884cfe13289165b7",
|
||||
strip_prefix = "upb-42cd08932e364a4cde35033b73f15c30250d7c2e",
|
||||
urls = [
|
||||
# https://github.com/protocolbuffers/upb/commits/24.x
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/42cd08932e364a4cde35033b73f15c30250d7c2e.tar.gz",
|
||||
"https://github.com/protocolbuffers/upb/archive/42cd08932e364a4cde35033b73f15c30250d7c2e.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "envoy_api" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "envoy_api",
|
||||
sha256 = "6fd3496c82919a433219733819a93b56699519a193126959e9c4fedc25e70663",
|
||||
strip_prefix = "data-plane-api-e53e7bbd012f81965f2e79848ad9a58ceb67201f",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/envoyproxy/data-plane-api/archive/e53e7bbd012f81965f2e79848ad9a58ceb67201f.tar.gz",
|
||||
"https://github.com/envoyproxy/data-plane-api/archive/e53e7bbd012f81965f2e79848ad9a58ceb67201f.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "io_bazel_rules_go" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "69de5c704a05ff37862f7e0f5534d4f479418afc21806c887db544a316f3cb6b",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "build_bazel_rules_apple" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "build_bazel_rules_apple",
|
||||
sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "build_bazel_apple_support" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "build_bazel_apple_support",
|
||||
sha256 = "f4fdf5c9b42b92ea12f229b265d74bb8cedb8208ca7a445b383c9f866cf53392",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/1.3.1/apple_support.1.3.1.tar.gz",
|
||||
"https://github.com/bazelbuild/apple_support/releases/download/1.3.1/apple_support.1.3.1.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_google_googleapis" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_google_googleapis",
|
||||
sha256 = "5bb6b0253ccf64b53d6c7249625a7e3f6c3bc6402abd52d3778bfa48258703a0",
|
||||
strip_prefix = "googleapis-2f9af297c84c55c8b871ba4495e01ade42476c92",
|
||||
build_file = Label("//bazel:googleapis.BUILD"),
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz",
|
||||
"https://github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "bazel_gazelle" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "bazel_gazelle",
|
||||
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "opencensus_proto" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "opencensus_proto",
|
||||
sha256 = "b7e13f0b4259e80c3070b583c2f39e53153085a6918718b1c710caf7037572b0",
|
||||
strip_prefix = "opencensus-proto-0.3.0/src",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/census-instrumentation/opencensus-proto/archive/v0.3.0.tar.gz",
|
||||
"https://github.com/census-instrumentation/opencensus-proto/archive/v0.3.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "com_envoyproxy_protoc_gen_validate" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_envoyproxy_protoc_gen_validate",
|
||||
strip_prefix = "protoc-gen-validate-4694024279bdac52b77e22dc87808bd0fd732b69",
|
||||
sha256 = "1e490b98005664d149b379a9529a6aa05932b8a11b76b4cd86f3d22d76346f47",
|
||||
urls = [
|
||||
"https://github.com/envoyproxy/protoc-gen-validate/archive/4694024279bdac52b77e22dc87808bd0fd732b69.tar.gz",
|
||||
],
|
||||
patches = ["@com_github_grpc_grpc//third_party:protoc-gen-validate.patch"],
|
||||
patch_args = ["-p1"],
|
||||
)
|
||||
|
||||
if "com_github_cncf_udpa" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_cncf_udpa",
|
||||
sha256 = "0d33b83f8c6368954e72e7785539f0d272a8aba2f6e2e336ed15fd1514bc9899",
|
||||
strip_prefix = "xds-e9ce68804cb4e64cab5a52e3c8baf840d4ff87b7",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/cncf/xds/archive/e9ce68804cb4e64cab5a52e3c8baf840d4ff87b7.tar.gz",
|
||||
"https://github.com/cncf/xds/archive/e9ce68804cb4e64cab5a52e3c8baf840d4ff87b7.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# TODO(stanleycheung): remove this when prometheus-cpp AND
|
||||
# opentelemetry-cpp cut a new release
|
||||
# This override is needed because this fix
|
||||
# https://github.com/jupp0r/prometheus-cpp/pull/626
|
||||
# has not been included in the latest prometheus-cpp release yet.
|
||||
# We also need opentelemetry-cpp to update their dependency on
|
||||
# prometheus-cpp after that fix is released.
|
||||
# Without the fix, we cannot build the prometheus exporter with bazel 6
|
||||
if "com_github_jupp0r_prometheus_cpp" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_jupp0r_prometheus_cpp",
|
||||
strip_prefix = "prometheus-cpp-b1234816facfdda29845c46696a02998a4af115a",
|
||||
urls = [
|
||||
"https://github.com/jupp0r/prometheus-cpp/archive/b123481.zip",
|
||||
],
|
||||
)
|
||||
|
||||
if "io_opentelemetry_cpp" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "io_opentelemetry_cpp",
|
||||
sha256 = "f30cd88bf898a5726d245eba882b8e81012021eb00df34109f4dfb203f005cea",
|
||||
strip_prefix = "opentelemetry-cpp-1.11.0",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.11.0.tar.gz",
|
||||
"https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.11.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
if "google_cloud_cpp" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "google_cloud_cpp",
|
||||
sha256 = "371d01b03c7e2604d671b8fa1c86710abe3b524a78bc2705a6bb4de715696755",
|
||||
strip_prefix = "google-cloud-cpp-2.14.0",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz",
|
||||
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
grpc_python_deps()
|
||||
|
||||
# TODO: move some dependencies from "grpc_deps" here?
|
||||
# buildifier: disable=unnamed-macro
|
||||
def grpc_test_only_deps():
|
||||
"""Internal, not intended for use by packages that are consuming grpc.
|
||||
|
||||
Loads dependencies that are only needed to run grpc library's tests.
|
||||
"""
|
||||
native.bind(
|
||||
name = "twisted",
|
||||
actual = "@com_github_twisted_twisted//:twisted",
|
||||
)
|
||||
|
||||
native.bind(
|
||||
name = "yaml",
|
||||
actual = "@com_github_yaml_pyyaml//:yaml",
|
||||
)
|
||||
|
||||
if "com_github_twisted_twisted" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_twisted_twisted",
|
||||
sha256 = "ca17699d0d62eafc5c28daf2c7d0a18e62ae77b4137300b6c7d7868b39b06139",
|
||||
strip_prefix = "twisted-twisted-17.5.0",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/twisted/twisted/archive/twisted-17.5.0.zip",
|
||||
"https://github.com/twisted/twisted/archive/twisted-17.5.0.zip",
|
||||
],
|
||||
build_file = "@com_github_grpc_grpc//third_party:twisted.BUILD",
|
||||
)
|
||||
|
||||
if "com_github_yaml_pyyaml" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_yaml_pyyaml",
|
||||
sha256 = "e34d97db6d846f5e2ad51417fd646e7ce6a3a70726ccea2a857e0580a7155f39",
|
||||
strip_prefix = "pyyaml-6.0.1",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/yaml/pyyaml/archive/6.0.1.zip",
|
||||
"https://github.com/yaml/pyyaml/archive/6.0.1.zip",
|
||||
],
|
||||
build_file = "@com_github_grpc_grpc//third_party:yaml.BUILD",
|
||||
)
|
||||
|
||||
if "com_github_twisted_incremental" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_twisted_incremental",
|
||||
sha256 = "f0ca93359ee70243ff7fbf2d904a6291810bd88cb80ed4aca6fa77f318a41a36",
|
||||
strip_prefix = "incremental-incremental-17.5.0",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/twisted/incremental/archive/incremental-17.5.0.zip",
|
||||
"https://github.com/twisted/incremental/archive/incremental-17.5.0.zip",
|
||||
],
|
||||
build_file = "@com_github_grpc_grpc//third_party:incremental.BUILD",
|
||||
)
|
||||
|
||||
if "com_github_zopefoundation_zope_interface" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_zopefoundation_zope_interface",
|
||||
sha256 = "e9579fc6149294339897be3aa9ecd8a29217c0b013fe6f44fcdae00e3204198a",
|
||||
strip_prefix = "zope.interface-4.4.3",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/zopefoundation/zope.interface/archive/4.4.3.zip",
|
||||
"https://github.com/zopefoundation/zope.interface/archive/4.4.3.zip",
|
||||
],
|
||||
build_file = "@com_github_grpc_grpc//third_party:zope_interface.BUILD",
|
||||
)
|
||||
|
||||
if "com_github_twisted_constantly" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_github_twisted_constantly",
|
||||
sha256 = "2702cd322161a579d2c0dbf94af4e57712eedc7bd7bbbdc554a230544f7d346c",
|
||||
strip_prefix = "constantly-15.1.0",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/twisted/constantly/archive/15.1.0.zip",
|
||||
"https://github.com/twisted/constantly/archive/15.1.0.zip",
|
||||
],
|
||||
build_file = "@com_github_grpc_grpc//third_party:constantly.BUILD",
|
||||
)
|
||||
|
||||
if "com_google_libprotobuf_mutator" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "com_google_libprotobuf_mutator",
|
||||
sha256 = "11ab4c57b4051977d8fedb86dba5c9092e578bc293c47be146e0b0596b6a0bdc",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/libprotobuf-mutator/archive/c390388561be36f94a559a4aed7e2fe60470f60b.tar.gz",
|
||||
"https://github.com/google/libprotobuf-mutator/archive/c390388561be36f94a559a4aed7e2fe60470f60b.tar.gz",
|
||||
],
|
||||
strip_prefix = "libprotobuf-mutator-c390388561be36f94a559a4aed7e2fe60470f60b",
|
||||
build_file = "@com_github_grpc_grpc//third_party:libprotobuf_mutator.BUILD",
|
||||
)
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Loads the dependencies necessary for the external repositories defined in grpc_deps.bzl."""
|
||||
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
|
||||
load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
|
||||
load("@com_envoyproxy_protoc_gen_validate//:dependencies.bzl", "go_third_party")
|
||||
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
|
||||
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
|
||||
load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
|
||||
load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")
|
||||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
|
||||
|
||||
def grpc_extra_deps(ignore_version_differences = False):
|
||||
"""Loads the extra dependencies.
|
||||
|
||||
These are necessary for using the external repositories defined in
|
||||
grpc_deps.bzl. Projects that depend on gRPC as an external repository need
|
||||
to call both grpc_deps and grpc_extra_deps, if they have not already loaded
|
||||
the extra dependencies. For example, they can do the following in their
|
||||
WORKSPACE
|
||||
```
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps", "grpc_test_only_deps")
|
||||
grpc_deps()
|
||||
|
||||
grpc_test_only_deps()
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
|
||||
|
||||
grpc_extra_deps()
|
||||
```
|
||||
|
||||
Args:
|
||||
ignore_version_differences: Plumbed directly to the invocation of
|
||||
apple_rules_dependencies.
|
||||
"""
|
||||
protobuf_deps()
|
||||
|
||||
upb_deps()
|
||||
|
||||
api_dependencies()
|
||||
|
||||
go_rules_dependencies()
|
||||
go_register_toolchains(version = "1.18")
|
||||
gazelle_dependencies()
|
||||
|
||||
# Pull-in the go 3rd party dependencies for protoc_gen_validate, which is
|
||||
# needed for building C++ xDS protos
|
||||
go_third_party()
|
||||
|
||||
apple_rules_dependencies(ignore_version_differences = ignore_version_differences)
|
||||
|
||||
apple_support_dependencies()
|
||||
|
||||
# Initialize Google APIs with only C++ and Python targets
|
||||
switched_rules_by_language(
|
||||
name = "com_google_googleapis_imports",
|
||||
cc = True,
|
||||
grpc = True,
|
||||
python = True,
|
||||
)
|
||||
|
||||
google_cloud_cpp_deps()
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Load dependencies needed to compile and test the grpc python library as a 3rd-party consumer."""
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@com_github_grpc_grpc//third_party/py:python_configure.bzl", "python_configure")
|
||||
|
||||
# buildifier: disable=unnamed-macro
|
||||
def grpc_python_deps():
|
||||
"""Loads dependencies for gRPC Python."""
|
||||
if "io_bazel_rules_python" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "io_bazel_rules_python",
|
||||
url = "https://github.com/bazelbuild/rules_python/releases/download/0.4.0/rules_python-0.4.0.tar.gz",
|
||||
sha256 = "954aa89b491be4a083304a2cb838019c8b8c3720a7abb9c4cb81ac7a24230cea",
|
||||
patches = ["@com_github_grpc_grpc//third_party:rules_python.patch"],
|
||||
patch_args = ["-p1"],
|
||||
)
|
||||
|
||||
python_configure(name = "local_config_python")
|
||||
|
||||
native.bind(
|
||||
name = "python_headers",
|
||||
actual = "@local_config_python//:python_headers",
|
||||
)
|
||||
|
||||
if "cython" not in native.existing_rules():
|
||||
http_archive(
|
||||
name = "cython",
|
||||
build_file = "@com_github_grpc_grpc//third_party:cython.BUILD",
|
||||
sha256 = "a2da56cc22be823acf49741b9aa3aa116d4f07fa8e8b35a3cb08b8447b37c607",
|
||||
strip_prefix = "cython-0.29.35",
|
||||
urls = [
|
||||
"https://github.com/cython/cython/archive/0.29.35.tar.gz",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
# Follows convention set in objectivec_helpers.cc in the protobuf ObjC compiler.
|
||||
|
||||
"""
|
||||
Contains generic helper utilities.
|
||||
"""
|
||||
|
||||
_upper_segments_list = ["url", "http", "https"]
|
||||
|
||||
def strip_extension(str):
|
||||
return str.rpartition(".")[0]
|
||||
|
||||
def capitalize(word):
|
||||
if word in _upper_segments_list:
|
||||
return word.upper()
|
||||
else:
|
||||
return word.capitalize()
|
||||
|
||||
def lower_underscore_to_upper_camel(str):
|
||||
"""Converts from lower underscore case to upper camel case.
|
||||
|
||||
Args:
|
||||
str: The snake case string to convert.
|
||||
|
||||
Returns:
|
||||
The title case version of str.
|
||||
"""
|
||||
str = strip_extension(str)
|
||||
camel_case_str = ""
|
||||
word = ""
|
||||
for c in str.elems(): # NB: assumes ASCII!
|
||||
if c.isalpha():
|
||||
word += c.lower()
|
||||
else:
|
||||
# Last word is finished.
|
||||
if len(word):
|
||||
camel_case_str += capitalize(word)
|
||||
word = ""
|
||||
if c.isdigit():
|
||||
camel_case_str += c
|
||||
|
||||
# Otherwise, drop the character. See UnderscoresToCamelCase in:
|
||||
# third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
|
||||
|
||||
if len(word):
|
||||
camel_case_str += capitalize(word)
|
||||
return camel_case_str
|
||||
|
||||
def file_to_upper_camel(src):
|
||||
elements = src.rpartition("/")
|
||||
upper_camel = lower_underscore_to_upper_camel(elements[-1])
|
||||
return "".join(list(elements[:-1]) + [upper_camel])
|
||||
|
||||
def file_with_extension(src, ext):
|
||||
elements = src.rpartition("/")
|
||||
return "".join(list(elements[:-1]) + [elements[-1], "." + ext])
|
||||
|
||||
def to_upper_camel_with_extension(src, ext):
|
||||
src = file_to_upper_camel(src)
|
||||
return file_with_extension(src, ext)
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Python-related rules intended only for use internal to the repo."""
|
||||
|
||||
load("//bazel:gevent_test.bzl", "py_grpc_gevent_test")
|
||||
|
||||
def internal_py_grpc_test(name, **kwargs):
|
||||
"""Runs a test under all supported environments.
|
||||
|
||||
Args:
|
||||
name: The name of the test.
|
||||
**kwargs: Any additional arguments to add to the test.
|
||||
"""
|
||||
native.py_test(
|
||||
name = name + ".native",
|
||||
python_version = "PY3",
|
||||
**kwargs
|
||||
)
|
||||
py_grpc_gevent_test(name, **kwargs)
|
||||
|
||||
suite_kwargs = {}
|
||||
if "visibility" in kwargs:
|
||||
suite_kwargs["visibility"] = kwargs["visibility"]
|
||||
|
||||
native.test_suite(
|
||||
name = name,
|
||||
tests = [
|
||||
name + ".native",
|
||||
name + ".gevent",
|
||||
],
|
||||
**suite_kwargs
|
||||
)
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""
|
||||
Contains the objc_grpc_library rule.
|
||||
"""
|
||||
|
||||
load(
|
||||
"//bazel:generate_objc.bzl",
|
||||
"generate_objc",
|
||||
"generate_objc_hdrs",
|
||||
"generate_objc_non_arc_srcs",
|
||||
"generate_objc_srcs",
|
||||
)
|
||||
|
||||
def objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kwargs):
|
||||
"""Generates messages and/or service stubs for given proto_library and all transitively dependent proto files
|
||||
|
||||
Args:
|
||||
name: name of target
|
||||
deps: a list of proto_library targets that needs to be compiled
|
||||
srcs: a list of labels to proto files with service stubs to be generated,
|
||||
labels specified must include service stubs; otherwise Bazel will complain about srcs being empty
|
||||
use_well_known_protos: whether to use the well known protos defined in
|
||||
@com_google_protobuf//src/google/protobuf, default to false
|
||||
**kwargs: other arguments
|
||||
"""
|
||||
objc_grpc_library_name = "_" + name + "_objc_grpc_library"
|
||||
|
||||
generate_objc(
|
||||
name = objc_grpc_library_name,
|
||||
srcs = srcs,
|
||||
deps = deps,
|
||||
use_well_known_protos = use_well_known_protos,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
generate_objc_hdrs(
|
||||
name = objc_grpc_library_name + "_hdrs",
|
||||
src = ":" + objc_grpc_library_name,
|
||||
)
|
||||
|
||||
generate_objc_non_arc_srcs(
|
||||
name = objc_grpc_library_name + "_non_arc_srcs",
|
||||
src = ":" + objc_grpc_library_name,
|
||||
)
|
||||
|
||||
arc_srcs = None
|
||||
if len(srcs) > 0:
|
||||
generate_objc_srcs(
|
||||
name = objc_grpc_library_name + "_srcs",
|
||||
src = ":" + objc_grpc_library_name,
|
||||
)
|
||||
arc_srcs = [":" + objc_grpc_library_name + "_srcs"]
|
||||
|
||||
native.objc_library(
|
||||
name = name,
|
||||
hdrs = [":" + objc_grpc_library_name + "_hdrs"],
|
||||
non_arc_srcs = [":" + objc_grpc_library_name + "_non_arc_srcs"],
|
||||
srcs = arc_srcs,
|
||||
defines = [
|
||||
"GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0",
|
||||
"GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0",
|
||||
],
|
||||
includes = [
|
||||
"_generated_protos",
|
||||
"src/objective-c",
|
||||
],
|
||||
deps = [
|
||||
"@com_github_grpc_grpc//src/objective-c:proto_objc_rpc",
|
||||
"@com_google_protobuf//:protobuf_objc",
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
|
|
@ -0,0 +1,341 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Utility functions for generating protobuf code."""
|
||||
|
||||
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
|
||||
|
||||
_PROTO_EXTENSION = ".proto"
|
||||
_VIRTUAL_IMPORTS = "/_virtual_imports/"
|
||||
|
||||
_WELL_KNOWN_PROTOS_BASE = [
|
||||
"any_proto",
|
||||
"api_proto",
|
||||
"compiler_plugin_proto",
|
||||
"descriptor_proto",
|
||||
"duration_proto",
|
||||
"empty_proto",
|
||||
"field_mask_proto",
|
||||
"source_context_proto",
|
||||
"struct_proto",
|
||||
"timestamp_proto",
|
||||
"type_proto",
|
||||
"wrappers_proto",
|
||||
]
|
||||
|
||||
def well_known_proto_libs():
|
||||
return ["@com_google_protobuf//:" + b for b in _WELL_KNOWN_PROTOS_BASE]
|
||||
|
||||
def is_well_known(label):
|
||||
# Bazel surfaces labels as their undelying identity, even if they are referenced
|
||||
# via aliases. Bazel also does not currently provide a way to find the real label
|
||||
# underlying an alias. So the implementation detail that the WKTs present at the
|
||||
# top level of the protobuf repo are actually backed by targets in the
|
||||
# //src/google/protobuf package leaks through here.
|
||||
# We include both the alias path and the underlying path to be resilient to
|
||||
# reversions of this change as well as for continuing compatiblity with repos
|
||||
# that happen to pull in older versions of protobuf.
|
||||
all_wkt_targets = (["@com_google_protobuf//:" + b for b in _WELL_KNOWN_PROTOS_BASE] +
|
||||
["@com_google_protobuf//src/google/protobuf:" + b for b in _WELL_KNOWN_PROTOS_BASE])
|
||||
return label in all_wkt_targets
|
||||
|
||||
def get_proto_root(workspace_root):
|
||||
"""Gets the root protobuf directory.
|
||||
|
||||
Args:
|
||||
workspace_root: context.label.workspace_root
|
||||
|
||||
Returns:
|
||||
The directory relative to which generated include paths should be.
|
||||
"""
|
||||
if workspace_root:
|
||||
return "/{}".format(workspace_root)
|
||||
else:
|
||||
return ""
|
||||
|
||||
def _strip_proto_extension(proto_filename):
|
||||
if not proto_filename.endswith(_PROTO_EXTENSION):
|
||||
fail('"{}" does not end with "{}"'.format(
|
||||
proto_filename,
|
||||
_PROTO_EXTENSION,
|
||||
))
|
||||
return proto_filename[:-len(_PROTO_EXTENSION)]
|
||||
|
||||
def proto_path_to_generated_filename(proto_path, fmt_str):
|
||||
"""Calculates the name of a generated file for a protobuf path.
|
||||
|
||||
For example, "examples/protos/helloworld.proto" might map to
|
||||
"helloworld.pb.h".
|
||||
|
||||
Args:
|
||||
proto_path: The path to the .proto file.
|
||||
fmt_str: A format string used to calculate the generated filename. For
|
||||
example, "{}.pb.h" might be used to calculate a C++ header filename.
|
||||
|
||||
Returns:
|
||||
The generated filename.
|
||||
"""
|
||||
return fmt_str.format(_strip_proto_extension(proto_path))
|
||||
|
||||
def get_include_directory(source_file):
|
||||
"""Returns the include directory path for the source_file.
|
||||
|
||||
All of the include statements within the given source_file are calculated
|
||||
relative to the directory returned by this method.
|
||||
|
||||
The returned directory path can be used as the "--proto_path=" argument
|
||||
value.
|
||||
|
||||
Args:
|
||||
source_file: A proto file.
|
||||
|
||||
Returns:
|
||||
The include directory path for the source_file.
|
||||
"""
|
||||
directory = source_file.path
|
||||
prefix_len = 0
|
||||
|
||||
if is_in_virtual_imports(source_file):
|
||||
root, relative = source_file.path.split(_VIRTUAL_IMPORTS, 2)
|
||||
result = root + _VIRTUAL_IMPORTS + relative.split("/", 1)[0]
|
||||
return result
|
||||
|
||||
if not source_file.is_source and directory.startswith(source_file.root.path):
|
||||
prefix_len = len(source_file.root.path) + 1
|
||||
|
||||
if directory.startswith("external", prefix_len):
|
||||
external_separator = directory.find("/", prefix_len)
|
||||
repository_separator = directory.find("/", external_separator + 1)
|
||||
return directory[:repository_separator]
|
||||
else:
|
||||
return source_file.root.path if source_file.root.path else "."
|
||||
|
||||
def get_plugin_args(
|
||||
plugin,
|
||||
flags,
|
||||
dir_out,
|
||||
generate_mocks,
|
||||
plugin_name = "PLUGIN"):
|
||||
"""Returns arguments configuring protoc to use a plugin for a language.
|
||||
|
||||
Args:
|
||||
plugin: An executable file to run as the protoc plugin.
|
||||
flags: The plugin flags to be passed to protoc.
|
||||
dir_out: The output directory for the plugin.
|
||||
generate_mocks: A bool indicating whether to generate mocks.
|
||||
plugin_name: A name of the plugin, it is required to be unique when there
|
||||
are more than one plugin used in a single protoc command.
|
||||
Returns:
|
||||
A list of protoc arguments configuring the plugin.
|
||||
"""
|
||||
augmented_flags = list(flags)
|
||||
if generate_mocks:
|
||||
augmented_flags.append("generate_mock_code=true")
|
||||
|
||||
augmented_dir_out = dir_out
|
||||
if augmented_flags:
|
||||
augmented_dir_out = ",".join(augmented_flags) + ":" + dir_out
|
||||
|
||||
return [
|
||||
"--plugin=protoc-gen-{plugin_name}={plugin_path}".format(
|
||||
plugin_name = plugin_name,
|
||||
plugin_path = plugin.path,
|
||||
),
|
||||
"--{plugin_name}_out={dir_out}".format(
|
||||
plugin_name = plugin_name,
|
||||
dir_out = augmented_dir_out,
|
||||
),
|
||||
]
|
||||
|
||||
def _make_prefix(label):
|
||||
"""Returns the directory prefix for a label.
|
||||
|
||||
@repo//foo/bar:sub/dir/file.proto => 'external/repo/foo/bar/'
|
||||
//foo/bar:sub/dir/file.proto => 'foo/bar/'
|
||||
//:sub/dir/file.proto => ''
|
||||
|
||||
That is, the prefix can be removed from a file's full path to
|
||||
obtain the file's relative location within the package's effective
|
||||
directory."""
|
||||
|
||||
wsr = label.workspace_root
|
||||
pkg = label.package
|
||||
|
||||
if not wsr and not pkg:
|
||||
return ""
|
||||
elif not wsr:
|
||||
return pkg + "/"
|
||||
elif not pkg:
|
||||
return wsr + "/"
|
||||
else:
|
||||
return wsr + "/" + pkg + "/"
|
||||
|
||||
def get_staged_proto_file(label, context, source_file):
|
||||
"""Copies a proto file to the appropriate location if necessary.
|
||||
|
||||
Args:
|
||||
label: The label of the rule using the .proto file.
|
||||
context: The ctx object for the rule or aspect.
|
||||
source_file: The original .proto file.
|
||||
|
||||
Returns:
|
||||
The original proto file OR a new file in the staged location.
|
||||
"""
|
||||
if source_file.dirname == label.package or \
|
||||
is_in_virtual_imports(source_file):
|
||||
# Current target and source_file are in same package
|
||||
return source_file
|
||||
else:
|
||||
# Current target and source_file are in different packages (most
|
||||
# probably even in different repositories)
|
||||
prefix = _make_prefix(source_file.owner)
|
||||
copied_proto = context.actions.declare_file(source_file.path[len(prefix):])
|
||||
context.actions.run_shell(
|
||||
inputs = [source_file],
|
||||
outputs = [copied_proto],
|
||||
command = "cp {} {}".format(source_file.path, copied_proto.path),
|
||||
mnemonic = "CopySourceProto",
|
||||
)
|
||||
return copied_proto
|
||||
|
||||
def protos_from_context(context):
|
||||
"""Copies proto files to the appropriate location.
|
||||
|
||||
Args:
|
||||
context: The ctx object for the rule.
|
||||
|
||||
Returns:
|
||||
A list of the protos.
|
||||
"""
|
||||
protos = []
|
||||
for src in context.attr.deps:
|
||||
for file in src[ProtoInfo].direct_sources:
|
||||
protos.append(get_staged_proto_file(context.label, context, file))
|
||||
return protos
|
||||
|
||||
def includes_from_deps(deps):
|
||||
"""Get includes from rule dependencies."""
|
||||
return [
|
||||
file
|
||||
for src in deps
|
||||
for file in src[ProtoInfo].transitive_imports.to_list()
|
||||
]
|
||||
|
||||
def get_proto_arguments(protos, genfiles_dir_path):
|
||||
"""Get the protoc arguments specifying which protos to compile.
|
||||
|
||||
Args:
|
||||
protos: The protob files to supply.
|
||||
genfiles_dir_path: The path to the genfiles directory.
|
||||
|
||||
Returns:
|
||||
The arguments to supply to protoc.
|
||||
"""
|
||||
arguments = []
|
||||
for proto in protos:
|
||||
strip_prefix_len = 0
|
||||
if is_in_virtual_imports(proto):
|
||||
incl_directory = get_include_directory(proto)
|
||||
if proto.path.startswith(incl_directory):
|
||||
strip_prefix_len = len(incl_directory) + 1
|
||||
elif proto.path.startswith(genfiles_dir_path):
|
||||
strip_prefix_len = len(genfiles_dir_path) + 1
|
||||
|
||||
arguments.append(proto.path[strip_prefix_len:])
|
||||
|
||||
return arguments
|
||||
|
||||
def declare_out_files(protos, context, generated_file_format):
|
||||
"""Declares and returns the files to be generated.
|
||||
|
||||
Args:
|
||||
protos: A list of files. The protos to declare.
|
||||
context: The context object.
|
||||
generated_file_format: A format string. Will be passed to
|
||||
proto_path_to_generated_filename to generate the filename of each
|
||||
generated file.
|
||||
|
||||
Returns:
|
||||
A list of file providers.
|
||||
"""
|
||||
|
||||
out_file_paths = []
|
||||
for proto in protos:
|
||||
if not is_in_virtual_imports(proto):
|
||||
prefix = _make_prefix(proto.owner)
|
||||
full_prefix = context.genfiles_dir.path + "/" + prefix
|
||||
if proto.path.startswith(full_prefix):
|
||||
out_file_paths.append(proto.path[len(full_prefix):])
|
||||
elif proto.path.startswith(prefix):
|
||||
out_file_paths.append(proto.path[len(prefix):])
|
||||
else:
|
||||
out_file_paths.append(proto.path[proto.path.index(_VIRTUAL_IMPORTS) + 1:])
|
||||
|
||||
return [
|
||||
context.actions.declare_file(
|
||||
proto_path_to_generated_filename(
|
||||
out_file_path,
|
||||
generated_file_format,
|
||||
),
|
||||
)
|
||||
for out_file_path in out_file_paths
|
||||
]
|
||||
|
||||
def get_out_dir(protos, context):
|
||||
"""Returns the value to supply to the --<lang>_out= protoc flag.
|
||||
|
||||
The result is based on the input source proto files and current context.
|
||||
|
||||
Args:
|
||||
protos: A list of protos to be used as source files in protoc command
|
||||
context: A ctx object for the rule.
|
||||
Returns:
|
||||
The value of --<lang>_out= argument.
|
||||
"""
|
||||
at_least_one_virtual = 0
|
||||
for proto in protos:
|
||||
if is_in_virtual_imports(proto):
|
||||
at_least_one_virtual = True
|
||||
elif at_least_one_virtual:
|
||||
fail("Proto sources must be either all virtual imports or all real")
|
||||
if at_least_one_virtual:
|
||||
out_dir = get_include_directory(protos[0])
|
||||
ws_root = protos[0].owner.workspace_root
|
||||
prefix = "/" + _make_prefix(protos[0].owner) + _VIRTUAL_IMPORTS[1:]
|
||||
|
||||
return struct(
|
||||
path = out_dir,
|
||||
import_path = out_dir[out_dir.find(prefix) + 1:],
|
||||
)
|
||||
|
||||
out_dir = context.genfiles_dir.path
|
||||
ws_root = context.label.workspace_root
|
||||
if ws_root:
|
||||
out_dir = out_dir + "/" + ws_root
|
||||
return struct(path = out_dir, import_path = None)
|
||||
|
||||
def is_in_virtual_imports(source_file, virtual_folder = _VIRTUAL_IMPORTS):
|
||||
"""Determines if source_file is virtual.
|
||||
|
||||
A file is virtual if placed in the _virtual_imports subdirectory. The
|
||||
output of all proto_library targets which use import_prefix and/or
|
||||
strip_import_prefix arguments is placed under _virtual_imports directory.
|
||||
|
||||
Args:
|
||||
source_file: A proto file.
|
||||
virtual_folder: The virtual folder name (is set to "_virtual_imports"
|
||||
by default)
|
||||
Returns:
|
||||
True if source_file is located under _virtual_imports, False otherwise.
|
||||
"""
|
||||
return not source_file.is_source and virtual_folder in source_file.path
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
# Copyright 2021 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
"""Generates and compiles Python gRPC stubs from proto_library rules."""
|
||||
|
||||
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
|
||||
load(
|
||||
"//bazel:protobuf.bzl",
|
||||
"declare_out_files",
|
||||
"get_include_directory",
|
||||
"get_out_dir",
|
||||
"get_plugin_args",
|
||||
"get_proto_arguments",
|
||||
"get_staged_proto_file",
|
||||
"includes_from_deps",
|
||||
"is_well_known",
|
||||
"protos_from_context",
|
||||
)
|
||||
|
||||
_GENERATED_PROTO_FORMAT = "{}_pb2.py"
|
||||
_GENERATED_PROTO_STUB_FORMAT = "{}_pb2.pyi"
|
||||
_GENERATED_GRPC_PROTO_FORMAT = "{}_pb2_grpc.py"
|
||||
|
||||
PyProtoInfo = provider(
|
||||
"The Python outputs from the Protobuf compiler.",
|
||||
fields = {
|
||||
"py_info": "A PyInfo provider for the generated code.",
|
||||
"generated_py_srcs": "The direct (not transitive) generated Python source files.",
|
||||
},
|
||||
)
|
||||
|
||||
def _merge_pyinfos(pyinfos):
|
||||
return PyInfo(
|
||||
transitive_sources = depset(transitive = [p.transitive_sources for p in pyinfos]),
|
||||
imports = depset(transitive = [p.imports for p in pyinfos]),
|
||||
)
|
||||
|
||||
def _gen_py_aspect_impl(target, context):
|
||||
# Early return for well-known protos.
|
||||
if is_well_known(str(context.label)):
|
||||
return [
|
||||
PyProtoInfo(
|
||||
py_info = context.attr._protobuf_library[PyInfo],
|
||||
generated_py_srcs = [],
|
||||
),
|
||||
]
|
||||
|
||||
protos = []
|
||||
for p in target[ProtoInfo].direct_sources:
|
||||
protos.append(get_staged_proto_file(target.label, context, p))
|
||||
|
||||
includes = depset(direct = protos, transitive = [target[ProtoInfo].transitive_imports])
|
||||
out_files = (declare_out_files(protos, context, _GENERATED_PROTO_FORMAT) +
|
||||
declare_out_files(protos, context, _GENERATED_PROTO_STUB_FORMAT))
|
||||
generated_py_srcs = out_files
|
||||
|
||||
tools = [context.executable._protoc]
|
||||
|
||||
out_dir = get_out_dir(protos, context)
|
||||
|
||||
arguments = ([
|
||||
"--python_out={}".format(out_dir.path),
|
||||
"--pyi_out={}".format(out_dir.path),
|
||||
] + [
|
||||
"--proto_path={}".format(get_include_directory(i))
|
||||
for i in includes.to_list()
|
||||
] + [
|
||||
"--proto_path={}".format(context.genfiles_dir.path),
|
||||
])
|
||||
|
||||
arguments += get_proto_arguments(protos, context.genfiles_dir.path)
|
||||
|
||||
context.actions.run(
|
||||
inputs = protos + includes.to_list(),
|
||||
tools = tools,
|
||||
outputs = out_files,
|
||||
executable = context.executable._protoc,
|
||||
arguments = arguments,
|
||||
mnemonic = "ProtocInvocation",
|
||||
)
|
||||
|
||||
imports = []
|
||||
if out_dir.import_path:
|
||||
imports.append("{}/{}".format(context.workspace_name, out_dir.import_path))
|
||||
|
||||
py_info = PyInfo(transitive_sources = depset(direct = out_files), imports = depset(direct = imports))
|
||||
return PyProtoInfo(
|
||||
py_info = _merge_pyinfos(
|
||||
[
|
||||
py_info,
|
||||
context.attr._protobuf_library[PyInfo],
|
||||
] + [dep[PyProtoInfo].py_info for dep in context.rule.attr.deps],
|
||||
),
|
||||
generated_py_srcs = generated_py_srcs,
|
||||
)
|
||||
|
||||
_gen_py_aspect = aspect(
|
||||
implementation = _gen_py_aspect_impl,
|
||||
attr_aspects = ["deps"],
|
||||
fragments = ["py"],
|
||||
attrs = {
|
||||
"_protoc": attr.label(
|
||||
default = Label("//external:protocol_compiler"),
|
||||
providers = ["files_to_run"],
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
),
|
||||
"_protobuf_library": attr.label(
|
||||
default = Label("@com_google_protobuf//:protobuf_python"),
|
||||
providers = [PyInfo],
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
def _generate_py_impl(context):
|
||||
if (len(context.attr.deps) != 1):
|
||||
fail("Can only compile a single proto at a time.")
|
||||
|
||||
py_sources = []
|
||||
|
||||
# If the proto_library this rule *directly* depends on is in another
|
||||
# package, then we generate .py files to import them in this package. This
|
||||
# behavior is needed to allow rearranging of import paths to make Bazel
|
||||
# outputs align with native python workflows.
|
||||
#
|
||||
# Note that this approach is vulnerable to protoc defining __all__ or other
|
||||
# symbols with __ prefixes that need to be directly imported. Since these
|
||||
# names are likely to be reserved for private APIs, the risk is minimal.
|
||||
if context.label.package != context.attr.deps[0].label.package:
|
||||
for py_src in context.attr.deps[0][PyProtoInfo].generated_py_srcs:
|
||||
reimport_py_file = context.actions.declare_file(py_src.basename)
|
||||
py_sources.append(reimport_py_file)
|
||||
import_line = "from %s import *" % py_src.short_path.replace("..", "external").replace("/", ".")[:-len(".py")]
|
||||
context.actions.write(reimport_py_file, import_line)
|
||||
|
||||
# Collect output PyInfo provider.
|
||||
imports = [context.label.package + "/" + i for i in context.attr.imports]
|
||||
py_info = PyInfo(transitive_sources = depset(direct = py_sources), imports = depset(direct = imports))
|
||||
out_pyinfo = _merge_pyinfos([py_info, context.attr.deps[0][PyProtoInfo].py_info])
|
||||
|
||||
runfiles = context.runfiles(files = out_pyinfo.transitive_sources.to_list()).merge(context.attr._protobuf_library[DefaultInfo].data_runfiles)
|
||||
return [
|
||||
DefaultInfo(
|
||||
files = out_pyinfo.transitive_sources,
|
||||
runfiles = runfiles,
|
||||
),
|
||||
out_pyinfo,
|
||||
]
|
||||
|
||||
py_proto_library = rule(
|
||||
attrs = {
|
||||
"deps": attr.label_list(
|
||||
mandatory = True,
|
||||
allow_empty = False,
|
||||
providers = [ProtoInfo],
|
||||
aspects = [_gen_py_aspect],
|
||||
),
|
||||
"_protoc": attr.label(
|
||||
default = Label("//external:protocol_compiler"),
|
||||
providers = ["files_to_run"],
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
),
|
||||
"_protobuf_library": attr.label(
|
||||
default = Label("@com_google_protobuf//:protobuf_python"),
|
||||
providers = [PyInfo],
|
||||
),
|
||||
"imports": attr.string_list(),
|
||||
},
|
||||
implementation = _generate_py_impl,
|
||||
)
|
||||
|
||||
def _generate_pb2_grpc_src_impl(context):
|
||||
protos = protos_from_context(context)
|
||||
includes = includes_from_deps(context.attr.deps)
|
||||
out_files = declare_out_files(protos, context, _GENERATED_GRPC_PROTO_FORMAT)
|
||||
|
||||
plugin_flags = ["grpc_2_0"] + context.attr.strip_prefixes
|
||||
|
||||
arguments = []
|
||||
tools = [context.executable._protoc, context.executable._grpc_plugin]
|
||||
out_dir = get_out_dir(protos, context)
|
||||
if out_dir.import_path:
|
||||
# is virtual imports
|
||||
out_path = out_dir.path
|
||||
else:
|
||||
out_path = context.genfiles_dir.path
|
||||
arguments += get_plugin_args(
|
||||
context.executable._grpc_plugin,
|
||||
plugin_flags,
|
||||
out_path,
|
||||
False,
|
||||
)
|
||||
|
||||
arguments += [
|
||||
"--proto_path={}".format(get_include_directory(i))
|
||||
for i in includes
|
||||
]
|
||||
arguments.append("--proto_path={}".format(context.genfiles_dir.path))
|
||||
arguments += get_proto_arguments(protos, context.genfiles_dir.path)
|
||||
|
||||
context.actions.run(
|
||||
inputs = protos + includes,
|
||||
tools = tools,
|
||||
outputs = out_files,
|
||||
executable = context.executable._protoc,
|
||||
arguments = arguments,
|
||||
mnemonic = "ProtocInvocation",
|
||||
)
|
||||
|
||||
p = PyInfo(transitive_sources = depset(direct = out_files))
|
||||
py_info = _merge_pyinfos(
|
||||
[
|
||||
p,
|
||||
context.attr._grpc_library[PyInfo],
|
||||
] + [dep[PyInfo] for dep in context.attr.py_deps],
|
||||
)
|
||||
|
||||
runfiles = context.runfiles(files = out_files, transitive_files = py_info.transitive_sources).merge(context.attr._grpc_library[DefaultInfo].data_runfiles)
|
||||
|
||||
return [
|
||||
DefaultInfo(
|
||||
files = depset(direct = out_files),
|
||||
runfiles = runfiles,
|
||||
),
|
||||
py_info,
|
||||
]
|
||||
|
||||
_generate_pb2_grpc_src = rule(
|
||||
attrs = {
|
||||
"deps": attr.label_list(
|
||||
mandatory = True,
|
||||
allow_empty = False,
|
||||
providers = [ProtoInfo],
|
||||
),
|
||||
"py_deps": attr.label_list(
|
||||
mandatory = True,
|
||||
allow_empty = False,
|
||||
providers = [PyInfo],
|
||||
),
|
||||
"strip_prefixes": attr.string_list(),
|
||||
"_grpc_plugin": attr.label(
|
||||
executable = True,
|
||||
providers = ["files_to_run"],
|
||||
cfg = "host",
|
||||
default = Label("//src/compiler:grpc_python_plugin"),
|
||||
),
|
||||
"_protoc": attr.label(
|
||||
executable = True,
|
||||
providers = ["files_to_run"],
|
||||
cfg = "host",
|
||||
default = Label("//external:protocol_compiler"),
|
||||
),
|
||||
"_grpc_library": attr.label(
|
||||
default = Label("//src/python/grpcio/grpc:grpcio"),
|
||||
providers = [PyInfo],
|
||||
),
|
||||
},
|
||||
implementation = _generate_pb2_grpc_src_impl,
|
||||
)
|
||||
|
||||
def py_grpc_library(
|
||||
name,
|
||||
srcs,
|
||||
deps,
|
||||
strip_prefixes = [],
|
||||
**kwargs):
|
||||
"""Generate python code for gRPC services defined in a protobuf.
|
||||
|
||||
Args:
|
||||
name: The name of the target.
|
||||
srcs: (List of `labels`) a single proto_library target containing the
|
||||
schema of the service.
|
||||
deps: (List of `labels`) a single py_proto_library target for the
|
||||
proto_library in `srcs`.
|
||||
strip_prefixes: (List of `strings`) If provided, this prefix will be
|
||||
stripped from the beginning of foo_pb2 modules imported by the
|
||||
generated stubs. This is useful in combination with the `imports`
|
||||
attribute of the `py_library` rule.
|
||||
**kwargs: Additional arguments to be supplied to the invocation of
|
||||
py_library.
|
||||
"""
|
||||
if len(srcs) != 1:
|
||||
fail("Can only compile a single proto at a time.")
|
||||
|
||||
if len(deps) != 1:
|
||||
fail("Deps must have length 1.")
|
||||
|
||||
_generate_pb2_grpc_src(
|
||||
name = name,
|
||||
deps = srcs,
|
||||
py_deps = deps,
|
||||
strip_prefixes = strip_prefixes,
|
||||
**kwargs
|
||||
)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
6.3.2
|
||||
5.4.1
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
# Copyright 2023 gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Auto generated by tools/codegen/core/gen_experiments.py
|
||||
|
||||
"""Dictionary of tags to experiments so we know when to test different experiments."""
|
||||
|
||||
TEST_EXPERIMENTS = {
|
||||
"windows": {
|
||||
"dbg": {
|
||||
},
|
||||
"off": {
|
||||
"experiments_tag_test": [
|
||||
"test_experiment_1",
|
||||
],
|
||||
},
|
||||
"on": {
|
||||
},
|
||||
},
|
||||
"ios": {
|
||||
"dbg": {
|
||||
},
|
||||
"off": {
|
||||
},
|
||||
"on": {
|
||||
},
|
||||
},
|
||||
"posix": {
|
||||
"dbg": {
|
||||
},
|
||||
"off": {
|
||||
},
|
||||
"on": {
|
||||
"experiments_tag_test": [
|
||||
"test_experiment_1",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2020 The gRPC Authors
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Script to upload github archives for bazel dependencies to GCS, creating a reliable mirror link.
|
||||
# Archives are copied to "grpc-bazel-mirror" GCS bucket (https://console.cloud.google.com/storage/browser/grpc-bazel-mirror?project=grpc-testing)
|
||||
# and will by downloadable with the https://storage.googleapis.com/grpc-bazel-mirror/ prefix.
|
||||
#
|
||||
# This script should be run each time bazel dependencies are updated.
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
# Create a temp directory to hold the versioned tarball,
|
||||
# and clean it up when the script exits.
|
||||
tmpdir="$(mktemp -d)"
|
||||
function cleanup {
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
function upload {
|
||||
local file="$1"
|
||||
|
||||
if gsutil stat "gs://grpc-bazel-mirror/${file}" > /dev/null
|
||||
then
|
||||
echo "Skipping ${file}"
|
||||
else
|
||||
echo "Downloading https://${file}"
|
||||
curl -L --fail --output "${tmpdir}/archive" "https://${file}"
|
||||
|
||||
echo "Uploading https://${file} to https://storage.googleapis.com/grpc-bazel-mirror/${file}"
|
||||
gsutil cp "${tmpdir}/archive" "gs://grpc-bazel-mirror/${file}"
|
||||
|
||||
rm -rf "${tmpdir}/archive"
|
||||
fi
|
||||
}
|
||||
|
||||
# How to check that all mirror URLs work:
|
||||
# 1. clean $HOME/.cache/bazel
|
||||
# 2. bazel clean --expunge
|
||||
# 3. bazel sync (failed downloads will print warnings)
|
||||
|
||||
# A specific link can be upload manually by running e.g.
|
||||
# upload "github.com/google/boringssl/archive/1c2769383f027befac5b75b6cedd25daf3bf4dcf.tar.gz"
|
||||
|
||||
# bazel binaries used by the tools/bazel wrapper script
|
||||
upload github.com/bazelbuild/bazel/releases/download/5.4.1/bazel-5.4.1-linux-x86_64
|
||||
upload github.com/bazelbuild/bazel/releases/download/5.4.1/bazel-5.4.1-darwin-x86_64
|
||||
upload github.com/bazelbuild/bazel/releases/download/5.4.1/bazel-5.4.1-windows-x86_64.exe
|
||||
|
||||
upload github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-x86_64
|
||||
upload github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-darwin-x86_64
|
||||
upload github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-windows-x86_64.exe
|
||||
|
||||
upload github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64
|
||||
upload github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-darwin-x86_64
|
||||
upload github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-windows-x86_64.exe
|
||||
|
||||
# Collect the github archives to mirror from grpc_deps.bzl
|
||||
grep -o '"https://github.com/[^"]*"' bazel/grpc_deps.bzl | sed 's/^"https:\/\///' | sed 's/"$//' | while read -r line ; do
|
||||
echo "Updating mirror for ${line}"
|
||||
upload "${line}"
|
||||
done
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
||||
|
||||
config_setting(
|
||||
name = "darwin",
|
||||
values = {"cpu": "darwin"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "darwin_x86_64",
|
||||
values = {"cpu": "darwin_x86_64"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "darwin_arm64",
|
||||
values = {"cpu": "darwin_arm64"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "darwin_arm64e",
|
||||
values = {"cpu": "darwin_arm64e"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "windows",
|
||||
values = {"cpu": "x64_windows"},
|
||||
)
|
||||
|
||||
# Android is not officially supported through C++.
|
||||
# This just helps with the build for now.
|
||||
config_setting(
|
||||
name = "android",
|
||||
values = {
|
||||
"crosstool_top": "//external:android/crosstool",
|
||||
},
|
||||
)
|
||||
|
||||
# iOS is not officially supported through C++.
|
||||
# This just helps with the build for now.
|
||||
config_setting(
|
||||
name = "ios_x86_64",
|
||||
values = {"cpu": "ios_x86_64"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "ios_armv7",
|
||||
values = {"cpu": "ios_armv7"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "ios_armv7s",
|
||||
values = {"cpu": "ios_armv7s"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "ios_arm64",
|
||||
values = {"cpu": "ios_arm64"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "ios_sim_arm64",
|
||||
values = {"cpu": "ios_sim_arm64"},
|
||||
)
|
||||
|
||||
# The following architectures are found in
|
||||
# https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java
|
||||
config_setting(
|
||||
name = "tvos_x86_64",
|
||||
values = {"cpu": "tvos_x86_64"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "tvos_arm64",
|
||||
values = {"cpu": "tvos_arm64"}
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "watchos_i386",
|
||||
values = {"cpu": "watchos_i386"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "watchos_x86_64",
|
||||
values = {"cpu": "watchos_x86_64"}
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "watchos_armv7k",
|
||||
values = {"cpu": "watchos_armv7k"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "watchos_arm64_32",
|
||||
values = {"cpu": "watchos_arm64_32"}
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "openbsd",
|
||||
values = {"cpu": "openbsd"},
|
||||
)
|
||||
|
||||
copy_file(
|
||||
name = "ares_build_h",
|
||||
src = "@com_github_grpc_grpc//third_party/cares:ares_build.h",
|
||||
out = "ares_build.h",
|
||||
)
|
||||
|
||||
copy_file(
|
||||
name = "ares_config_h",
|
||||
src = select({
|
||||
":ios_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":ios_armv7": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":ios_armv7s": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":ios_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":ios_sim_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":tvos_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":tvos_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":watchos_i386": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":watchos_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":watchos_armv7k": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":watchos_arm64_32": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":darwin": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":darwin_x86_64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":darwin_arm64": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":darwin_arm64e": "@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h",
|
||||
":windows": "@com_github_grpc_grpc//third_party/cares:config_windows/ares_config.h",
|
||||
":android": "@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h",
|
||||
":openbsd": "@com_github_grpc_grpc//third_party/cares:config_openbsd/ares_config.h",
|
||||
"//conditions:default": "@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h",
|
||||
}),
|
||||
out = "ares_config.h",
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "ares",
|
||||
srcs = [
|
||||
"src/lib/ares__read_line.c",
|
||||
"src/lib/ares__get_hostent.c",
|
||||
"src/lib/ares__close_sockets.c",
|
||||
"src/lib/ares__timeval.c",
|
||||
"src/lib/ares_gethostbyaddr.c",
|
||||
"src/lib/ares_getenv.c",
|
||||
"src/lib/ares_free_string.c",
|
||||
"src/lib/ares_free_hostent.c",
|
||||
"src/lib/ares_fds.c",
|
||||
"src/lib/ares_expand_string.c",
|
||||
"src/lib/ares_create_query.c",
|
||||
"src/lib/ares_cancel.c",
|
||||
"src/lib/ares_android.c",
|
||||
"src/lib/ares_parse_txt_reply.c",
|
||||
"src/lib/ares_parse_srv_reply.c",
|
||||
"src/lib/ares_parse_soa_reply.c",
|
||||
"src/lib/ares_parse_ptr_reply.c",
|
||||
"src/lib/ares_parse_ns_reply.c",
|
||||
"src/lib/ares_parse_naptr_reply.c",
|
||||
"src/lib/ares_parse_mx_reply.c",
|
||||
"src/lib/ares_parse_caa_reply.c",
|
||||
"src/lib/ares_options.c",
|
||||
"src/lib/ares_nowarn.c",
|
||||
"src/lib/ares_mkquery.c",
|
||||
"src/lib/ares_llist.c",
|
||||
"src/lib/ares_getsock.c",
|
||||
"src/lib/ares_getnameinfo.c",
|
||||
"src/lib/bitncmp.c",
|
||||
"src/lib/ares_writev.c",
|
||||
"src/lib/ares_version.c",
|
||||
"src/lib/ares_timeout.c",
|
||||
"src/lib/ares_strerror.c",
|
||||
"src/lib/ares_strcasecmp.c",
|
||||
"src/lib/ares_search.c",
|
||||
"src/lib/ares_platform.c",
|
||||
"src/lib/windows_port.c",
|
||||
"src/lib/inet_ntop.c",
|
||||
"src/lib/ares__sortaddrinfo.c",
|
||||
"src/lib/ares__readaddrinfo.c",
|
||||
"src/lib/ares_parse_uri_reply.c",
|
||||
"src/lib/ares__parse_into_addrinfo.c",
|
||||
"src/lib/ares_parse_a_reply.c",
|
||||
"src/lib/ares_parse_aaaa_reply.c",
|
||||
"src/lib/ares_library_init.c",
|
||||
"src/lib/ares_init.c",
|
||||
"src/lib/ares_gethostbyname.c",
|
||||
"src/lib/ares_getaddrinfo.c",
|
||||
"src/lib/ares_freeaddrinfo.c",
|
||||
"src/lib/ares_expand_name.c",
|
||||
"src/lib/ares_destroy.c",
|
||||
"src/lib/ares_data.c",
|
||||
"src/lib/ares__addrinfo_localhost.c",
|
||||
"src/lib/ares__addrinfo2hostent.c",
|
||||
"src/lib/inet_net_pton.c",
|
||||
"src/lib/ares_strsplit.c",
|
||||
"src/lib/ares_strdup.c",
|
||||
"src/lib/ares_send.c",
|
||||
"src/lib/ares_rand.c",
|
||||
"src/lib/ares_query.c",
|
||||
"src/lib/ares_process.c",
|
||||
],
|
||||
hdrs = [
|
||||
"ares_build.h",
|
||||
"ares_config.h",
|
||||
"include/ares_version.h",
|
||||
"include/ares.h",
|
||||
"include/ares_rules.h",
|
||||
"include/ares_dns.h",
|
||||
"include/ares_nameser.h",
|
||||
"src/tools/ares_getopt.h",
|
||||
"src/lib/ares_strsplit.h",
|
||||
"src/lib/ares_android.h",
|
||||
"src/lib/ares_private.h",
|
||||
"src/lib/ares_llist.h",
|
||||
"src/lib/ares_platform.h",
|
||||
"src/lib/ares_ipv6.h",
|
||||
"src/lib/config-dos.h",
|
||||
"src/lib/bitncmp.h",
|
||||
"src/lib/ares_strcasecmp.h",
|
||||
"src/lib/setup_once.h",
|
||||
"src/lib/ares_inet_net_pton.h",
|
||||
"src/lib/ares_data.h",
|
||||
"src/lib/ares_getenv.h",
|
||||
"src/lib/config-win32.h",
|
||||
"src/lib/ares_strdup.h",
|
||||
"src/lib/ares_iphlpapi.h",
|
||||
"src/lib/ares_setup.h",
|
||||
"src/lib/ares_writev.h",
|
||||
"src/lib/ares_nowarn.h",
|
||||
],
|
||||
copts = [
|
||||
"-D_GNU_SOURCE",
|
||||
"-D_HAS_EXCEPTIONS=0",
|
||||
"-DHAVE_CONFIG_H",
|
||||
] + select({
|
||||
":windows": [
|
||||
"-DNOMINMAX",
|
||||
"-D_CRT_SECURE_NO_DEPRECATE",
|
||||
"-D_CRT_NONSTDC_NO_DEPRECATE",
|
||||
"-D_WIN32_WINNT=0x0600",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
defines = ["CARES_STATICLIB"],
|
||||
includes = ["include", "."],
|
||||
linkopts = select({
|
||||
":windows": ["-defaultlib:ws2_32.lib"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
linkstatic = 1,
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
py_library(
|
||||
name = "constantly",
|
||||
srcs = glob(["constantly/*.py"]),
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Adapted with modifications from tensorflow/third_party/cython.BUILD
|
||||
|
||||
py_library(
|
||||
name="cython_lib",
|
||||
srcs=glob(
|
||||
["Cython/**/*.py"],
|
||||
exclude=[
|
||||
"**/Tests/*.py",
|
||||
],
|
||||
) + ["cython.py"],
|
||||
data=glob([
|
||||
"Cython/**/*.pyx",
|
||||
"Cython/Utility/*.*",
|
||||
"Cython/Includes/**/*.pxd",
|
||||
]),
|
||||
srcs_version="PY2AND3",
|
||||
visibility=["//visibility:public"],
|
||||
)
|
||||
|
||||
# May not be named "cython", since that conflicts with Cython/ on OSX
|
||||
py_binary(
|
||||
name="cython_binary",
|
||||
srcs=["cython.py"],
|
||||
main="cython.py",
|
||||
srcs_version="PY2AND3",
|
||||
visibility=["//visibility:public"],
|
||||
deps=["cython_lib"],
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
py_library(
|
||||
name = "enum34",
|
||||
srcs = ["enum/__init__.py"],
|
||||
srcs_version = "PY2AND3",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
py_library(
|
||||
name = "futures",
|
||||
srcs = glob(["concurrent/**/*.py"]),
|
||||
srcs_version = "PY2AND3",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
py_library(
|
||||
name = "incremental",
|
||||
srcs = glob(["src/incremental/*.py"]),
|
||||
imports = [
|
||||
"src",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2021 gRPC authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "libprotobuf_mutator",
|
||||
srcs = glob(
|
||||
["src/*.cc", "src/libfuzzer/*.cc"],
|
||||
exclude = ["src/*_test.cc", "src/libfuzzer/*_test.cc"]
|
||||
),
|
||||
hdrs = glob(["src/*.h", "port/*.h", "src/libfuzzer/*.h"]),
|
||||
deps = [
|
||||
"@com_google_protobuf//:protobuf",
|
||||
"@com_google_googletest//:gtest",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
includes = ["."]
|
||||
)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
genrule(
|
||||
name = "copy_six",
|
||||
srcs = ["six-1.16.0/six.py"],
|
||||
outs = ["__init__.py"],
|
||||
cmd = "cp $< $(@)",
|
||||
)
|
||||
|
||||
py_library(
|
||||
name = "six",
|
||||
srcs = ["__init__.py"],
|
||||
srcs_version = "PY2AND3",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
py_library(
|
||||
name = "twisted",
|
||||
srcs = glob(["src/twisted/**/*.py"]),
|
||||
imports = [
|
||||
"src",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
deps = [
|
||||
"@com_github_twisted_incremental//:incremental",
|
||||
"@com_github_twisted_constantly//:constantly",
|
||||
"@com_github_zopefoundation_zope_interface//:zope_interface",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
# Copyright (c) 2009-2021, Google LLC
|
||||
# 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 LLC 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 Google LLC 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.
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "liblua_headers",
|
||||
hdrs = [
|
||||
"src/lauxlib.h",
|
||||
"src/lua.h",
|
||||
"src/lua.hpp",
|
||||
"src/luaconf.h",
|
||||
"src/lualib.h",
|
||||
],
|
||||
defines = ["LUA_USE_LINUX"],
|
||||
includes = ["src"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "liblua",
|
||||
srcs = [
|
||||
"src/lapi.c",
|
||||
"src/lapi.h",
|
||||
"src/lauxlib.c",
|
||||
"src/lauxlib.h",
|
||||
"src/lbaselib.c",
|
||||
"src/lbitlib.c",
|
||||
"src/lcode.c",
|
||||
"src/lcode.h",
|
||||
"src/lcorolib.c",
|
||||
"src/lctype.c",
|
||||
"src/lctype.h",
|
||||
"src/ldblib.c",
|
||||
"src/ldebug.c",
|
||||
"src/ldebug.h",
|
||||
"src/ldo.c",
|
||||
"src/ldo.h",
|
||||
"src/ldump.c",
|
||||
"src/lfunc.c",
|
||||
"src/lfunc.h",
|
||||
"src/lgc.c",
|
||||
"src/lgc.h",
|
||||
"src/linit.c",
|
||||
"src/liolib.c",
|
||||
"src/llex.c",
|
||||
"src/llex.h",
|
||||
"src/llimits.h",
|
||||
"src/lmathlib.c",
|
||||
"src/lmem.c",
|
||||
"src/lmem.h",
|
||||
"src/loadlib.c",
|
||||
"src/lobject.c",
|
||||
"src/lobject.h",
|
||||
"src/lopcodes.c",
|
||||
"src/lopcodes.h",
|
||||
"src/loslib.c",
|
||||
"src/lparser.c",
|
||||
"src/lparser.h",
|
||||
"src/lstate.c",
|
||||
"src/lstate.h",
|
||||
"src/lstring.c",
|
||||
"src/lstring.h",
|
||||
"src/lstrlib.c",
|
||||
"src/ltable.c",
|
||||
"src/ltable.h",
|
||||
"src/ltablib.c",
|
||||
"src/ltm.c",
|
||||
"src/ltm.h",
|
||||
"src/lundump.c",
|
||||
"src/lundump.h",
|
||||
"src/lvm.c",
|
||||
"src/lvm.h",
|
||||
"src/lzio.c",
|
||||
"src/lzio.h",
|
||||
],
|
||||
hdrs = [
|
||||
"src/lauxlib.h",
|
||||
"src/lua.h",
|
||||
"src/lua.hpp",
|
||||
"src/luaconf.h",
|
||||
"src/lualib.h",
|
||||
],
|
||||
defines = ["LUA_USE_LINUX"],
|
||||
includes = ["src"],
|
||||
linkopts = [
|
||||
"-lm",
|
||||
"-ldl",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "lua",
|
||||
srcs = [
|
||||
"src/lua.c",
|
||||
],
|
||||
linkopts = [
|
||||
"-lreadline",
|
||||
"-rdynamic",
|
||||
],
|
||||
deps = [
|
||||
":liblua",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
py_library(
|
||||
name = "yaml",
|
||||
srcs = glob(["lib/yaml/*.py"]),
|
||||
imports = [
|
||||
"lib",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
cc_library(
|
||||
name = "zlib",
|
||||
srcs = [
|
||||
"adler32.c",
|
||||
"compress.c",
|
||||
"crc32.c",
|
||||
"deflate.c",
|
||||
"infback.c",
|
||||
"inffast.c",
|
||||
"inflate.c",
|
||||
"inftrees.c",
|
||||
"trees.c",
|
||||
"uncompr.c",
|
||||
"zutil.c",
|
||||
],
|
||||
hdrs = [
|
||||
"crc32.h",
|
||||
"deflate.h",
|
||||
"gzguts.h",
|
||||
"inffast.h",
|
||||
"inffixed.h",
|
||||
"inflate.h",
|
||||
"inftrees.h",
|
||||
"trees.h",
|
||||
"zconf.h",
|
||||
"zlib.h",
|
||||
"zutil.h",
|
||||
],
|
||||
includes = [
|
||||
".",
|
||||
],
|
||||
linkstatic = 1,
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
py_library(
|
||||
name = "zope_interface",
|
||||
srcs = glob([
|
||||
"src/zope/interface/*.py",
|
||||
"src/zope/interface/common/*.py",
|
||||
]),
|
||||
imports = [
|
||||
"src",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
|
@ -16,10 +16,9 @@ if [[ -d $DEST_DIR/dist ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
git clone --branch $REVISION git@github.com:mongodb-forks/grpc.git $DEST_DIR/dist
|
||||
git clone --branch $REVISION https://github.com/mongodb-forks/grpc.git $DEST_DIR/dist
|
||||
pushd $DEST_DIR/dist
|
||||
find . -mindepth 1 -maxdepth 1 -name ".*" -exec rm -rf {} \;
|
||||
rm -rf bazel
|
||||
rm -rf cmake
|
||||
rm -rf doc
|
||||
rm -rf summerofcode
|
||||
|
|
@ -40,7 +39,6 @@ rm -rf src/php
|
|||
rm -rf src/python
|
||||
rm -rf src/ruby
|
||||
|
||||
find . -type f -name "*.BUILD" -exec rm -rf {} \;
|
||||
find . -type f -name "*.podspec" -exec rm -rf {} \;
|
||||
find . -type f -name "*.gemspec" -exec rm -rf {} \;
|
||||
popd
|
||||
|
|
|
|||
|
|
@ -0,0 +1,582 @@
|
|||
load("//bazel:mongo_src_rules.bzl", "mongo_cc_binary", "mongo_cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files(glob(["*"]))
|
||||
|
||||
GRPC_TARGET_COMPATIBLE_WITH = select({
|
||||
"//bazel/config:build_grpc_enabled": [],
|
||||
"//conditions:default": ["@platforms//:incompatible"],
|
||||
})
|
||||
|
||||
PROTOBUF_COPTS = [
|
||||
"-DHAVE_CONFIG_H",
|
||||
"-DHAVE_ZLIB=1",
|
||||
"-DPIC=1",
|
||||
] + select({
|
||||
"//bazel/config:gcc_or_clang": [
|
||||
"-DHAVE_PTHREAD=1",
|
||||
"-Wno-sign-compare",
|
||||
"-Wno-overloaded-virtual",
|
||||
"-Wno-implicit-fallthrough",
|
||||
],
|
||||
"//bazel/config:compiler_type_msvc": [
|
||||
"/wd4018", # signed/unsigned mismatch
|
||||
"/wd4065", # switch statement contains 'default' but no 'case' labels
|
||||
"/wd4146", # unary minus operator applied to unsigned type, result still unsigned
|
||||
"-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING",
|
||||
],
|
||||
}) + select({
|
||||
"//bazel/config:compiler_type_gcc": [
|
||||
"-Wno-stringop-overflow",
|
||||
"-Wno-error=deprecated",
|
||||
"-Wno-error=attributes",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
PROTOBUF_HEADERS = [
|
||||
"dist/src/google/protobuf/arena.h",
|
||||
"dist/src/google/protobuf/descriptor.h",
|
||||
"dist/src/google/protobuf/message_lite.h",
|
||||
"dist/src/google/protobuf/struct.pb.h",
|
||||
"dist/src/google/protobuf/arena_test_util.h",
|
||||
"dist/src/google/protobuf/arenastring.h",
|
||||
"dist/src/google/protobuf/api.pb.h",
|
||||
"dist/src/google/protobuf/map_test_util_impl.h",
|
||||
"dist/src/google/protobuf/metadata.h",
|
||||
"dist/src/google/protobuf/parse_context.h",
|
||||
"dist/src/google/protobuf/reflection.h",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/accessor_generator.h",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/accessors.h",
|
||||
"dist/src/google/protobuf/compiler/rust/context.h",
|
||||
"dist/src/google/protobuf/compiler/rust/generator.h",
|
||||
"dist/src/google/protobuf/compiler/rust/message.h",
|
||||
"dist/src/google/protobuf/compiler/rust/naming.h",
|
||||
"dist/src/google/protobuf/compiler/rust/oneof.h",
|
||||
"dist/src/google/protobuf/compiler/rust/relative_path.h",
|
||||
"dist/src/google/protobuf/compiler/versions_suffix.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/cpp_generator.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/enum.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/extension.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/field.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/generators.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/file.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/generator.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/helpers.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/message.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/message_layout_helper.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/names.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/options.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/padding_optimizer.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/parse_function_generator.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/service.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/tracker.h",
|
||||
"dist/src/google/protobuf/compiler/cpp/unittest.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_doc_comment.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_enum.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_enum_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_field_base.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_generator.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_helpers.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_map_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_message.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_message_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_options.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_primitive_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_reflection_class.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h",
|
||||
"dist/src/google/protobuf/compiler/csharp/names.h",
|
||||
"dist/src/google/protobuf/compiler/java/extension.h",
|
||||
"dist/src/google/protobuf/compiler/java/extension_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/field.h",
|
||||
"dist/src/google/protobuf/compiler/java/generator.h",
|
||||
"dist/src/google/protobuf/compiler/java/generator_factory.h",
|
||||
"dist/src/google/protobuf/compiler/java/java_generator.h",
|
||||
"dist/src/google/protobuf/compiler/java/kotlin_generator.h",
|
||||
"dist/src/google/protobuf/compiler/java/map_field.h",
|
||||
"dist/src/google/protobuf/compiler/java/message.h",
|
||||
"dist/src/google/protobuf/compiler/java/message_builder.h",
|
||||
"dist/src/google/protobuf/compiler/java/message_field_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/message_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/message_serialization.h",
|
||||
"dist/src/google/protobuf/compiler/java/name_resolver.h",
|
||||
"dist/src/google/protobuf/compiler/java/names.h",
|
||||
"dist/src/google/protobuf/compiler/java/service.h",
|
||||
"dist/src/google/protobuf/compiler/java/string_field_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/context.h",
|
||||
"dist/src/google/protobuf/compiler/java/doc_comment.h",
|
||||
"dist/src/google/protobuf/compiler/java/enum.h",
|
||||
"dist/src/google/protobuf/compiler/java/enum_field.h",
|
||||
"dist/src/google/protobuf/compiler/java/enum_field_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/enum_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/file.h",
|
||||
"dist/src/google/protobuf/compiler/java/helpers.h",
|
||||
"dist/src/google/protobuf/compiler/java/java_features.pb.h",
|
||||
"dist/src/google/protobuf/compiler/java/map_field_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/message_builder_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/message_field.h",
|
||||
"dist/src/google/protobuf/compiler/java/options.h",
|
||||
"dist/src/google/protobuf/compiler/java/primitive_field.h",
|
||||
"dist/src/google/protobuf/compiler/java/primitive_field_lite.h",
|
||||
"dist/src/google/protobuf/compiler/java/shared_code_generator.h",
|
||||
"dist/src/google/protobuf/compiler/java/string_field.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/enum.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/enum_field.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/extension.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/field.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/file.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/generator.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/helpers.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/import_writer.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/line_consumer.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/map_field.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/message.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/message_field.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/names.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/nsobject_methods.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/oneof.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/options.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/primitive_field.h",
|
||||
"dist/src/google/protobuf/compiler/objectivec/text_format_decode_data.h",
|
||||
"dist/src/google/protobuf/compiler/php/names.h",
|
||||
"dist/src/google/protobuf/compiler/php/php_generator.h",
|
||||
"dist/src/google/protobuf/compiler/python/generator.h",
|
||||
"dist/src/google/protobuf/compiler/python/helpers.h",
|
||||
"dist/src/google/protobuf/compiler/python/pyi_generator.h",
|
||||
"dist/src/google/protobuf/compiler/python/python_generator.h",
|
||||
"dist/src/google/protobuf/compiler/ruby/ruby_generator.h",
|
||||
"dist/src/google/protobuf/compiler/package_info.h",
|
||||
"dist/src/google/protobuf/compiler/scc.h",
|
||||
"dist/src/google/protobuf/compiler/zip_writer.h",
|
||||
"dist/src/google/protobuf/compiler/annotation_test_util.h",
|
||||
"dist/src/google/protobuf/compiler/code_generator.h",
|
||||
"dist/src/google/protobuf/compiler/command_line_interface.h",
|
||||
"dist/src/google/protobuf/compiler/importer.h",
|
||||
"dist/src/google/protobuf/compiler/mock_code_generator.h",
|
||||
"dist/src/google/protobuf/compiler/parser.h",
|
||||
"dist/src/google/protobuf/compiler/plugin.h",
|
||||
"dist/src/google/protobuf/compiler/plugin.pb.h",
|
||||
"dist/src/google/protobuf/compiler/subprocess.h",
|
||||
"dist/src/google/protobuf/compiler/allowlists/allowlist.h",
|
||||
"dist/src/google/protobuf/compiler/allowlists/allowlists.h",
|
||||
"dist/src/google/protobuf/compiler/command_line_interface_tester.h",
|
||||
"dist/src/google/protobuf/compiler/retention.h",
|
||||
"dist/src/google/protobuf/compiler/versions.h",
|
||||
"dist/src/google/protobuf/descriptor.pb.h",
|
||||
"dist/src/google/protobuf/descriptor_database.h",
|
||||
"dist/src/google/protobuf/duration.pb.h",
|
||||
"dist/src/google/protobuf/dynamic_message.h",
|
||||
"dist/src/google/protobuf/has_bits.h",
|
||||
"dist/src/google/protobuf/map_field.h",
|
||||
"dist/src/google/protobuf/explicitly_constructed.h",
|
||||
"dist/src/google/protobuf/extension_set.h",
|
||||
"dist/src/google/protobuf/extension_set_inl.h",
|
||||
"dist/src/google/protobuf/field_access_listener.h",
|
||||
"dist/src/google/protobuf/field_mask.pb.h",
|
||||
"dist/src/google/protobuf/generated_enum_reflection.h",
|
||||
"dist/src/google/protobuf/generated_enum_util.h",
|
||||
"dist/src/google/protobuf/generated_message_bases.h",
|
||||
"dist/src/google/protobuf/generated_message_reflection.h",
|
||||
"dist/src/google/protobuf/map_field_inl.h",
|
||||
"dist/src/google/protobuf/empty.pb.h",
|
||||
"dist/src/google/protobuf/generated_message_tctable_decl.h",
|
||||
"dist/src/google/protobuf/generated_message_tctable_impl.h",
|
||||
"dist/src/google/protobuf/any.pb.h",
|
||||
"dist/src/google/protobuf/implicit_weak_message.h",
|
||||
"dist/src/google/protobuf/inlined_string_field.h",
|
||||
"dist/src/google/protobuf/map.h",
|
||||
"dist/src/google/protobuf/map_entry.h",
|
||||
"dist/src/google/protobuf/any.h",
|
||||
"dist/src/google/protobuf/generated_message_util.h",
|
||||
"dist/src/google/protobuf/map_test_util.h",
|
||||
"dist/src/google/protobuf/map_type_handler.h",
|
||||
"dist/src/google/protobuf/metadata_lite.h",
|
||||
"dist/src/google/protobuf/test_util.h",
|
||||
"dist/src/google/protobuf/json/internal/descriptor_traits.h",
|
||||
"dist/src/google/protobuf/json/internal/lexer.h",
|
||||
"dist/src/google/protobuf/json/internal/message_path.h",
|
||||
"dist/src/google/protobuf/json/internal/parser.h",
|
||||
"dist/src/google/protobuf/json/internal/parser_traits.h",
|
||||
"dist/src/google/protobuf/json/internal/unparser.h",
|
||||
"dist/src/google/protobuf/json/internal/unparser_traits.h",
|
||||
"dist/src/google/protobuf/json/internal/untyped_message.h",
|
||||
"dist/src/google/protobuf/json/internal/writer.h",
|
||||
"dist/src/google/protobuf/json/internal/zero_copy_buffered_stream.h",
|
||||
"dist/src/google/protobuf/json/json.h",
|
||||
"dist/src/google/protobuf/package_info.h",
|
||||
"dist/src/google/protobuf/reflection_ops.h",
|
||||
"dist/src/google/protobuf/service.h",
|
||||
"dist/src/google/protobuf/test_util2.h",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream.h",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream_impl.h",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream_impl_lite.h",
|
||||
"dist/src/google/protobuf/io/coded_stream.h",
|
||||
"dist/src/google/protobuf/io/gzip_stream.h",
|
||||
"dist/src/google/protobuf/io/io_win32.h",
|
||||
"dist/src/google/protobuf/io/package_info.h",
|
||||
"dist/src/google/protobuf/io/printer.h",
|
||||
"dist/src/google/protobuf/io/strtod.h",
|
||||
"dist/src/google/protobuf/io/test_zero_copy_stream.h",
|
||||
"dist/src/google/protobuf/io/tokenizer.h",
|
||||
"dist/src/google/protobuf/io/zero_copy_sink.h",
|
||||
"dist/src/google/protobuf/map_field_lite.h",
|
||||
"dist/src/google/protobuf/map_lite_test_util.h",
|
||||
"dist/src/google/protobuf/message.h",
|
||||
"dist/src/google/protobuf/port.h",
|
||||
"dist/src/google/protobuf/type.pb.h",
|
||||
"dist/src/google/protobuf/repeated_ptr_field.h",
|
||||
"dist/src/google/protobuf/source_context.pb.h",
|
||||
"dist/src/google/protobuf/string_member_robber.h",
|
||||
"dist/src/google/protobuf/test_util_lite.h",
|
||||
"dist/src/google/protobuf/text_format.h",
|
||||
"dist/src/google/protobuf/timestamp.pb.h",
|
||||
"dist/src/google/protobuf/arena_align.h",
|
||||
"dist/src/google/protobuf/arena_cleanup.h",
|
||||
"dist/src/google/protobuf/arenaz_sampler.h",
|
||||
"dist/src/google/protobuf/cpp_features.pb.h",
|
||||
"dist/src/google/protobuf/cpp_edition_defaults.h",
|
||||
"dist/src/google/protobuf/feature_resolver.h",
|
||||
"dist/src/google/protobuf/internal_message_util.h",
|
||||
"dist/src/google/protobuf/reflection_tester.h",
|
||||
"dist/src/google/protobuf/unknown_field_set.h",
|
||||
"dist/src/google/protobuf/descriptor_legacy.h",
|
||||
"dist/src/google/protobuf/internal_visibility.h",
|
||||
"dist/src/google/protobuf/stubs/callback.h",
|
||||
"dist/src/google/protobuf/stubs/common.h",
|
||||
"dist/src/google/protobuf/stubs/platform_macros.h",
|
||||
"dist/src/google/protobuf/stubs/port.h",
|
||||
"dist/src/google/protobuf/stubs/status_macros.h",
|
||||
"dist/src/google/protobuf/descriptor_visitor.h",
|
||||
"dist/src/google/protobuf/generated_message_tctable_gen.h",
|
||||
"dist/src/google/protobuf/testing/file.h",
|
||||
"dist/src/google/protobuf/testing/googletest.h",
|
||||
"dist/src/google/protobuf/wire_format.h",
|
||||
"dist/src/google/protobuf/wire_format_lite.h",
|
||||
"dist/src/google/protobuf/wrappers.pb.h",
|
||||
"dist/src/google/protobuf/reflection_internal.h",
|
||||
"dist/src/google/protobuf/arena_allocation_policy.h",
|
||||
"dist/src/google/protobuf/endian.h",
|
||||
"dist/src/google/protobuf/repeated_field.h",
|
||||
"dist/src/google/protobuf/util/delimited_message_util.h",
|
||||
"dist/src/google/protobuf/util/field_comparator.h",
|
||||
"dist/src/google/protobuf/util/field_mask_util.h",
|
||||
"dist/src/google/protobuf/util/json_util.h",
|
||||
"dist/src/google/protobuf/util/message_differencer.h",
|
||||
"dist/src/google/protobuf/util/package_info.h",
|
||||
"dist/src/google/protobuf/util/time_util.h",
|
||||
"dist/src/google/protobuf/util/type_resolver.h",
|
||||
"dist/src/google/protobuf/util/type_resolver_util.h",
|
||||
"dist/src/google/protobuf/internal_visibility_for_testing.h",
|
||||
"dist/src/google/protobuf/raw_ptr.h",
|
||||
"dist/src/google/protobuf/reflection_mode.h",
|
||||
"dist/src/google/protobuf/serial_arena.h",
|
||||
"dist/src/google/protobuf/string_block.h",
|
||||
"dist/src/google/protobuf/test_textproto.h",
|
||||
"dist/src/google/protobuf/thread_safe_arena.h",
|
||||
"dist/src/google/protobuf/varint_shuffle.h",
|
||||
"dist/src/google/protobuf/map_test.inc",
|
||||
"dist/src/google/protobuf/message_unittest.inc",
|
||||
"dist/src/google/protobuf/compiler/cpp/unittest.inc",
|
||||
"dist/src/google/protobuf/port_def.inc",
|
||||
"dist/src/google/protobuf/map_test_util.inc",
|
||||
"dist/src/google/protobuf/port_undef.inc",
|
||||
"dist/src/google/protobuf/test_util.inc",
|
||||
"dist/src/google/protobuf/proto3_lite_unittest.inc",
|
||||
"dist/src/google/protobuf/wire_format_unittest.inc",
|
||||
]
|
||||
|
||||
# TODO(aaronmondal): We might need to port this before merging.
|
||||
# if protobuf_env.ToolchainIs('gcc', 'clang'):
|
||||
# protobuf_env.Append(
|
||||
# if debugBuild:
|
||||
# protobuf_env.Append(CCFLAGS=['-Wno-error'])
|
||||
#
|
||||
|
||||
# TODO(aaronmondal): Seems to be unused/not required. Double-check before merge.
|
||||
# # Passing this up to the main env
|
||||
# env['PROTOC_DESCRIPTOR_PROTO'] = protobuf_env.File(
|
||||
# "dist/src/google/protobuf/descriptor.proto").abspath
|
||||
|
||||
mongo_cc_library(
|
||||
name = "utf8_validity",
|
||||
srcs = [
|
||||
"dist/third_party/utf8_range/utf8_validity.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"dist/third_party/utf8_range/utf8_validity.h",
|
||||
],
|
||||
includes = ["dist/third_party/utf8_range"],
|
||||
target_compatible_with = GRPC_TARGET_COMPATIBLE_WITH,
|
||||
deps = [
|
||||
"//src/third_party/abseil-cpp:absl_base",
|
||||
"//src/third_party/abseil-cpp:absl_debugging_internal",
|
||||
"//src/third_party/abseil-cpp:absl_die_if_null",
|
||||
"//src/third_party/abseil-cpp:absl_flags",
|
||||
"//src/third_party/abseil-cpp:absl_hash",
|
||||
"//src/third_party/abseil-cpp:absl_log_initialize",
|
||||
"//src/third_party/abseil-cpp:absl_log_internal_check_op",
|
||||
"//src/third_party/abseil-cpp:absl_log_internal_message",
|
||||
"//src/third_party/abseil-cpp:absl_log_severity",
|
||||
"//src/third_party/abseil-cpp:absl_status",
|
||||
"//src/third_party/abseil-cpp:absl_statusor",
|
||||
"//src/third_party/abseil-cpp:absl_str_format_internal",
|
||||
"//src/third_party/abseil-cpp:absl_strings",
|
||||
"//src/third_party/abseil-cpp:absl_synchronization",
|
||||
"//src/third_party/abseil-cpp:absl_time",
|
||||
],
|
||||
)
|
||||
|
||||
mongo_cc_library(
|
||||
name = "protobuf",
|
||||
srcs = [
|
||||
"dist/src/google/protobuf/any.cc",
|
||||
"dist/src/google/protobuf/any.pb.cc",
|
||||
"dist/src/google/protobuf/any_lite.cc",
|
||||
"dist/src/google/protobuf/api.pb.cc",
|
||||
"dist/src/google/protobuf/arena.cc",
|
||||
"dist/src/google/protobuf/arena_align.cc",
|
||||
"dist/src/google/protobuf/arenastring.cc",
|
||||
"dist/src/google/protobuf/arenaz_sampler.cc",
|
||||
"dist/src/google/protobuf/compiler/importer.cc",
|
||||
"dist/src/google/protobuf/compiler/parser.cc",
|
||||
"dist/src/google/protobuf/cpp_features.pb.cc",
|
||||
"dist/src/google/protobuf/descriptor.cc",
|
||||
"dist/src/google/protobuf/descriptor.pb.cc",
|
||||
"dist/src/google/protobuf/descriptor_database.cc",
|
||||
"dist/src/google/protobuf/duration.pb.cc",
|
||||
"dist/src/google/protobuf/dynamic_message.cc",
|
||||
"dist/src/google/protobuf/empty.pb.cc",
|
||||
"dist/src/google/protobuf/extension_set.cc",
|
||||
"dist/src/google/protobuf/extension_set_heavy.cc",
|
||||
"dist/src/google/protobuf/feature_resolver.cc",
|
||||
"dist/src/google/protobuf/field_mask.pb.cc",
|
||||
"dist/src/google/protobuf/generated_enum_util.cc",
|
||||
"dist/src/google/protobuf/generated_message_bases.cc",
|
||||
"dist/src/google/protobuf/generated_message_reflection.cc",
|
||||
"dist/src/google/protobuf/generated_message_tctable_full.cc",
|
||||
"dist/src/google/protobuf/generated_message_tctable_gen.cc",
|
||||
"dist/src/google/protobuf/generated_message_tctable_lite.cc",
|
||||
"dist/src/google/protobuf/generated_message_util.cc",
|
||||
"dist/src/google/protobuf/implicit_weak_message.cc",
|
||||
"dist/src/google/protobuf/inlined_string_field.cc",
|
||||
"dist/src/google/protobuf/internal_message_util.cc",
|
||||
"dist/src/google/protobuf/io/coded_stream.cc",
|
||||
"dist/src/google/protobuf/io/gzip_stream.cc",
|
||||
"dist/src/google/protobuf/io/io_win32.cc",
|
||||
"dist/src/google/protobuf/io/printer.cc",
|
||||
"dist/src/google/protobuf/io/strtod.cc",
|
||||
"dist/src/google/protobuf/io/tokenizer.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_sink.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream_impl.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
|
||||
"dist/src/google/protobuf/json/internal/lexer.cc",
|
||||
"dist/src/google/protobuf/json/internal/message_path.cc",
|
||||
"dist/src/google/protobuf/json/internal/parser.cc",
|
||||
"dist/src/google/protobuf/json/internal/unparser.cc",
|
||||
"dist/src/google/protobuf/json/internal/untyped_message.cc",
|
||||
"dist/src/google/protobuf/json/internal/writer.cc",
|
||||
"dist/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc",
|
||||
"dist/src/google/protobuf/json/json.cc",
|
||||
"dist/src/google/protobuf/map.cc",
|
||||
"dist/src/google/protobuf/map_field.cc",
|
||||
"dist/src/google/protobuf/message.cc",
|
||||
"dist/src/google/protobuf/message_lite.cc",
|
||||
"dist/src/google/protobuf/parse_context.cc",
|
||||
"dist/src/google/protobuf/port.cc",
|
||||
"dist/src/google/protobuf/raw_ptr.cc",
|
||||
"dist/src/google/protobuf/reflection_mode.cc",
|
||||
"dist/src/google/protobuf/reflection_ops.cc",
|
||||
"dist/src/google/protobuf/repeated_field.cc",
|
||||
"dist/src/google/protobuf/repeated_ptr_field.cc",
|
||||
"dist/src/google/protobuf/service.cc",
|
||||
"dist/src/google/protobuf/source_context.pb.cc",
|
||||
"dist/src/google/protobuf/struct.pb.cc",
|
||||
"dist/src/google/protobuf/stubs/common.cc",
|
||||
"dist/src/google/protobuf/text_format.cc",
|
||||
"dist/src/google/protobuf/timestamp.pb.cc",
|
||||
"dist/src/google/protobuf/type.pb.cc",
|
||||
"dist/src/google/protobuf/unknown_field_set.cc",
|
||||
"dist/src/google/protobuf/util/delimited_message_util.cc",
|
||||
"dist/src/google/protobuf/util/field_comparator.cc",
|
||||
"dist/src/google/protobuf/util/field_mask_util.cc",
|
||||
"dist/src/google/protobuf/util/message_differencer.cc",
|
||||
"dist/src/google/protobuf/util/time_util.cc",
|
||||
"dist/src/google/protobuf/util/type_resolver_util.cc",
|
||||
"dist/src/google/protobuf/wire_format.cc",
|
||||
"dist/src/google/protobuf/wire_format_lite.cc",
|
||||
"dist/src/google/protobuf/wrappers.pb.cc",
|
||||
],
|
||||
hdrs = PROTOBUF_HEADERS,
|
||||
copts = PROTOBUF_COPTS,
|
||||
includes = [
|
||||
"dist/src",
|
||||
],
|
||||
target_compatible_with = GRPC_TARGET_COMPATIBLE_WITH,
|
||||
deps = [
|
||||
":utf8_validity",
|
||||
"//src/third_party/abseil-cpp:absl_base",
|
||||
"//src/third_party/abseil-cpp:absl_debugging_internal",
|
||||
"//src/third_party/abseil-cpp:absl_die_if_null",
|
||||
"//src/third_party/abseil-cpp:absl_flags",
|
||||
"//src/third_party/abseil-cpp:absl_hash",
|
||||
"//src/third_party/abseil-cpp:absl_log_initialize",
|
||||
"//src/third_party/abseil-cpp:absl_log_internal_check_op",
|
||||
"//src/third_party/abseil-cpp:absl_log_internal_message",
|
||||
"//src/third_party/abseil-cpp:absl_log_severity",
|
||||
"//src/third_party/abseil-cpp:absl_status",
|
||||
"//src/third_party/abseil-cpp:absl_statusor",
|
||||
"//src/third_party/abseil-cpp:absl_str_format_internal",
|
||||
"//src/third_party/abseil-cpp:absl_strings",
|
||||
"//src/third_party/abseil-cpp:absl_synchronization",
|
||||
"//src/third_party/abseil-cpp:absl_time",
|
||||
"//src/third_party/zlib",
|
||||
],
|
||||
)
|
||||
|
||||
mongo_cc_library(
|
||||
name = "protoc",
|
||||
srcs = [
|
||||
"dist/src/google/protobuf/compiler/allowlists/editions.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/empty_package.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/open_enum.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/unused_imports.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/weak_imports.cc",
|
||||
"dist/src/google/protobuf/compiler/code_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/command_line_interface.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/enum.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/extension.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/cord_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/string_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/file.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/message.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/padding_optimizer.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/parse_function_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/service.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/tracker.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_enum.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_message.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/names.cc",
|
||||
"dist/src/google/protobuf/compiler/java/context.cc",
|
||||
"dist/src/google/protobuf/compiler/java/doc_comment.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/extension.cc",
|
||||
"dist/src/google/protobuf/compiler/java/extension_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/file.cc",
|
||||
"dist/src/google/protobuf/compiler/java/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/java/generator_factory.cc",
|
||||
"dist/src/google/protobuf/compiler/java/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/java/java_features.pb.cc",
|
||||
"dist/src/google/protobuf/compiler/java/kotlin_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/java/map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/map_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_builder.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_builder_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_serialization.cc",
|
||||
"dist/src/google/protobuf/compiler/java/name_resolver.cc",
|
||||
"dist/src/google/protobuf/compiler/java/names.cc",
|
||||
"dist/src/google/protobuf/compiler/java/primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/primitive_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/service.cc",
|
||||
"dist/src/google/protobuf/compiler/java/shared_code_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/java/string_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/string_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/enum.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/extension.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/file.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/import_writer.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/line_consumer.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/message.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/names.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/oneof.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc",
|
||||
"dist/src/google/protobuf/compiler/php/names.cc",
|
||||
"dist/src/google/protobuf/compiler/php/php_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/plugin.cc",
|
||||
"dist/src/google/protobuf/compiler/plugin.pb.cc",
|
||||
"dist/src/google/protobuf/compiler/python/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/python/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/python/pyi_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/retention.cc",
|
||||
"dist/src/google/protobuf/compiler/ruby/ruby_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/accessors.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/singular_message.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/singular_scalar.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/singular_string.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/unsupported_field.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/context.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/message.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/naming.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/oneof.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/relative_path.cc",
|
||||
"dist/src/google/protobuf/compiler/subprocess.cc",
|
||||
"dist/src/google/protobuf/compiler/zip_writer.cc",
|
||||
],
|
||||
hdrs = PROTOBUF_HEADERS,
|
||||
copts = PROTOBUF_COPTS,
|
||||
includes = [
|
||||
"dist/src",
|
||||
],
|
||||
target_compatible_with = GRPC_TARGET_COMPATIBLE_WITH,
|
||||
deps = [
|
||||
"protobuf",
|
||||
"//src/third_party/abseil-cpp:absl_base",
|
||||
"//src/third_party/abseil-cpp:absl_strings",
|
||||
],
|
||||
)
|
||||
|
||||
mongo_cc_binary(
|
||||
name = "protobuf_compiler",
|
||||
srcs = ["dist/src/google/protobuf/compiler/main.cc"] + PROTOBUF_HEADERS,
|
||||
copts = PROTOBUF_COPTS,
|
||||
includes = [
|
||||
"dist/src",
|
||||
],
|
||||
target_compatible_with = GRPC_TARGET_COMPATIBLE_WITH,
|
||||
deps = [
|
||||
"protobuf",
|
||||
"protoc",
|
||||
],
|
||||
)
|
||||
|
|
@ -52,260 +52,12 @@ protobuf_env.Append(CPPPATH=[
|
|||
protobuf_root.Dir("dist/src"),
|
||||
], )
|
||||
|
||||
protobuf_env.BazelProgram(
|
||||
target="protobuf_compiler",
|
||||
source=[],
|
||||
LIBDEPS=[],
|
||||
)
|
||||
|
||||
# Passing this up to the main env
|
||||
env['PROTOC_DESCRIPTOR_PROTO'] = protobuf_env.File(
|
||||
"dist/src/google/protobuf/descriptor.proto").abspath
|
||||
|
||||
utf8_validity_env = protobuf_env.Clone()
|
||||
utf8_validity_env.Append(CPPPATH=[
|
||||
protobuf_root.Dir('dist/third_party/utf8_range'),
|
||||
], )
|
||||
|
||||
utf8_validity_env.Library(
|
||||
target='utf8_validity',
|
||||
source=[
|
||||
"dist/third_party/utf8_range/utf8_validity.cc",
|
||||
],
|
||||
)
|
||||
|
||||
protobuf_env.Append(CPPPATH=[
|
||||
protobuf_root.Dir('dist/third_party/utf8_range'),
|
||||
])
|
||||
|
||||
protobuf_env.Library(
|
||||
target='protobuf',
|
||||
source=[
|
||||
"dist/src/google/protobuf/any.cc",
|
||||
"dist/src/google/protobuf/any.pb.cc",
|
||||
"dist/src/google/protobuf/any_lite.cc",
|
||||
"dist/src/google/protobuf/api.pb.cc",
|
||||
"dist/src/google/protobuf/arena.cc",
|
||||
"dist/src/google/protobuf/arena_align.cc",
|
||||
"dist/src/google/protobuf/arenastring.cc",
|
||||
"dist/src/google/protobuf/arenaz_sampler.cc",
|
||||
"dist/src/google/protobuf/compiler/importer.cc",
|
||||
"dist/src/google/protobuf/compiler/parser.cc",
|
||||
"dist/src/google/protobuf/cpp_features.pb.cc",
|
||||
"dist/src/google/protobuf/descriptor.cc",
|
||||
"dist/src/google/protobuf/descriptor.pb.cc",
|
||||
"dist/src/google/protobuf/descriptor_database.cc",
|
||||
"dist/src/google/protobuf/duration.pb.cc",
|
||||
"dist/src/google/protobuf/dynamic_message.cc",
|
||||
"dist/src/google/protobuf/empty.pb.cc",
|
||||
"dist/src/google/protobuf/extension_set.cc",
|
||||
"dist/src/google/protobuf/extension_set_heavy.cc",
|
||||
"dist/src/google/protobuf/feature_resolver.cc",
|
||||
"dist/src/google/protobuf/field_mask.pb.cc",
|
||||
"dist/src/google/protobuf/generated_enum_util.cc",
|
||||
"dist/src/google/protobuf/generated_message_bases.cc",
|
||||
"dist/src/google/protobuf/generated_message_reflection.cc",
|
||||
"dist/src/google/protobuf/generated_message_tctable_full.cc",
|
||||
"dist/src/google/protobuf/generated_message_tctable_gen.cc",
|
||||
"dist/src/google/protobuf/generated_message_tctable_lite.cc",
|
||||
"dist/src/google/protobuf/generated_message_util.cc",
|
||||
"dist/src/google/protobuf/implicit_weak_message.cc",
|
||||
"dist/src/google/protobuf/inlined_string_field.cc",
|
||||
"dist/src/google/protobuf/internal_message_util.cc",
|
||||
"dist/src/google/protobuf/io/coded_stream.cc",
|
||||
"dist/src/google/protobuf/io/gzip_stream.cc",
|
||||
"dist/src/google/protobuf/io/io_win32.cc",
|
||||
"dist/src/google/protobuf/io/printer.cc",
|
||||
"dist/src/google/protobuf/io/strtod.cc",
|
||||
"dist/src/google/protobuf/io/tokenizer.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_sink.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream_impl.cc",
|
||||
"dist/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
|
||||
"dist/src/google/protobuf/json/internal/lexer.cc",
|
||||
"dist/src/google/protobuf/json/internal/message_path.cc",
|
||||
"dist/src/google/protobuf/json/internal/parser.cc",
|
||||
"dist/src/google/protobuf/json/internal/unparser.cc",
|
||||
"dist/src/google/protobuf/json/internal/untyped_message.cc",
|
||||
"dist/src/google/protobuf/json/internal/writer.cc",
|
||||
"dist/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc",
|
||||
"dist/src/google/protobuf/json/json.cc",
|
||||
"dist/src/google/protobuf/map.cc",
|
||||
"dist/src/google/protobuf/map_field.cc",
|
||||
"dist/src/google/protobuf/message.cc",
|
||||
"dist/src/google/protobuf/message_lite.cc",
|
||||
"dist/src/google/protobuf/parse_context.cc",
|
||||
"dist/src/google/protobuf/port.cc",
|
||||
"dist/src/google/protobuf/raw_ptr.cc",
|
||||
"dist/src/google/protobuf/reflection_mode.cc",
|
||||
"dist/src/google/protobuf/reflection_ops.cc",
|
||||
"dist/src/google/protobuf/repeated_field.cc",
|
||||
"dist/src/google/protobuf/repeated_ptr_field.cc",
|
||||
"dist/src/google/protobuf/service.cc",
|
||||
"dist/src/google/protobuf/source_context.pb.cc",
|
||||
"dist/src/google/protobuf/struct.pb.cc",
|
||||
"dist/src/google/protobuf/stubs/common.cc",
|
||||
"dist/src/google/protobuf/text_format.cc",
|
||||
"dist/src/google/protobuf/timestamp.pb.cc",
|
||||
"dist/src/google/protobuf/type.pb.cc",
|
||||
"dist/src/google/protobuf/unknown_field_set.cc",
|
||||
"dist/src/google/protobuf/util/delimited_message_util.cc",
|
||||
"dist/src/google/protobuf/util/field_comparator.cc",
|
||||
"dist/src/google/protobuf/util/field_mask_util.cc",
|
||||
"dist/src/google/protobuf/util/message_differencer.cc",
|
||||
"dist/src/google/protobuf/util/time_util.cc",
|
||||
"dist/src/google/protobuf/util/type_resolver_util.cc",
|
||||
"dist/src/google/protobuf/wire_format.cc",
|
||||
"dist/src/google/protobuf/wire_format_lite.cc",
|
||||
"dist/src/google/protobuf/wrappers.pb.cc",
|
||||
],
|
||||
LIBDEPS=[
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_base',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_debugging_internal',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_die_if_null',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_flags',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_hash',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_log_initialize',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_log_internal_check_op',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_log_internal_message',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_log_severity',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_status',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_statusor',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_str_format_internal',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_strings',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_synchronization',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_time',
|
||||
'$BUILD_DIR/third_party/zlib/zlib',
|
||||
'utf8_validity',
|
||||
],
|
||||
)
|
||||
|
||||
protobuf_env.Library(
|
||||
target='protoc',
|
||||
source=[
|
||||
"dist/src/google/protobuf/compiler/allowlists/editions.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/empty_package.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/open_enum.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/unused_imports.cc",
|
||||
"dist/src/google/protobuf/compiler/allowlists/weak_imports.cc",
|
||||
"dist/src/google/protobuf/compiler/code_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/command_line_interface.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/enum.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/extension.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/cord_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/field_generators/string_field.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/file.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/message.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/padding_optimizer.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/parse_function_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/service.cc",
|
||||
"dist/src/google/protobuf/compiler/cpp/tracker.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_enum.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_message.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
|
||||
"dist/src/google/protobuf/compiler/csharp/names.cc",
|
||||
"dist/src/google/protobuf/compiler/java/context.cc",
|
||||
"dist/src/google/protobuf/compiler/java/doc_comment.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/enum_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/extension.cc",
|
||||
"dist/src/google/protobuf/compiler/java/extension_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/file.cc",
|
||||
"dist/src/google/protobuf/compiler/java/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/java/generator_factory.cc",
|
||||
"dist/src/google/protobuf/compiler/java/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/java/java_features.pb.cc",
|
||||
"dist/src/google/protobuf/compiler/java/kotlin_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/java/map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/map_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_builder.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_builder_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/message_serialization.cc",
|
||||
"dist/src/google/protobuf/compiler/java/name_resolver.cc",
|
||||
"dist/src/google/protobuf/compiler/java/names.cc",
|
||||
"dist/src/google/protobuf/compiler/java/primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/primitive_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/java/service.cc",
|
||||
"dist/src/google/protobuf/compiler/java/shared_code_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/java/string_field.cc",
|
||||
"dist/src/google/protobuf/compiler/java/string_field_lite.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/enum.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/enum_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/extension.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/file.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/import_writer.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/line_consumer.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/map_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/message.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/message_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/names.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/oneof.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/primitive_field.cc",
|
||||
"dist/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc",
|
||||
"dist/src/google/protobuf/compiler/php/names.cc",
|
||||
"dist/src/google/protobuf/compiler/php/php_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/plugin.cc",
|
||||
"dist/src/google/protobuf/compiler/plugin.pb.cc",
|
||||
"dist/src/google/protobuf/compiler/python/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/python/helpers.cc",
|
||||
"dist/src/google/protobuf/compiler/python/pyi_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/retention.cc",
|
||||
"dist/src/google/protobuf/compiler/ruby/ruby_generator.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/accessors.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/singular_message.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/singular_scalar.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/singular_string.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/accessors/unsupported_field.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/context.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/generator.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/message.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/naming.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/oneof.cc",
|
||||
"dist/src/google/protobuf/compiler/rust/relative_path.cc",
|
||||
"dist/src/google/protobuf/compiler/subprocess.cc",
|
||||
"dist/src/google/protobuf/compiler/zip_writer.cc",
|
||||
],
|
||||
LIBDEPS=[
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_base',
|
||||
'$BUILD_DIR/third_party/abseil-cpp/absl_strings',
|
||||
'protobuf',
|
||||
],
|
||||
)
|
||||
|
||||
protobuf_compiler = protobuf_env.Program(
|
||||
target='protobuf_compiler',
|
||||
source=['dist/src/google/protobuf/compiler/main.cc'],
|
||||
LIBDEPS=[
|
||||
'protobuf',
|
||||
'protoc',
|
||||
],
|
||||
AIB_COMPONENT='protobuf',
|
||||
)
|
||||
|
||||
installed = env.GetAutoInstalledFiles(protobuf_compiler[0])
|
||||
if installed:
|
||||
setattr(installed[0].attributes, 'AIB_NO_ARCHIVE', True)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ if [[ -d $DEST_DIR/dist ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
git clone --branch $REVISION git@github.com:mongodb-forks/protobuf.git $DEST_DIR/dist
|
||||
git clone --branch $REVISION https://github.com/mongodb-forks/protobuf.git $DEST_DIR/dist
|
||||
pushd $DEST_DIR/dist
|
||||
rm -rf benchmarks
|
||||
rm -rf cmake
|
||||
|
|
|
|||
Loading…
Reference in New Issue