From 94729654c9232a098180a73817c3151e42d831c9 Mon Sep 17 00:00:00 2001 From: raihan <54474184+ryihan@users.noreply.github.com> Date: Tue, 26 Oct 2021 03:51:02 +0600 Subject: [PATCH] Update --- bazel/cc_grpc_library.bzl | 118 ++ bazel/copts.bzl | 56 + bazel/custom_exec_properties.bzl | 17 + bazel/cython_library.bzl | 90 + bazel/generate_cc.bzl | 201 ++ bazel/generate_objc.bzl | 237 +++ bazel/gevent_test.bzl | 71 + bazel/grpc_build_system.bzl | 405 ++++ bazel/grpc_deps.bzl | 533 +++++ bazel/grpc_extra_deps.bzl | 62 + bazel/grpc_python_deps.bzl | 74 + bazel/grpc_util.bzl | 59 + bazel/internal_python_rules.bzl | 35 + bazel/objc_grpc_library.bzl | 81 + bazel/protobuf.bzl | 279 +++ bazel/python_rules.bzl | 329 ++++ grpc.bzl | 113 ++ .../grpc_objc_internal_library.bzl | 173 ++ test/core/bad_client/generate_tests.bzl | 56 + test/core/bad_ssl/generate_tests.bzl | 57 + test/core/end2end/generate_tests.bzl | 561 ++++++ test/core/util/grpc_fuzzer.bzl | 75 + .../microbenchmarks/grpc_benchmark_config.bzl | 18 + .../generate_resolver_component_tests.bzl | 92 + test/cpp/qps/json_run_localhost_scenarios.bzl | 93 + test/cpp/qps/qps_benchmark_script.bzl | 92 + test/cpp/qps/qps_json_driver_scenarios.bzl | 47 + .../address_sorting/address_sorting.bzl | 38 + third_party/py/python_configure.bzl | 398 ++++ .../cc_toolchain_config.bzl | 1718 +++++++++++++++++ third_party/upb/bazel/build_defs.bzl | 169 ++ third_party/upb/bazel/upb_proto_library.bzl | 385 ++++ third_party/upb/bazel/workspace_deps.bzl | 50 + third_party/upb/benchmarks/build_defs.bzl | 87 + third_party/upb/cmake/build_defs.bzl | 68 + .../upb/bindings/lua/lua_proto_library.bzl | 135 ++ .../python/grpcio_tools/grpcio_tools.bzl | 94 + 37 files changed, 7166 insertions(+) create mode 100644 bazel/cc_grpc_library.bzl create mode 100644 bazel/copts.bzl create mode 100644 bazel/custom_exec_properties.bzl create mode 100644 bazel/cython_library.bzl create mode 100644 bazel/generate_cc.bzl create mode 100644 bazel/generate_objc.bzl create mode 100644 bazel/gevent_test.bzl create mode 100644 bazel/grpc_build_system.bzl create mode 100644 bazel/grpc_deps.bzl create mode 100644 bazel/grpc_extra_deps.bzl create mode 100644 bazel/grpc_python_deps.bzl create mode 100644 bazel/grpc_util.bzl create mode 100644 bazel/internal_python_rules.bzl create mode 100644 bazel/objc_grpc_library.bzl create mode 100644 bazel/protobuf.bzl create mode 100644 bazel/python_rules.bzl create mode 100644 grpc.bzl create mode 100644 src/objective-c/grpc_objc_internal_library.bzl create mode 100644 test/core/bad_client/generate_tests.bzl create mode 100644 test/core/bad_ssl/generate_tests.bzl create mode 100644 test/core/end2end/generate_tests.bzl create mode 100644 test/core/util/grpc_fuzzer.bzl create mode 100644 test/cpp/microbenchmarks/grpc_benchmark_config.bzl create mode 100644 test/cpp/naming/generate_resolver_component_tests.bzl create mode 100644 test/cpp/qps/json_run_localhost_scenarios.bzl create mode 100644 test/cpp/qps/qps_benchmark_script.bzl create mode 100644 test/cpp/qps/qps_json_driver_scenarios.bzl create mode 100644 third_party/address_sorting/address_sorting.bzl create mode 100644 third_party/py/python_configure.bzl create mode 100644 third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl create mode 100644 third_party/upb/bazel/build_defs.bzl create mode 100644 third_party/upb/bazel/upb_proto_library.bzl create mode 100644 third_party/upb/bazel/workspace_deps.bzl create mode 100644 third_party/upb/benchmarks/build_defs.bzl create mode 100644 third_party/upb/cmake/build_defs.bzl create mode 100644 third_party/upb/upb/bindings/lua/lua_proto_library.bzl create mode 100644 tools/distrib/python/grpcio_tools/grpcio_tools.bzl diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl new file mode 100644 index 00000000..9c31f0c1 --- /dev/null +++ b/bazel/cc_grpc_library.bzl @@ -0,0 +1,118 @@ +# 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] + 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 + ) diff --git a/bazel/copts.bzl b/bazel/copts.bzl new file mode 100644 index 00000000..64c16cdd --- /dev/null +++ b/bazel/copts.bzl @@ -0,0 +1,56 @@ +# 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 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-comparison", + "-Wvla", + # 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, + "//conditions:default": [], +}) diff --git a/bazel/custom_exec_properties.bzl b/bazel/custom_exec_properties.bzl new file mode 100644 index 00000000..6605f5cc --- /dev/null +++ b/bazel/custom_exec_properties.bzl @@ -0,0 +1,17 @@ +# 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. + +load("@grpc_custom_exec_properties//:constants.bzl", _LARGE_MACHINE = "LARGE_MACHINE") + +LARGE_MACHINE = _LARGE_MACHINE diff --git a/bazel/cython_library.bzl b/bazel/cython_library.bzl new file mode 100644 index 00000000..8e003c22 --- /dev/null +++ b/bazel/cython_library.bzl @@ -0,0 +1,90 @@ +# 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 = [] + 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"], + 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 + ) diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl new file mode 100644 index 00000000..b419e13a --- /dev/null +++ b/bazel/generate_cc.bzl @@ -0,0 +1,201 @@ +# 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.""" + 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 += ["--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 += ["--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_protos is supported", + ) + 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 += ["-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 struct(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_protos", + **kwargs + ) + else: + _generate_cc(**kwargs) diff --git a/bazel/generate_objc.bzl b/bazel/generate_objc.bzl new file mode 100644 index 00000000..f6424b38 --- /dev/null +++ b/bazel/generate_objc.bzl @@ -0,0 +1,237 @@ +# 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("@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 += [_get_output_file_name_from_proto(proto, _PROTO_HEADER_FMT)] + outs += [_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 += [_get_output_file_name_from_proto(proto, _GRPC_PROTO_HEADER_FMT)] + outs += [_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 = [] + if ctx.executable.plugin: + arguments += get_plugin_args( + ctx.executable.plugin, + [], + dir_out, + False, + ) + tools = [ctx.executable.plugin] + arguments += ["--objc_out=" + dir_out] + + arguments += ["--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 += ["--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 += ["-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)) + +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_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)) + +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, +) diff --git a/bazel/gevent_test.bzl b/bazel/gevent_test.bzl new file mode 100644 index 00000000..55444d32 --- /dev/null +++ b/bazel/gevent_test.bzl @@ -0,0 +1,71 @@ +# 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("@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): + 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], + deps = augmented_deps, + srcs = [copied_main_filename], + main = copied_main_filename, + python_version = "PY3", + flaky = True, + **kwargs + ) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl new file mode 100644 index 00000000..ddfb8e36 --- /dev/null +++ b/bazel/grpc_build_system.bzl @@ -0,0 +1,405 @@ +# 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. +# + +load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") +load("//bazel:copts.bzl", "GRPC_DEFAULT_COPTS") +load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") + +# The set of pollers to test against if a test exercises polling +POLLERS = ["epollex", "epoll1", "poll"] + +def if_not_windows(a): + return select({ + "//:windows": [], + "//:windows_msvc": [], + "//conditions:default": a, + }) + +def if_mac(a): + return select({ + "//:mac_x86_64": a, + "//conditions:default": [], + }) + +def _get_external_deps(external_deps): + ret = [] + for dep in external_deps: + if dep == "address_sorting": + ret += ["//third_party/address_sorting"] + elif dep == "xxhash": + ret += ["//third_party/xxhash"] + elif dep == "cares": + ret += select({ + "//:grpc_no_ares": [], + "//conditions:default": ["//external:cares"], + }) + elif dep == "cronet_c_for_grpc": + ret += ["//third_party/objective_c/Cronet:cronet_c_for_grpc"] + elif dep.startswith("absl/"): + ret += ["@com_google_absl//" + dep] + else: + ret += ["//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_gpr_base_legacy": PRIVATE, + "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, + "debug_location": PRIVATE, + "endpoint_tests": PRIVATE, + "grpclb": PRIVATE, + "grpc_opencensus_plugin": PUBLIC, + "grpc_resolver_fake": PRIVATE, + "grpc++_test": PRIVATE, + "public": PUBLIC, + "ref_counted_ptr": PRIVATE, + "trace": PRIVATE, + "tsi_interface": PRIVATE, + "tsi": PRIVATE, + "xds": 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 = [], + use_cfstream = False, + tags = [], + linkstatic = False): + visibility = _update_visibility(visibility) + copts = [] + if use_cfstream: + copts = if_mac(["-DGRPC_CFSTREAM"]) + if language.upper() == "C": + copts = copts + if_not_windows(["-std=c99"]) + linkopts = if_not_windows(["-pthread"]) + if use_cfstream: + linkopts = linkopts + if_mac(["-framework CoreFoundation"]) + + if select_deps: + deps += select(select_deps) + + 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 = [ + "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): + ios_test_adapter = "//third_party/objective_c/google_toolbox_for_mac:GTM_GoogleTestRunner_GTM_USING_XCTEST" + + test_lib_ios = name + "_test_lib_ios" + ios_tags = tags + ["manual", "ios_cc_test"] + 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"), + tags = ios_tags, + alwayslink = 1, + testonly = 1, + ) + ios_test_deps = [ios_test_adapter, ":" + test_lib_ios] + ios_unit_test( + name = name + "_on_ios", + size = kwargs.get("size"), + tags = ios_tags, + minimum_os_version = "9.0", + deps = ios_test_deps, + ) + +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 = []): + copts = copts + if_mac(["-DGRPC_CFSTREAM"]) + if language.upper() == "C": + copts = copts + if_not_windows(["-std=c99"]) + + # NOTE: these attributes won't be used for the poller-specific versions of a test + # automatically, you need to set them explicitly (if applicable) + args = { + "srcs": srcs, + "args": args, + "data": data, + "deps": deps + _get_external_deps(external_deps), + "copts": GRPC_DEFAULT_COPTS + copts, + "linkopts": if_not_windows(["-pthread"]), + "size": size, + "timeout": timeout, + "exec_compatible_with": exec_compatible_with, + "exec_properties": exec_properties, + "shard_count": shard_count, + "flaky": flaky, + } + if uses_polling: + # the vanilla version of the test should run on platforms that only + # support a single poller + native.cc_test( + name = name, + testonly = True, + tags = (tags + [ + "no_linux", # linux supports multiple pollers + ]), + **args + ) + + # on linux we run the same test multiple times, once for each poller + for poller in POLLERS: + native.sh_test( + name = name + "@poller=" + poller, + data = [name] + data, + srcs = [ + "//test/core/util:run_with_poller_sh", + ], + size = size, + timeout = timeout, + args = [ + poller, + "$(location %s)" % name, + ] + args["args"], + tags = (tags + ["no_windows", "no_mac"]), + exec_compatible_with = exec_compatible_with, + exec_properties = exec_properties, + shard_count = shard_count, + flaky = flaky, + ) + else: + # the test behavior doesn't depend on polling, just generate the test + native.cc_test(name = name, tags = tags + ["no_uses_polling"], **args) + ios_cc_test( + name = name, + tags = tags, + **args + ) + +def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = [], features = []): + copts = [] + if language.upper() == "C": + copts = ["-std=c99"] + native.cc_binary( + name = name, + srcs = srcs, + args = args, + data = data, + testonly = testonly, + linkshared = linkshared, + deps = deps + _get_external_deps(external_deps), + copts = GRPC_DEFAULT_COPTS + copts, + linkopts = if_not_windows(["-pthread"]) + linkopts, + tags = tags, + features = features, + ) + +def grpc_generate_one_off_targets(): + # In open-source, grpc_objc* libraries depend directly on //:grpc + native.alias( + name = "grpc_objc", + actual = "//:grpc", + ) + +def grpc_generate_objc_one_off_targets(): + pass + +def grpc_sh_test(name, srcs, args = [], data = []): + native.sh_test( + name = name, + srcs = srcs, + args = args, + data = data, + ) + +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 = []): + 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: + native.package( + default_visibility = visibility, + features = features, + ) + +def grpc_objc_library( + name, + srcs = [], + hdrs = [], + textual_hdrs = [], + data = [], + deps = [], + defines = [], + 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) + textual_hdrs: private headers + data: any other bundle resources + defines: preprocessors + 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, + textual_hdrs = textual_hdrs, + data = data, + deps = deps, + defines = defines, + includes = includes, + visibility = visibility, + ) + +def grpc_upb_proto_library(name, deps): + upb_proto_library(name = name, deps = deps) + +def python_config_settings(): + native.config_setting( + name = "python3", + flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, + ) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl new file mode 100644 index 00000000..17e53a06 --- /dev/null +++ b/bazel/grpc_deps.bzl @@ -0,0 +1,533 @@ +# 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") + +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_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 = "absl", + actual = "@com_google_absl//absl", + ) + + native.bind( + name = "absl-base", + actual = "@com_google_absl//absl/base", + ) + + native.bind( + name = "absl-time", + actual = "@com_google_absl//absl/time:time", + ) + + 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 = "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-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 = "libuv", + actual = "@libuv//:libuv", + ) + + 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 = "bf070ffab0ea1a2d0c3d024d8ab8c813c96a5d07a890a9e7e9a979e9ad427b47", + strip_prefix = "boringssl-95b3ed1b01f2ef1d72fed290ed79fe1b0e7dafc0", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/boringssl/archive/95b3ed1b01f2ef1d72fed290ed79fe1b0e7dafc0.tar.gz", + "https://github.com/google/boringssl/archive/95b3ed1b01f2ef1d72fed290ed79fe1b0e7dafc0.tar.gz", + ], + ) + + if "zlib" not in native.existing_rules(): + http_archive( + name = "zlib", + build_file = "@com_github_grpc_grpc//third_party:zlib.BUILD", + sha256 = "6d4d6640ca3121620995ee255945161821218752b551a1a180f4215f7d124d45", + strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz", + "https://github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz", + ], + ) + + if "com_google_protobuf" not in native.existing_rules(): + http_archive( + name = "com_google_protobuf", + sha256 = "74b5c6f7ca553a8d7c365ff0b5008ef5a44bc1aaeca6f964ad7557c2fa430691", + strip_prefix = "protobuf-0dab03ba7bc438d7ba3eac2b2c1eb39ed520f928", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/0dab03ba7bc438d7ba3eac2b2c1eb39ed520f928.tar.gz", + "https://github.com/protocolbuffers/protobuf/archive/0dab03ba7bc438d7ba3eac2b2c1eb39ed520f928.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 = "443d383db648ebb8e391382c0ab63263b7091d03197f304390baac10f178a468", + strip_prefix = "googletest-c9ccac7cb7345901884aabf5d1a786cfa6e2f397", + urls = [ + # 2019-08-19 + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/googletest/archive/c9ccac7cb7345901884aabf5d1a786cfa6e2f397.tar.gz", + "https://github.com/google/googletest/archive/c9ccac7cb7345901884aabf5d1a786cfa6e2f397.tar.gz", + ], + ) + + if "rules_cc" not in native.existing_rules(): + http_archive( + name = "rules_cc", + sha256 = "35f2fb4ea0b3e61ad64a369de284e4fbbdcdba71836a5555abb5e194cf119509", + strip_prefix = "rules_cc-624b5d59dfb45672d4239422fa1e3de1822ee110", + urls = [ + #2019-08-15 + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_cc/archive/624b5d59dfb45672d4239422fa1e3de1822ee110.tar.gz", + "https://github.com/bazelbuild/rules_cc/archive/624b5d59dfb45672d4239422fa1e3de1822ee110.tar.gz", + ], + ) + + if "com_github_google_benchmark" not in native.existing_rules(): + http_archive( + name = "com_github_google_benchmark", + sha256 = "daa4a97e0547d76de300e325a49177b199f3689ce5a35e25d47696f7cb050f86", + strip_prefix = "benchmark-73d4d5e8d6d449fc8663765a42aa8aeeee844489", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/benchmark/archive/73d4d5e8d6d449fc8663765a42aa8aeeee844489.tar.gz", + "https://github.com/google/benchmark/archive/73d4d5e8d6d449fc8663765a42aa8aeeee844489.tar.gz", + ], + ) + + if "com_googlesource_code_re2" not in native.existing_rules(): + http_archive( + name = "com_googlesource_code_re2", + sha256 = "319a58a58d8af295db97dfeecc4e250179c5966beaa2d842a82f0a013b6a239b", + # Release 2021-09-01 + strip_prefix = "re2-8e08f47b11b413302749c0d8b17a1c94777495d5", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/re2/archive/8e08f47b11b413302749c0d8b17a1c94777495d5.tar.gz", + "https://github.com/google/re2/archive/8e08f47b11b413302749c0d8b17a1c94777495d5.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 = "e8c2751ddc70fed9dc6f999acd92e232d5846f009ee1674f8aee81f19b2b915a", + strip_prefix = "c-ares-e982924acee7f7313b4baa4ee5ec000c5e373c30", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/c-ares/c-ares/archive/e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz", + "https://github.com/c-ares/c-ares/archive/e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz", + ], + ) + + if "com_google_absl" not in native.existing_rules(): + http_archive( + name = "com_google_absl", + sha256 = "1764491a199eb9325b177126547f03d244f86b4ff28f16f206c7b3e7e4f777ec", + strip_prefix = "abseil-cpp-278e0a071885a22dcd2fd1b5576cc44757299343", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/278e0a071885a22dcd2fd1b5576cc44757299343.tar.gz", + "https://github.com/abseil/abseil-cpp/archive/278e0a071885a22dcd2fd1b5576cc44757299343.tar.gz", + ], + ) + + if "bazel_toolchains" not in native.existing_rules(): + # list of releases is at https://releases.bazel.build/bazel-toolchains.html + http_archive( + name = "bazel_toolchains", + sha256 = "179ec02f809e86abf56356d8898c8bd74069f1bd7c56044050c2cd3d79d0e024", + strip_prefix = "bazel-toolchains-4.1.0", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/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.2/bazel-skylib-1.0.2.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + ], + sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", + ) + + 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 = "90d6fafa8b1a2ea613bf662731d3086e1c2ed286f458a95c81744df2dbae41b1", + strip_prefix = "opencensus-cpp-c9a4da319bc669a772928ffc55af4a61be1a1176", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/census-instrumentation/opencensus-cpp/archive/c9a4da319bc669a772928ffc55af4a61be1a1176.tar.gz", + "https://github.com/census-instrumentation/opencensus-cpp/archive/c9a4da319bc669a772928ffc55af4a61be1a1176.tar.gz", + ], + ) + + if "upb" not in native.existing_rules(): + http_archive( + name = "upb", + sha256 = "6a5f67874af66b239b709c572ac1a5a00fdb1b29beaf13c3e6f79b1ba10dc7c4", + strip_prefix = "upb-2de300726a1ba2de9a468468dc5ff9ed17a3215f", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz", + "https://github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz", + ], + ) + + if "envoy_api" not in native.existing_rules(): + http_archive( + name = "envoy_api", + sha256 = "e89d4dddbadf797dd2700ce45ee8abc82557a934a15fcad82673e7d13213b868", + strip_prefix = "data-plane-api-20b1b5fcee88a20a08b71051a961181839ec7268", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/envoyproxy/data-plane-api/archive/20b1b5fcee88a20a08b71051a961181839ec7268.tar.gz", + "https://github.com/envoyproxy/data-plane-api/archive/20b1b5fcee88a20a08b71051a961181839ec7268.tar.gz", + ], + ) + + if "io_bazel_rules_go" not in native.existing_rules(): + http_archive( + name = "io_bazel_rules_go", + sha256 = "dbf5a9ef855684f84cac2e7ae7886c5a001d4f66ae23f6904da0faaaef0d61fc", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.11/rules_go-v0.24.11.tar.gz", + "https://github.com/bazelbuild/rules_go/releases/download/v0.24.11/rules_go-v0.24.11.tar.gz", + ], + ) + + if "build_bazel_rules_apple" not in native.existing_rules(): + http_archive( + name = "build_bazel_rules_apple", + sha256 = "0052d452af7742c8f3a4e0929763388a66403de363775db7e90adecb2ba4944b", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz", + "https://github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz", + ], + ) + + if "build_bazel_apple_support" not in native.existing_rules(): + http_archive( + name = "build_bazel_apple_support", + sha256 = "76df040ade90836ff5543888d64616e7ba6c3a7b33b916aa3a4b68f342d1b447", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/0.11.0/apple_support.0.11.0.tar.gz", + "https://github.com/bazelbuild/apple_support/releases/download/0.11.0/apple_support.0.11.0.tar.gz", + ], + ) + + if "libuv" not in native.existing_rules(): + http_archive( + name = "libuv", + build_file = "@com_github_grpc_grpc//third_party:libuv.BUILD", + sha256 = "5ca4e9091f3231d8ad8801862dc4e851c23af89c69141d27723157776f7291e7", + strip_prefix = "libuv-02a9e1be252b623ee032a3137c0b0c94afbe6809", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/libuv/libuv/archive/02a9e1be252b623ee032a3137c0b0c94afbe6809.tar.gz", + "https://github.com/libuv/libuv/archive/02a9e1be252b623ee032a3137c0b0c94afbe6809.tar.gz", + ], + ) + + if "com_google_googleapis" not in native.existing_rules(): + http_archive( + name = "com_google_googleapis", + sha256 = "5bb6b0253ccf64b53d6c7249625a7e3f6c3bc6402abd52d3778bfa48258703a0", + strip_prefix = "googleapis-2f9af297c84c55c8b871ba4495e01ade42476c92", + 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 = "d987004a72697334a095bbaa18d615804a28280201a50ed6c234c40ccc41e493", + strip_prefix = "bazel-gazelle-0.19.1", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/bazel-gazelle/archive/v0.19.1.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/archive/v0.19.1.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", + sha256 = "dd4962e4a9e8388a4fbc5c33e64d73bdb222f103e4bad40ca5535f81c2c606c2", + strip_prefix = "protoc-gen-validate-59da36e59fef2267fc2b1849a05159e3ecdf24f3", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/envoyproxy/protoc-gen-validate/archive/59da36e59fef2267fc2b1849a05159e3ecdf24f3.tar.gz", + "https://github.com/envoyproxy/protoc-gen-validate/archive/59da36e59fef2267fc2b1849a05159e3ecdf24f3.tar.gz", + ], + ) + + grpc_python_deps() + +# TODO: move some dependencies from "grpc_deps" here? +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 = "6b4314b1b2051ddb9d4fcd1634e1fa9c1bb4012954273c9ff3ef689f6ec6c93e", + strip_prefix = "pyyaml-3.12", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/yaml/pyyaml/archive/3.12.zip", + "https://github.com/yaml/pyyaml/archive/3.12.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 = "b847c71723d8ce0b747aa661d7f3a07f1d16c595bf9c0202f30febc2f9a24a06", + urls = [ + "https://github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.tar.gz", + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.tar.gz", + ], + strip_prefix = "libprotobuf-mutator-ffd86a32874e5c08a143019aad1aaf0907294c9f", + build_file = "@com_github_grpc_grpc//third_party:libprotobuf_mutator.BUILD", + ) diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl new file mode 100644 index 00000000..ec171927 --- /dev/null +++ b/bazel/grpc_extra_deps.bzl @@ -0,0 +1,62 @@ +# 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("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") +load("@upb//bazel:workspace_deps.bzl", "upb_deps") +load("@envoy_api//bazel:repositories.bzl", "api_dependencies") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") +load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") +load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") + +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() + ``` + """ + protobuf_deps() + + upb_deps() + + api_dependencies() + + go_rules_dependencies() + go_register_toolchains() + + 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, + ) diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl new file mode 100644 index 00000000..bbbaa2a1 --- /dev/null +++ b/bazel/grpc_python_deps.bzl @@ -0,0 +1,74 @@ +# 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") + +def grpc_python_deps(): + # protobuf binds to the name "six", so we can't use it here. + # See https://github.com/bazelbuild/bazel/issues/1952 for why bind is + # horrible. + if "six" not in native.existing_rules(): + http_archive( + name = "six", + build_file = "@com_github_grpc_grpc//third_party:six.BUILD", + sha256 = "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", + urls = ["https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.tar.gz"], + ) + + if "enum34" not in native.existing_rules(): + http_archive( + name = "enum34", + build_file = "@com_github_grpc_grpc//third_party:enum34.BUILD", + strip_prefix = "enum34-1.1.6", + sha256 = "8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1", + urls = ["https://files.pythonhosted.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz"], + ) + + if "futures" not in native.existing_rules(): + http_archive( + name = "futures", + build_file = "@com_github_grpc_grpc//third_party:futures.BUILD", + strip_prefix = "futures-3.3.0", + sha256 = "7e033af76a5e35f58e56da7a91e687706faf4e7bdfb2cbc3f2cca6b9bcda9794", + urls = ["https://files.pythonhosted.org/packages/47/04/5fc6c74ad114032cd2c544c575bffc17582295e9cd6a851d6026ab4b2c00/futures-3.3.0.tar.gz"], + ) + + 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 = ["//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 = "e2e38e1f0572ca54d6085df3dec8b607d20e81515fb80215aed19c81e8fe2079", + strip_prefix = "cython-0.29.21", + urls = [ + "https://github.com/cython/cython/archive/0.29.21.tar.gz", + ], + ) diff --git a/bazel/grpc_util.bzl b/bazel/grpc_util.bzl new file mode 100644 index 00000000..b85d9af2 --- /dev/null +++ b/bazel/grpc_util.bzl @@ -0,0 +1,59 @@ +# 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. +_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): + 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) diff --git a/bazel/internal_python_rules.bzl b/bazel/internal_python_rules.bzl new file mode 100644 index 00000000..6f3c8751 --- /dev/null +++ b/bazel/internal_python_rules.bzl @@ -0,0 +1,35 @@ +# 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") +load("//bazel:python_rules.bzl", "py2and3_test") + +def internal_py_grpc_test(name, **kwargs): + """Runs a test under all supported environments.""" + py2and3_test(name, **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 + ".both_pythons", + name + ".gevent", + ], + **suite_kwargs + ) diff --git a/bazel/objc_grpc_library.bzl b/bazel/objc_grpc_library.bzl new file mode 100644 index 00000000..bfc04d11 --- /dev/null +++ b/bazel/objc_grpc_library.bzl @@ -0,0 +1,81 @@ +# 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( + "//bazel:generate_objc.bzl", + "generate_objc", + "generate_objc_hdrs", + "generate_objc_non_arc_srcs", + "generate_objc_srcs", +) +load("//bazel:protobuf.bzl", "well_known_proto_libs") + +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 + ) diff --git a/bazel/protobuf.bzl b/bazel/protobuf.bzl new file mode 100644 index 00000000..d8d18ea8 --- /dev/null +++ b/bazel/protobuf.bzl @@ -0,0 +1,279 @@ +# 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/" + +def well_known_proto_libs(): + return [ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:api_proto", + "@com_google_protobuf//:compiler_plugin_proto", + "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:empty_proto", + "@com_google_protobuf//:field_mask_proto", + "@com_google_protobuf//:source_context_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:type_proto", + "@com_google_protobuf//:wrappers_proto", + ] + +def is_well_known(label): + return label in well_known_proto_libs() + +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. I.e. 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 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) + copied_proto = context.actions.declare_file(source_file.basename) + 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.""" + 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.""" + + out_file_paths = [] + for proto in protos: + if not is_in_virtual_imports(proto): + out_file_paths.append(proto.basename) + else: + path = proto.path[proto.path.index(_VIRTUAL_IMPORTS) + 1:] + out_file_paths.append(path) + + 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 calculated value for --_out= protoc argument 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 --_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 + if ws_root and out_dir.find(ws_root) >= 0: + out_dir = "".join(out_dir.rsplit(ws_root, 1)) + return struct( + path = out_dir, + import_path = out_dir[out_dir.find(_VIRTUAL_IMPORTS) + 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 (is placed in _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 diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl new file mode 100644 index 00000000..b38672ea --- /dev/null +++ b/bazel/python_rules.bzl @@ -0,0 +1,329 @@ +# 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_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]), + ] + + 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) + generated_py_srcs = out_files + + tools = [context.executable._protoc] + + out_dir = get_out_dir(protos, context) + + arguments = ([ + "--python_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("%s/%s/%s" % (context.workspace_name, context.label.package, 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("/", ".")[:-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) + arguments += get_plugin_args( + context.executable._grpc_plugin, + plugin_flags, + out_dir.path, + False, + ) + + arguments += [ + "--proto_path={}".format(get_include_directory(i)) + for i in includes + ] + arguments += ["--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 + ) + +# TODO(https://github.com/grpc/grpc/issues/27543): Remove once Python 2 is no longer supported. +def py2and3_test( + name, + py_test = native.py_test, + **kwargs): + """Runs a Python test under both Python 2 and Python 3. + + Args: + name: The name of the test. + py_test: The rule to use for each test. + **kwargs: Keyword arguments passed directly to the underlying py_test + rule. + """ + if "python_version" in kwargs: + fail("Cannot specify 'python_version' in py2and3_test.") + + names = [name + suffix for suffix in (".python2", ".python3")] + python_versions = ["PY2", "PY3"] + for case_name, python_version in zip(names, python_versions): + py_test( + name = case_name, + python_version = python_version, + **kwargs + ) + + suite_kwargs = {} + if "visibility" in kwargs: + suite_kwargs["visibility"] = kwargs["visibility"] + + native.test_suite( + name = name + ".both_pythons", + tests = names, + **suite_kwargs + ) diff --git a/grpc.bzl b/grpc.bzl new file mode 100644 index 00000000..06de3bca --- /dev/null +++ b/grpc.bzl @@ -0,0 +1,113 @@ +# Copyright 2015 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. + +""" +Bazel macros to declare gRPC libraries automatically generated from proto files. + +This file declares two macros: +- objc_proto_library +- objc_grpc_library +""" + +def _lower_underscore_to_upper_camel(str): + humps = [] + for hump in str.split("_"): + humps += [hump[0].upper() + hump[1:]] + return "".join(humps) + +def _file_to_upper_camel(src): + elements = src.rpartition("/") + upper_camel = _lower_underscore_to_upper_camel(elements[-1]) + return "".join(elements[:-1] + [upper_camel]) + +def _file_with_extension(src, ext): + elements = src.rpartition("/") + basename = elements[-1].partition(".")[0] + return "".join(elements[:-1] + [basename, ext]) + +def _protoc_invocation(srcs, flags): + """Returns a command line to invoke protoc from a genrule, on the given + sources, using the given flags. + """ + protoc_command = "$(location //external:protoc) -I . " + srcs_params = "" + for src in srcs: + srcs_params += " $(location %s)" % (src) + return protoc_command + flags + srcs_params + +def objc_proto_library(name, srcs, visibility = None): + """Declares an objc_library for the code generated by protoc from the given + proto sources. This generated code doesn't include proto services. + """ + h_files = [] + m_files = [] + for src in srcs: + src = _file_to_upper_camel(src) + h_files += [_file_with_extension(src, ".pbobjc.h")] + m_files += [_file_with_extension(src, ".pbobjc.m")] + + protoc_flags = "--objc_out=$(GENDIR)" + + native.genrule( + name = name + "_codegen", + srcs = srcs + ["//external:protoc"], + outs = h_files + m_files, + cmd = _protoc_invocation(srcs, protoc_flags), + ) + native.objc_library( + name = name, + hdrs = h_files, + includes = ["."], + non_arc_srcs = m_files, + deps = ["//external:protobuf_objc"], + visibility = visibility, + ) + +def objc_grpc_library(name, services, other_messages, visibility = None): + """Declares an objc_library for the code generated by gRPC and protoc from the + given proto sources (services and other_messages). The generated code doesn't + include proto services of the files passed as other_messages. + """ + objc_proto_library(name + "_messages", services + other_messages) + + h_files = [] + m_files = [] + for src in services: + src = _file_to_upper_camel(src) + h_files += [_file_with_extension(src, ".pbrpc.h")] + m_files += [_file_with_extension(src, ".pbrpc.m")] + + protoc_flags = ("--grpc_out=$(GENDIR) --plugin=" + + "protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)") + + native.genrule( + name = name + "_codegen", + srcs = services + [ + "//external:grpc_protoc_plugin_objc", + "//external:protoc", + ], + outs = h_files + m_files, + cmd = _protoc_invocation(services, protoc_flags), + ) + native.objc_library( + name = name, + hdrs = h_files, + includes = ["."], + srcs = m_files, + deps = [ + ":" + name + "_messages", + "//external:proto_objc_rpc", + ], + visibility = visibility, + ) diff --git a/src/objective-c/grpc_objc_internal_library.bzl b/src/objective-c/grpc_objc_internal_library.bzl new file mode 100644 index 00000000..ad212d13 --- /dev/null +++ b/src/objective-c/grpc_objc_internal_library.bzl @@ -0,0 +1,173 @@ +# Copyright 2019 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. +# + +load("@rules_proto//proto:defs.bzl", "proto_library") +load( + "//bazel:generate_objc.bzl", + "generate_objc", + "generate_objc_hdrs", + "generate_objc_non_arc_srcs", + "generate_objc_srcs", +) + +def proto_library_objc_wrapper( + name, + srcs, + deps = [], + use_well_known_protos = False): + """proto_library for adding dependencies to google/protobuf protos + use_well_known_protos - ignored in open source version + """ + proto_library( + name = name, + srcs = srcs, + deps = deps, + ) + +def grpc_objc_examples_library( + name, + srcs = [], + hdrs = [], + textual_hdrs = [], + data = [], + deps = [], + defines = [], + sdk_frameworks = [], + includes = []): + """objc_library for testing, only works in //src/objective-c/exmaples + + Args: + name: name of target + hdrs: public headers + srcs: all source files (.m) + textual_hdrs: private headers + data: any other bundle resources + defines: preprocessors + sdk_frameworks: sdks + includes: added to search path, always [the path to objc directory] + deps: dependencies + """ + native.objc_library( + name = name, + srcs = srcs, + hdrs = hdrs, + textual_hdrs = textual_hdrs, + data = data, + defines = defines, + includes = includes, + sdk_frameworks = sdk_frameworks, + deps = deps + [":RemoteTest"], + ) + +def grpc_objc_testing_library( + name, + srcs = [], + hdrs = [], + textual_hdrs = [], + data = [], + deps = [], + defines = [], + includes = []): + """objc_library for testing, only works in //src/objective-c/tests + + Args: + name: name of target + hdrs: public headers + srcs: all source files (.m) + textual_hdrs: private headers + data: any other bundle resources + defines: preprocessors + includes: added to search path, always [the path to objc directory] + deps: dependencies + """ + + additional_deps = [ + ":RemoteTest", + "//src/objective-c:grpc_objc_client_internal_testing", + ] + + if not name == "TestConfigs": + additional_deps += [":TestConfigs"] + + native.objc_library( + name = name, + hdrs = hdrs, + srcs = srcs, + textual_hdrs = textual_hdrs, + data = data, + defines = defines, + includes = includes, + deps = deps + additional_deps, + ) + +def local_objc_grpc_library(name, deps, testing = True, srcs = [], use_well_known_protos = False, **kwargs): + """!!For local targets within the gRPC repository only!! Will not work outside of the repo + """ + 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"] + + library_deps = ["@com_google_protobuf//:protobuf_objc"] + if testing: + library_deps += ["//src/objective-c:grpc_objc_client_internal_testing"] + else: + library_deps += ["//src/objective-c:proto_objc_rpc"] + + 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"], + deps = library_deps, + ) diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl new file mode 100644 index 00000000..272c2bb8 --- /dev/null +++ b/test/core/bad_client/generate_tests.bzl @@ -0,0 +1,56 @@ +#!/usr/bin/env python2.7 +# Copyright 2015 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 the appropriate build.json data for all the bad_client tests.""" + +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test") + +def test_options(): + return struct() + +# maps test names to options +BAD_CLIENT_TESTS = { + "badreq": test_options(), + "bad_streaming_id": test_options(), + "connection_prefix": test_options(), + "duplicate_header": test_options(), + "headers": test_options(), + "initial_settings_frame": test_options(), + "head_of_line_blocking": test_options(), + "large_metadata": test_options(), + "out_of_bounds": test_options(), + "server_registered_method": test_options(), + "simple_request": test_options(), + "window_overflow": test_options(), + "unknown_frame": test_options(), +} + +def grpc_bad_client_tests(): + grpc_cc_library( + name = "bad_client_test", + srcs = ["bad_client.cc"], + hdrs = ["bad_client.h"], + language = "C++", + deps = ["//test/core/util:grpc_test_util", "//:grpc", "//:gpr", "//test/core/end2end:cq_verifier"], + ) + for t, topt in BAD_CLIENT_TESTS.items(): + grpc_cc_test( + name = "%s_bad_client_test" % t, + srcs = ["tests/%s.cc" % t], + deps = [":bad_client_test"], + external_deps = [ + "gtest", + ], + ) diff --git a/test/core/bad_ssl/generate_tests.bzl b/test/core/bad_ssl/generate_tests.bzl new file mode 100644 index 00000000..79e82b30 --- /dev/null +++ b/test/core/bad_ssl/generate_tests.bzl @@ -0,0 +1,57 @@ +#!/usr/bin/env python2.7 +# Copyright 2015 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("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test") + +def test_options(): + return struct() + +# maps test names to options +BAD_SSL_TESTS = ["cert", "alpn"] + +def grpc_bad_ssl_tests(): + grpc_cc_library( + name = "bad_ssl_test_server", + srcs = ["server_common.cc"], + hdrs = ["server_common.h"], + deps = [ + "//test/core/util:grpc_test_util", + "//:grpc", + ], + ) + for t in BAD_SSL_TESTS: + grpc_cc_binary( + name = "bad_ssl_%s_server" % t, + srcs = ["servers/%s.cc" % t], + deps = [":bad_ssl_test_server"], + ) + grpc_cc_test( + name = "bad_ssl_%s_test" % t, + srcs = ["bad_ssl_test.cc"], + data = [ + ":bad_ssl_%s_server" % t, + "//src/core/tsi/test_creds:badserver.key", + "//src/core/tsi/test_creds:badserver.pem", + "//src/core/tsi/test_creds:ca.pem", + "//src/core/tsi/test_creds:server1.key", + "//src/core/tsi/test_creds:server1.pem", + ], + deps = [ + "//test/core/util:grpc_test_util", + "//:gpr", + "//test/core/end2end:cq_verifier", + ], + tags = ["no_windows"], + ) diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl new file mode 100644 index 00000000..a2a9d2b7 --- /dev/null +++ b/test/core/end2end/generate_tests.bzl @@ -0,0 +1,561 @@ +#!/usr/bin/env python2.7 +# Copyright 2015 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 the appropriate build.json data for all the end2end tests.""" + +load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library") + +POLLERS = ["epollex", "epoll1", "poll"] + +def _fixture_options( + fullstack = True, + includes_proxy = False, + dns_resolver = True, + name_resolution = True, + secure = True, + tracing = False, + _platforms = ["windows", "linux", "mac", "posix"], + is_inproc = False, + is_http2 = True, + supports_proxy_auth = False, + supports_write_buffering = True, + client_channel = True, + supports_msvc = True, + flaky_tests = []): + return struct( + fullstack = fullstack, + includes_proxy = includes_proxy, + dns_resolver = dns_resolver, + name_resolution = name_resolution, + secure = secure, + tracing = tracing, + is_inproc = is_inproc, + is_http2 = is_http2, + supports_proxy_auth = supports_proxy_auth, + supports_write_buffering = supports_write_buffering, + client_channel = client_channel, + supports_msvc = supports_msvc, + _platforms = _platforms, + flaky_tests = flaky_tests, + ) + +# maps fixture name to whether it requires the security library +END2END_FIXTURES = { + "h2_compress": _fixture_options(), + "h2_census": _fixture_options(), + # TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have + # decided how the load reporting service should be enabled. + #'h2_load_reporting': _fixture_options(), + "h2_fakesec": _fixture_options(), + "h2_fd": _fixture_options( + dns_resolver = False, + fullstack = False, + client_channel = False, + _platforms = ["linux", "mac", "posix"], + ), + "h2_full": _fixture_options(), + "h2_full+pipe": _fixture_options(_platforms = ["linux"]), + "h2_full+trace": _fixture_options(tracing = True), + "h2_http_proxy": _fixture_options(supports_proxy_auth = True), + "h2_insecure": _fixture_options(secure = True), + "h2_oauth2": _fixture_options(), + "h2_proxy": _fixture_options(includes_proxy = True), + "h2_sockpair_1byte": _fixture_options( + fullstack = False, + dns_resolver = False, + client_channel = False, + ), + "h2_sockpair": _fixture_options( + fullstack = False, + dns_resolver = False, + client_channel = False, + ), + "h2_sockpair+trace": _fixture_options( + fullstack = False, + dns_resolver = False, + tracing = True, + client_channel = False, + ), + "h2_ssl": _fixture_options(secure = True), + "h2_ssl_cred_reload": _fixture_options(secure = True), + "h2_tls": _fixture_options(secure = True), + "h2_local_uds": _fixture_options( + secure = True, + dns_resolver = False, + _platforms = ["linux", "mac", "posix"], + ), + "h2_local_ipv4": _fixture_options(secure = True, dns_resolver = False, _platforms = ["linux", "mac", "posix"]), + "h2_local_ipv6": _fixture_options(secure = True, dns_resolver = False, _platforms = ["linux", "mac", "posix"]), + "h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = True), + "h2_uds": _fixture_options( + dns_resolver = False, + _platforms = ["linux", "mac", "posix"], + ), + "inproc": _fixture_options( + secure = True, + fullstack = False, + dns_resolver = False, + name_resolution = False, + is_inproc = True, + is_http2 = False, + supports_write_buffering = False, + client_channel = False, + ), +} + +# maps fixture name to whether it requires the security library +END2END_NOSEC_FIXTURES = { + "h2_compress": _fixture_options(secure = False), + "h2_census": _fixture_options(secure = False), + # TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have + # decided how the load reporting service should be enabled. + #'h2_load_reporting': _fixture_options(), + "h2_fakesec": _fixture_options(), + "h2_fd": _fixture_options( + dns_resolver = False, + fullstack = False, + client_channel = False, + secure = False, + _platforms = ["linux", "mac", "posix"], + supports_msvc = False, + ), + "h2_full": _fixture_options(secure = False), + "h2_full+pipe": _fixture_options(secure = False, _platforms = ["linux"], supports_msvc = False), + "h2_full+trace": _fixture_options(secure = False, tracing = True, supports_msvc = False), + "h2_http_proxy": _fixture_options(secure = False, supports_proxy_auth = True), + "h2_proxy": _fixture_options(secure = False, includes_proxy = True), + "h2_sockpair_1byte": _fixture_options( + fullstack = False, + dns_resolver = False, + client_channel = False, + secure = False, + ), + "h2_sockpair": _fixture_options( + fullstack = False, + dns_resolver = False, + client_channel = False, + secure = False, + ), + "h2_sockpair+trace": _fixture_options( + fullstack = False, + dns_resolver = False, + tracing = True, + secure = False, + client_channel = False, + ), + "h2_ssl": _fixture_options(secure = False), + "h2_ssl_cred_reload": _fixture_options(secure = False), + "h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = False), + "h2_uds": _fixture_options( + dns_resolver = False, + _platforms = ["linux", "mac", "posix"], + secure = False, + supports_msvc = False, + ), +} + +def _test_options( + needs_fullstack = False, + needs_dns = False, + needs_names = False, + proxyable = True, + secure = False, + traceable = False, + exclude_inproc = False, + needs_http2 = False, + needs_proxy_auth = False, + needs_write_buffering = False, + needs_client_channel = False, + short_name = None, + exclude_pollers = []): + return struct( + needs_fullstack = needs_fullstack, + needs_dns = needs_dns, + needs_names = needs_names, + proxyable = proxyable, + secure = secure, + traceable = traceable, + exclude_inproc = exclude_inproc, + needs_http2 = needs_http2, + needs_proxy_auth = needs_proxy_auth, + needs_write_buffering = needs_write_buffering, + needs_client_channel = needs_client_channel, + short_name = short_name, + exclude_pollers = exclude_pollers, + ) + +# maps test names to options +END2END_TESTS = { + "bad_hostname": _test_options(needs_names = True), + "bad_ping": _test_options(needs_fullstack = True, proxyable = False), + "binary_metadata": _test_options(), + "resource_quota_server": _test_options( + proxyable = False, + # TODO(b/151212019): Test case known to be flaky under epoll1. + exclude_pollers = ["epoll1"], + ), + "call_creds": _test_options(secure = True), + "call_host_override": _test_options( + needs_fullstack = True, + needs_dns = True, + needs_names = True, + ), + "cancel_after_accept": _test_options(), + "cancel_after_client_done": _test_options(), + "cancel_after_invoke": _test_options(), + "cancel_after_round_trip": _test_options(), + "cancel_before_invoke": _test_options(), + "cancel_in_a_vacuum": _test_options(), + "cancel_with_status": _test_options(), + "client_streaming": _test_options(), + "compressed_payload": _test_options(proxyable = False, exclude_inproc = True), + "connectivity": _test_options( + needs_fullstack = True, + needs_names = True, + proxyable = False, + ), + "channelz": _test_options(), + "default_host": _test_options( + needs_fullstack = True, + needs_dns = True, + needs_names = True, + ), + "disappearing_server": _test_options(needs_fullstack = True, needs_names = True), + "empty_batch": _test_options(), + "filter_causes_close": _test_options(), + "filter_init_fails": _test_options(), + "filter_context": _test_options(), + "graceful_server_shutdown": _test_options(exclude_inproc = True), + "hpack_size": _test_options( + proxyable = False, + traceable = False, + exclude_inproc = True, + ), + "high_initial_seqno": _test_options(), + "idempotent_request": _test_options(), + "invoke_large_request": _test_options(), + "keepalive_timeout": _test_options(proxyable = False, needs_http2 = True), + "large_metadata": _test_options(), + "max_concurrent_streams": _test_options( + proxyable = False, + exclude_inproc = True, + ), + "max_connection_age": _test_options(exclude_inproc = True), + "max_connection_idle": _test_options(needs_fullstack = True, proxyable = False), + "max_message_length": _test_options(), + "negative_deadline": _test_options(), + "no_error_on_hotpath": _test_options(proxyable = False), + "no_logging": _test_options(traceable = False), + "no_op": _test_options(), + "payload": _test_options(), + # TODO(juanlishen): This is disabled for now because it depends on some generated functions in + # end2end_tests.cc, which are not generated because they would depend on OpenCensus while + # OpenCensus can only be built via Bazel so far. + # 'load_reporting_hook': _test_options(), + "ping_pong_streaming": _test_options(), + "ping": _test_options(needs_fullstack = True, proxyable = False), + "proxy_auth": _test_options(needs_proxy_auth = True), + "registered_call": _test_options(), + "request_with_flags": _test_options(proxyable = False), + "request_with_payload": _test_options(), + "retry": _test_options(needs_client_channel = True), + "retry_cancellation": _test_options(needs_client_channel = True), + "retry_cancel_during_delay": _test_options(needs_client_channel = True), + "retry_cancel_with_multiple_send_batches": _test_options( + # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE + # See b/151617965 + short_name = "retry_cancel3", + needs_client_channel = True, + ), + "retry_disabled": _test_options(needs_client_channel = True), + "retry_exceeds_buffer_size_in_delay": _test_options( + needs_client_channel = True, + ), + "retry_exceeds_buffer_size_in_initial_batch": _test_options( + needs_client_channel = True, + # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE + # See b/151617965 + short_name = "retry_exceeds_buffer_size_in_init", + ), + "retry_exceeds_buffer_size_in_subsequent_batch": _test_options( + needs_client_channel = True, + # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE + # See b/151617965 + short_name = "retry_exceeds_buffer_size_in_subseq", + ), + "retry_lb_drop": _test_options(needs_client_channel = True), + "retry_lb_fail": _test_options(needs_client_channel = True), + "retry_non_retriable_status": _test_options(needs_client_channel = True), + "retry_non_retriable_status_before_recv_trailing_metadata_started": _test_options( + needs_client_channel = True, + # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE + # See b/151617965 + short_name = "retry_non_retriable_status2", + ), + "retry_per_attempt_recv_timeout": _test_options( + needs_client_channel = True, + ), + "retry_per_attempt_recv_timeout_on_last_attempt": _test_options( + needs_client_channel = True, + # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE + # See b/151617965 + short_name = "retry_per_attempt_recv_timeout2", + ), + "retry_recv_initial_metadata": _test_options(needs_client_channel = True), + "retry_recv_message": _test_options(needs_client_channel = True), + "retry_recv_trailing_metadata_error": _test_options( + needs_client_channel = True, + ), + "retry_send_initial_metadata_refs": _test_options( + needs_client_channel = True, + ), + "retry_send_op_fails": _test_options(needs_client_channel = True), + "retry_server_pushback_delay": _test_options(needs_client_channel = True), + "retry_server_pushback_disabled": _test_options(needs_client_channel = True), + "retry_streaming": _test_options(needs_client_channel = True), + "retry_streaming_after_commit": _test_options(needs_client_channel = True), + "retry_streaming_succeeds_before_replay_finished": _test_options( + needs_client_channel = True, + # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE + # See b/151617965 + short_name = "retry_streaming2", + ), + "retry_throttled": _test_options(needs_client_channel = True), + "retry_too_many_attempts": _test_options(needs_client_channel = True), + "sdk_authz": _test_options(secure = True), + "server_finishes_request": _test_options(), + "server_streaming": _test_options(needs_http2 = True), + "shutdown_finishes_calls": _test_options(), + "shutdown_finishes_tags": _test_options(), + "simple_cacheable_request": _test_options(), + "simple_delayed_request": _test_options(needs_fullstack = True), + "simple_metadata": _test_options(), + "simple_request": _test_options(), + "streaming_error_response": _test_options(), + "stream_compression_compressed_payload": _test_options( + proxyable = False, + exclude_inproc = True, + ), + "stream_compression_payload": _test_options(exclude_inproc = True), + "stream_compression_ping_pong_streaming": _test_options(exclude_inproc = True), + "trailing_metadata": _test_options(), + "authority_not_supported": _test_options(), + "filter_latency": _test_options(), + "filter_status_code": _test_options(), + "write_buffering": _test_options(needs_write_buffering = True), + "write_buffering_at_end": _test_options(needs_write_buffering = True), +} + +def _compatible(fopt, topt): + if topt.needs_fullstack: + if not fopt.fullstack: + return False + if topt.needs_dns: + if not fopt.dns_resolver: + return False + if topt.needs_names: + if not fopt.name_resolution: + return False + if not topt.proxyable: + if fopt.includes_proxy: + return False + if not topt.traceable: + if fopt.tracing: + return False + if topt.exclude_inproc: + if fopt.is_inproc: + return False + if topt.needs_http2: + if not fopt.is_http2: + return False + if topt.needs_proxy_auth: + if not fopt.supports_proxy_auth: + return False + if topt.needs_write_buffering: + if not fopt.supports_write_buffering: + return False + if topt.needs_client_channel: + if not fopt.client_channel: + return False + return True + +def _platform_support_tags(fopt): + result = [] + if not "windows" in fopt._platforms: + result += ["no_windows"] + if not "mac" in fopt._platforms: + result += ["no_mac"] + if not "linux" in fopt._platforms: + result += ["no_linux"] + return result + +def grpc_end2end_tests(): + grpc_cc_library( + name = "end2end_tests", + srcs = ["end2end_tests.cc", "end2end_test_utils.cc"] + [ + "tests/%s.cc" % t + for t in sorted(END2END_TESTS.keys()) + ], + hdrs = [ + "tests/cancel_test_helpers.h", + "end2end_tests.h", + ], + language = "C++", + testonly = 1, + deps = [ + ":cq_verifier", + ":ssl_test_data", + ":http_proxy", + ":proxy", + ":local_util", + "//test/core/util:test_lb_policies", + "//:grpc_authorization_provider", + ], + ) + + for f, fopt in END2END_FIXTURES.items(): + grpc_cc_binary( + name = "%s_test" % f, + srcs = ["fixtures/%s.cc" % f], + language = "C++", + testonly = 1, + data = [ + "//src/core/tsi/test_creds:ca.pem", + "//src/core/tsi/test_creds:server1.key", + "//src/core/tsi/test_creds:server1.pem", + ], + deps = [ + ":end2end_tests", + "//test/core/util:grpc_test_util", + "//:grpc", + "//:gpr", + ], + tags = _platform_support_tags(fopt), + ) + + for t, topt in END2END_TESTS.items(): + #print(_compatible(fopt, topt), f, t, fopt, topt) + if not _compatible(fopt, topt): + continue + + test_short_name = str(t) if not topt.short_name else topt.short_name + native.sh_test( + name = "%s_test@%s" % (f, test_short_name), + data = [":%s_test" % f], + srcs = ["end2end_test.sh"], + args = [ + "$(location %s_test)" % f, + t, + ], + tags = ["no_linux"] + _platform_support_tags(fopt), + flaky = t in fopt.flaky_tests, + ) + + for poller in POLLERS: + if poller in topt.exclude_pollers: + continue + native.sh_test( + name = "%s_test@%s@poller=%s" % (f, test_short_name, poller), + data = [":%s_test" % f], + srcs = ["end2end_test.sh"], + args = [ + "$(location %s_test)" % f, + t, + poller, + ], + tags = ["no_mac", "no_windows"], + flaky = t in fopt.flaky_tests, + ) + +def grpc_end2end_nosec_tests(): + grpc_cc_library( + name = "end2end_nosec_tests", + srcs = ["end2end_nosec_tests.cc", "end2end_test_utils.cc"] + [ + "tests/%s.cc" % t + for t in sorted(END2END_TESTS.keys()) + if not END2END_TESTS[t].secure + ], + hdrs = [ + "tests/cancel_test_helpers.h", + "end2end_tests.h", + ], + language = "C++", + testonly = 1, + deps = [ + ":cq_verifier", + ":ssl_test_data", + ":http_proxy", + ":proxy", + ":local_util", + "//test/core/util:test_lb_policies", + ], + ) + + for f, fopt in END2END_NOSEC_FIXTURES.items(): + if fopt.secure: + continue + grpc_cc_binary( + name = "%s_nosec_test" % f, + srcs = ["fixtures/%s.cc" % f], + language = "C++", + testonly = 1, + data = [ + "//src/core/tsi/test_creds:ca.pem", + "//src/core/tsi/test_creds:server1.key", + "//src/core/tsi/test_creds:server1.pem", + ], + deps = [ + ":end2end_nosec_tests", + "//test/core/util:grpc_test_util_unsecure", + "//:grpc_unsecure", + "//:gpr", + ], + tags = _platform_support_tags(fopt), + ) + for t, topt in END2END_TESTS.items(): + #print(_compatible(fopt, topt), f, t, fopt, topt) + if not _compatible(fopt, topt): + continue + if topt.secure: + continue + + test_short_name = str(t) if not topt.short_name else topt.short_name + native.sh_test( + name = "%s_nosec_test@%s" % (f, test_short_name), + data = [":%s_nosec_test" % f], + srcs = ["end2end_test.sh"], + args = [ + "$(location %s_nosec_test)" % f, + t, + ], + tags = ["no_linux"] + _platform_support_tags(fopt), + flaky = t in fopt.flaky_tests, + ) + + for poller in POLLERS: + if poller in topt.exclude_pollers: + continue + native.sh_test( + name = "%s_nosec_test@%s@poller=%s" % (f, test_short_name, poller), + data = [":%s_nosec_test" % f], + srcs = ["end2end_test.sh"], + args = [ + "$(location %s_nosec_test)" % f, + t, + poller, + ], + tags = ["no_mac", "no_windows"], + flaky = t in fopt.flaky_tests, + ) diff --git a/test/core/util/grpc_fuzzer.bzl b/test/core/util/grpc_fuzzer.bzl new file mode 100644 index 00000000..c85a8f3d --- /dev/null +++ b/test/core/util/grpc_fuzzer.bzl @@ -0,0 +1,75 @@ +# 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. + +load("//bazel:grpc_build_system.bzl", "grpc_cc_test") +load("@rules_proto//proto:defs.bzl", "proto_library") +load("@rules_cc//cc:defs.bzl", "cc_proto_library") + +def grpc_fuzzer(name, corpus, srcs = [], deps = [], data = [], size = "large", **kwargs): + CORPUS_DIR = native.package_name() + "/" + corpus + grpc_cc_test( + name = name, + srcs = srcs, + deps = deps + select({ + "//:grpc_build_fuzzers": [], + "//conditions:default": ["//test/core/util:fuzzer_corpus_test"], + }), + data = data + native.glob([corpus + "/**"]), + external_deps = [ + "gtest", + ], + size = size, + args = select({ + "//:grpc_build_fuzzers": [CORPUS_DIR], + "//conditions:default": ["--directory=" + CORPUS_DIR], + }), + **kwargs + ) + +def grpc_proto_fuzzer(name, corpus, proto, srcs = [], deps = [], data = [], size = "large", **kwargs): + PROTO_LIBRARY = "_%s_proto" % name + CC_PROTO_LIBRARY = "_%s_cc_proto" % name + CORPUS_DIR = native.package_name() + "/" + corpus + + proto_library( + name = PROTO_LIBRARY, + srcs = [proto], + ) + + cc_proto_library( + name = CC_PROTO_LIBRARY, + deps = [PROTO_LIBRARY], + ) + + grpc_cc_test( + name = name, + srcs = srcs, + deps = deps + [ + "@com_google_libprotobuf_mutator//:libprotobuf_mutator", + CC_PROTO_LIBRARY, + ] + select({ + "//:grpc_build_fuzzers": [], + "//conditions:default": ["//test/core/util:fuzzer_corpus_test"], + }), + data = data + native.glob([corpus + "/**"]), + external_deps = [ + "gtest", + ], + size = size, + args = select({ + "//:grpc_build_fuzzers": [CORPUS_DIR], + "//conditions:default": ["--directory=" + CORPUS_DIR], + }), + **kwargs + ) diff --git a/test/cpp/microbenchmarks/grpc_benchmark_config.bzl b/test/cpp/microbenchmarks/grpc_benchmark_config.bzl new file mode 100644 index 00000000..5b80171a --- /dev/null +++ b/test/cpp/microbenchmarks/grpc_benchmark_config.bzl @@ -0,0 +1,18 @@ +# 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. +"""Configuration macros for grpc microbenchmarking""" + +def grpc_benchmark_args(): + """Command line arguments for running a microbenchmark as a test""" + return ["--benchmark_min_time=0.001"] diff --git a/test/cpp/naming/generate_resolver_component_tests.bzl b/test/cpp/naming/generate_resolver_component_tests.bzl new file mode 100644 index 00000000..45c7ab34 --- /dev/null +++ b/test/cpp/naming/generate_resolver_component_tests.bzl @@ -0,0 +1,92 @@ +#!/usr/bin/env python2.7 +# Copyright 2015 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("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_test") + +def generate_resolver_component_tests(): + for unsecure_build_config_suffix in ["_unsecure", ""]: + grpc_cc_test( + name = "address_sorting_test%s" % unsecure_build_config_suffix, + srcs = [ + "address_sorting_test.cc", + ], + external_deps = [ + "gtest", + ], + deps = [ + "//test/cpp/util:test_util%s" % unsecure_build_config_suffix, + "//test/core/util:grpc_test_util%s" % unsecure_build_config_suffix, + "//:grpc++%s" % unsecure_build_config_suffix, + "//:grpc%s" % unsecure_build_config_suffix, + "//:gpr", + "//test/cpp/util:test_config", + ], + tags = ["no_windows"], + ) + + # meant to be invoked only through the top-level shell script driver + grpc_cc_binary( + name = "resolver_component_test%s" % unsecure_build_config_suffix, + testonly = 1, + srcs = [ + "resolver_component_test.cc", + ], + external_deps = [ + "gtest", + ], + deps = [ + ":dns_test_util", + "//test/cpp/util:test_util%s" % unsecure_build_config_suffix, + "//test/core/util:grpc_test_util%s" % unsecure_build_config_suffix, + "//:grpc++%s" % unsecure_build_config_suffix, + "//:grpc%s" % unsecure_build_config_suffix, + "//:gpr", + "//test/cpp/util:test_config", + ], + tags = ["no_windows"], + ) + grpc_cc_test( + name = "resolver_component_tests_runner_invoker%s" % unsecure_build_config_suffix, + srcs = [ + "resolver_component_tests_runner_invoker.cc", + ], + external_deps = [ + "absl/flags:flag", + ], + deps = [ + "//test/cpp/util:test_util", + "//test/core/util:grpc_test_util", + "//:grpc++", + "//:grpc", + "//:gpr", + "//test/cpp/util:test_config", + ], + data = [ + ":resolver_component_tests_runner", + ":resolver_component_test%s" % unsecure_build_config_suffix, + "//test/cpp/naming/utils:dns_server", + "//test/cpp/naming/utils:dns_resolver", + "//test/cpp/naming/utils:tcp_connect", + "resolver_test_record_groups.yaml", # include the transitive dependency so that the dns sever py binary can locate this + ], + args = [ + "--test_bin_name=resolver_component_test%s" % unsecure_build_config_suffix, + "--running_under_bazel=true", + ], + # The test is highly flaky on AWS workers that we use for running ARM64 tests. + # The "no_arm64" tag can be used to skip it. + # (see https://github.com/grpc/grpc/issues/25289). + tags = ["no_windows", "no_mac", "no_arm64"], + ) diff --git a/test/cpp/qps/json_run_localhost_scenarios.bzl b/test/cpp/qps/json_run_localhost_scenarios.bzl new file mode 100644 index 00000000..543997f5 --- /dev/null +++ b/test/cpp/qps/json_run_localhost_scenarios.bzl @@ -0,0 +1,93 @@ +# 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. +"""AUTOGENERATED: configuration of benchmark scenarios to be run as bazel test""" + +JSON_RUN_LOCALHOST_SCENARIOS = { + "cpp_protobuf_async_unary_1channel_100rpcs_1MB": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_1channel_100rpcs_1MB", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 1, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_client_1channel_1MB": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_client_1channel_1MB", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_75Kqps_600channel_60Krpcs_300Breq_50Bresp": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_75Kqps_600channel_60Krpcs_300Breq_50Bresp", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 300, "resp_size": 50}}, "load_params": {"poisson": {"offered_load": 37500}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 16, "server_processes": 0, "threads_per_cq": 1, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_1mps_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_1mps_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_10mps_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_10mps_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_1channel_1MBmsg_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_1channel_1MBmsg_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 1, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 1048576, "resp_size": 1048576}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 65536, "resp_size": 65536}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 65536, "resp_size": 65536}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_1cq_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_1cq_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_1cq_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1cq_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_1cq_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_1cq_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_one_server_core_secure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_one_server_core_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 10, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 128, "resp_size": 8388608}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 10, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_ping_pong_secure_1MB": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_ping_pong_secure_1MB", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_unary_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_unary_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_unary_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_unary_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_client_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_client_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_client_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_client_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_server_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_server_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 4, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_server_ping_pong_secure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_server_ping_pong_secure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_1mps_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_1mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_10mps_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_10mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 1, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 1048576, "resp_size": 1048576}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 65536, "resp_size": 65536}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 65536, "resp_size": 65536}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_1cq_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_1cq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_one_server_core_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_one_server_core_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 10, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 128, "resp_size": 8388608}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 10, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_ping_pong_insecure_1MB": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_ping_pong_insecure_1MB", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_unary_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_unary_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_unary_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_unary_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_client_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_client_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_client_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_client_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_server_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_server_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 4, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_server_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_server_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 4, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', +} diff --git a/test/cpp/qps/qps_benchmark_script.bzl b/test/cpp/qps/qps_benchmark_script.bzl new file mode 100644 index 00000000..6f4def97 --- /dev/null +++ b/test/cpp/qps/qps_benchmark_script.bzl @@ -0,0 +1,92 @@ +# Copyright 2018 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. +# + +"""Script to run qps benchmark.""" + +load("//bazel:grpc_build_system.bzl", "grpc_cc_test") +load("//test/cpp/qps:qps_json_driver_scenarios.bzl", "QPS_JSON_DRIVER_SCENARIOS") +load("//test/cpp/qps:json_run_localhost_scenarios.bzl", "JSON_RUN_LOCALHOST_SCENARIOS") + +def add_suffix(name): + # NOTE(https://github.com/grpc/grpc/issues/24178): Add the suffix to the name + # to avoid having the target name that 87, 88, 89 or 90 long. + m = len(name) - (87 - len("//test/cpp/qps:")) + if m >= 0 and m <= 3: + return name + "_" * (4 - m) + else: + return name + +def qps_json_driver_batch(): + for scenario in QPS_JSON_DRIVER_SCENARIOS: + grpc_cc_test( + name = add_suffix("qps_json_driver_test_%s" % scenario), + srcs = ["qps_json_driver.cc"], + args = [ + "--run_inproc", + "--scenarios_json", + QPS_JSON_DRIVER_SCENARIOS[scenario], + ], + deps = [ + ":benchmark_config", + ":driver_impl", + "//:grpc++", + "//test/cpp/util:test_config", + "//test/cpp/util:test_util", + ], + tags = [ + "qps_json_driver", + "no_mac", + ], + # TODO(b/156975956): address OOMing benchmark tests + flaky = True, + ) + +def json_run_localhost_batch(): + for scenario in JSON_RUN_LOCALHOST_SCENARIOS: + grpc_cc_test( + name = add_suffix("json_run_localhost_%s" % scenario), + srcs = ["json_run_localhost.cc"], + args = [ + "--scenarios_json", + JSON_RUN_LOCALHOST_SCENARIOS[scenario], + ], + data = [ + "//test/cpp/qps:qps_json_driver", + "//test/cpp/qps:qps_worker", + ], + deps = [ + "//:gpr", + "//test/core/util:grpc_test_util", + "//test/cpp/util:test_config", + "//test/cpp/util:test_util", + ], + tags = [ + "json_run_localhost", + "no_windows", + "no_mac", + ], + # TODO(b/156975956): address OOMing benchmark tests + flaky = True, + ) diff --git a/test/cpp/qps/qps_json_driver_scenarios.bzl b/test/cpp/qps/qps_json_driver_scenarios.bzl new file mode 100644 index 00000000..90fbf95e --- /dev/null +++ b/test/cpp/qps/qps_json_driver_scenarios.bzl @@ -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. +"""AUTOGENERATED: configuration of benchmark scenarios to be run as bazel test""" + +QPS_JSON_DRIVER_SCENARIOS = { + "cpp_protobuf_async_unary_1channel_100rpcs_1MB": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_1channel_100rpcs_1MB", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 1, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_client_1channel_1MB": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_client_1channel_1MB", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_ping_pong_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_ping_pong_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 1, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_1mps_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_1mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_10mps_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_10mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 1, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 1048576, "resp_size": 1048576}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 65536, "resp_size": 65536}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"bytebuf_params": {"req_size": 65536, "resp_size": 65536}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_1cq_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_1cq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure": '\'{"scenarios": [{"name": "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_GENERIC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"bytebuf_params": {"req_size": 0, "resp_size": 0}}}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 13, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 1000000, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 1000000, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 2, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 2, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 10, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 128, "resp_size": 8388608}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 10, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_ping_pong_insecure_1MB": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_ping_pong_insecure_1MB", "num_servers": 1, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 1, "async_client_threads": 1, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 1048576, "resp_size": 1048576}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "latency"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_unary_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_unary_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_unary_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_unary_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "UNARY", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 1}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 0, "rpc_type": "STREAMING", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}, "messages_per_stream": 10}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 0, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 16, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_CLIENT", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "SYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 1, "client_channels": 4, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "SYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', + "cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure": '\'{"scenarios": [{"name": "cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure", "num_servers": 1, "num_clients": 0, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "outstanding_rpcs_per_channel": 100, "client_channels": 4, "async_client_threads": 0, "client_processes": 0, "threads_per_cq": 3, "rpc_type": "STREAMING_FROM_SERVER", "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}], "payload_config": {"simple_params": {"req_size": 0, "resp_size": 0}}, "load_params": {"closed_loop": {}}}, "server_config": {"server_type": "ASYNC_SERVER", "security_params": null, "async_server_threads": 0, "server_processes": 0, "threads_per_cq": 3, "channel_args": [{"name": "grpc.optimization_target", "str_value": "throughput"}, {"name": "grpc.minimal_stack", "int_value": 1}]}, "warmup_seconds": 0, "benchmark_seconds": 1}]}\'', +} diff --git a/third_party/address_sorting/address_sorting.bzl b/third_party/address_sorting/address_sorting.bzl new file mode 100644 index 00000000..8010025e --- /dev/null +++ b/third_party/address_sorting/address_sorting.bzl @@ -0,0 +1,38 @@ +# $NetBSD: getaddrinfo.c,v 1.82 2006/03/25 12:09:40 rpaulo Exp $ */ +# $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */ +# +# Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. 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. +# 3. Neither the name of the project 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +def address_sorting_cc_library(name, srcs, hdrs, copts, includes): + native.cc_library( + name = name, + srcs = srcs, + hdrs = hdrs, + copts = copts, + includes = includes, + ) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl new file mode 100644 index 00000000..d06fa2b5 --- /dev/null +++ b/third_party/py/python_configure.bzl @@ -0,0 +1,398 @@ +# Adapted with modifications from tensorflow/third_party/py/ +"""Repository rule for Python autoconfiguration. + +`python_configure` depends on the following environment variables: + + * `PYTHON2_BIN_PATH`: location of python binary. + * `PYTHON2_LIB_PATH`: Location of python libraries. +""" + +_BAZEL_SH = "BAZEL_SH" +_PYTHON2_BIN_PATH = "PYTHON2_BIN_PATH" +_PYTHON2_LIB_PATH = "PYTHON2_LIB_PATH" +_PYTHON3_BIN_PATH = "PYTHON3_BIN_PATH" +_PYTHON3_LIB_PATH = "PYTHON3_LIB_PATH" + +_HEADERS_HELP = ( + "Are Python headers installed? Try installing python-dev or " + + "python3-dev on Debian-based systems. Try python-devel or python3-devel " + + "on Redhat-based systems." +) + +def _tpl(repository_ctx, tpl, substitutions = {}, out = None): + if not out: + out = tpl + repository_ctx.template( + out, + Label("//third_party/py:%s.tpl" % tpl), + substitutions, + ) + +def _fail(msg): + """Output failure message when auto configuration fails.""" + red = "\033[0;31m" + no_color = "\033[0m" + fail("%sPython Configuration Error:%s %s\n" % (red, no_color, msg)) + +def _is_windows(repository_ctx): + """Returns true if the host operating system is windows.""" + os_name = repository_ctx.os.name.lower() + return os_name.find("windows") != -1 + +def _execute( + repository_ctx, + cmdline, + error_msg = None, + error_details = None, + empty_stdout_fine = False): + """Executes an arbitrary shell command. + + Args: + repository_ctx: the repository_ctx object + cmdline: list of strings, the command to execute + error_msg: string, a summary of the error if the command fails + error_details: string, details about the error or steps to fix it + empty_stdout_fine: bool, if True, an empty stdout result is fine, otherwise + it's an error + Return: + the result of repository_ctx.execute(cmdline) + """ + result = repository_ctx.execute(cmdline) + if result.stderr or not (empty_stdout_fine or result.stdout): + _fail("\n".join([ + error_msg.strip() if error_msg else "Repository command failed", + result.stderr.strip(), + error_details if error_details else "", + ])) + else: + return result + +def _read_dir(repository_ctx, src_dir): + """Returns a string with all files in a directory. + + Finds all files inside a directory, traversing subfolders and following + symlinks. The returned string contains the full path of all files + separated by line breaks. + """ + if _is_windows(repository_ctx): + src_dir = src_dir.replace("/", "\\") + find_result = _execute( + repository_ctx, + ["cmd.exe", "/c", "dir", src_dir, "/b", "/s", "/a-d"], + empty_stdout_fine = True, + ) + + # src_files will be used in genrule.outs where the paths must + # use forward slashes. + return find_result.stdout.replace("\\", "/") + else: + find_result = _execute( + repository_ctx, + ["find", src_dir, "-follow", "-type", "f"], + empty_stdout_fine = True, + ) + return find_result.stdout + +def _genrule(src_dir, genrule_name, command, outs): + """Returns a string with a genrule. + + Genrule executes the given command and produces the given outputs. + """ + return ("genrule(\n" + ' name = "' + genrule_name + '",\n' + + " outs = [\n" + outs + "\n ],\n" + ' cmd = """\n' + + command + '\n """,\n' + ")\n") + +def _normalize_path(path): + """Returns a path with '/' and remove the trailing slash.""" + path = path.replace("\\", "/") + if path[-1] == "/": + path = path[:-1] + return path + +def _symlink_genrule_for_dir( + repository_ctx, + src_dir, + dest_dir, + genrule_name, + src_files = [], + dest_files = []): + """Returns a genrule to symlink(or copy if on Windows) a set of files. + + If src_dir is passed, files will be read from the given directory; otherwise + we assume files are in src_files and dest_files + """ + if src_dir != None: + src_dir = _normalize_path(src_dir) + dest_dir = _normalize_path(dest_dir) + files = "\n".join( + sorted(_read_dir(repository_ctx, src_dir).splitlines()), + ) + + # Create a list with the src_dir stripped to use for outputs. + dest_files = files.replace(src_dir, "").splitlines() + src_files = files.splitlines() + command = [] + outs = [] + for i in range(len(dest_files)): + if dest_files[i] != "": + # If we have only one file to link we do not want to use the dest_dir, as + # $(@D) will include the full path to the file. + dest = "$(@D)/" + dest_dir + dest_files[i] if len( + dest_files, + ) != 1 else "$(@D)/" + dest_files[i] + + # On Windows, symlink is not supported, so we just copy all the files. + cmd = "cp -f" if _is_windows(repository_ctx) else "ln -s" + command.append(cmd + ' "%s" "%s"' % (src_files[i], dest)) + outs.append(' "' + dest_dir + dest_files[i] + '",') + return _genrule( + src_dir, + genrule_name, + " && ".join(command), + "\n".join(outs), + ) + +def _get_python_bin(repository_ctx, bin_path_key, default_bin_path, allow_absent): + """Gets the python bin path.""" + python_bin = repository_ctx.os.environ.get(bin_path_key, default_bin_path) + if not repository_ctx.path(python_bin).exists: + # It's a command, use 'which' to find its path. + python_bin_path = repository_ctx.which(python_bin) + else: + # It's a path, use it as it is. + python_bin_path = python_bin + if python_bin_path != None: + return str(python_bin_path) + if not allow_absent: + _fail("Cannot find python in PATH, please make sure " + + "python is installed and add its directory in PATH, or --define " + + "%s='/something/else'.\nPATH=%s" % + (bin_path_key, repository_ctx.os.environ.get("PATH", ""))) + else: + return None + +def _get_bash_bin(repository_ctx): + """Gets the bash bin path.""" + bash_bin = repository_ctx.os.environ.get(_BAZEL_SH) + if bash_bin != None: + return bash_bin + else: + bash_bin_path = repository_ctx.which("bash") + if bash_bin_path != None: + return str(bash_bin_path) + else: + _fail( + "Cannot find bash in PATH, please make sure " + + "bash is installed and add its directory in PATH, or --define " + + "%s='/path/to/bash'.\nPATH=%s" % + (_BAZEL_SH, repository_ctx.os.environ.get("PATH", "")), + ) + +def _get_python_lib(repository_ctx, python_bin, lib_path_key): + """Gets the python lib path.""" + python_lib = repository_ctx.os.environ.get(lib_path_key) + if python_lib != None: + return python_lib + print_lib = ( + "<=1:\n" + + " print(paths[0])\n" + "END" + ) + cmd = "%s - %s" % (python_bin, print_lib) + result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd]) + return result.stdout.strip("\n") + +def _check_python_lib(repository_ctx, python_lib): + """Checks the python lib path.""" + cmd = 'test -d "%s" -a -x "%s"' % (python_lib, python_lib) + result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd]) + if result.return_code == 1: + _fail("Invalid python library path: %s" % python_lib) + +def _check_python_bin(repository_ctx, python_bin, bin_path_key, allow_absent): + """Checks the python bin path.""" + cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) + result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd]) + if result.return_code == 1: + if not allow_absent: + _fail("--define %s='%s' is not executable. Is it the python binary?" % + (bin_path_key, python_bin)) + else: + return None + return True + +def _get_python_include(repository_ctx, python_bin): + """Gets the python include path.""" + result = _execute( + repository_ctx, + [ + python_bin, + "-c", + "from __future__ import print_function;" + + "from distutils import sysconfig;" + + "print(sysconfig.get_python_inc())", + ], + error_msg = "Problem getting python include path for {}.".format(python_bin), + error_details = ( + "Is the Python binary path set up right? " + "(See ./configure or " + + python_bin + ".) " + "Is distutils installed? " + + _HEADERS_HELP + ), + ) + include_path = result.stdout.splitlines()[0] + _execute( + repository_ctx, + [ + python_bin, + "-c", + "import os;" + + "main_header = os.path.join(r'{}', 'Python.h');".format(include_path) + + "assert os.path.exists(main_header), main_header + ' does not exist.'", + ], + error_msg = "Unable to find Python headers for {}".format(python_bin), + error_details = _HEADERS_HELP, + empty_stdout_fine = True, + ) + return include_path + +def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key): + """Get Python import library name (pythonXY.lib) on Windows.""" + result = _execute( + repository_ctx, + [ + python_bin, + "-c", + "import sys;" + 'print("python" + str(sys.version_info[0]) + ' + + ' str(sys.version_info[1]) + ".lib")', + ], + error_msg = "Problem getting python import library.", + error_details = ("Is the Python binary path set up right? " + + "(See ./configure or " + bin_path_key + ".) "), + ) + return result.stdout.splitlines()[0] + +def _create_single_version_package( + repository_ctx, + variety_name, + bin_path_key, + default_bin_path, + lib_path_key, + allow_absent): + """Creates the repository containing files set up to build with Python.""" + empty_include_rule = "filegroup(\n name=\"{}_include\",\n srcs=[],\n)".format(variety_name) + + python_bin = _get_python_bin(repository_ctx, bin_path_key, default_bin_path, allow_absent) + if (python_bin == None or + _check_python_bin(repository_ctx, + python_bin, + bin_path_key, + allow_absent) == None) and allow_absent: + python_include_rule = empty_include_rule + else: + python_lib = _get_python_lib(repository_ctx, python_bin, lib_path_key) + _check_python_lib(repository_ctx, python_lib) + python_include = _get_python_include(repository_ctx, python_bin) + python_include_rule = _symlink_genrule_for_dir( + repository_ctx, + python_include, + "{}_include".format(variety_name), + "{}_include".format(variety_name), + ) + python_import_lib_genrule = "" + + # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib + # See https://docs.python.org/3/extending/windows.html + if _is_windows(repository_ctx): + python_include = _normalize_path(python_include) + python_import_lib_name = _get_python_import_lib_name( + repository_ctx, + python_bin, + bin_path_key, + ) + python_import_lib_src = python_include.rsplit( + "/", + 1, + )[0] + "/libs/" + python_import_lib_name + python_import_lib_genrule = _symlink_genrule_for_dir( + repository_ctx, + None, + "", + "{}_import_lib".format(variety_name), + [python_import_lib_src], + [python_import_lib_name], + ) + _tpl( + repository_ctx, + "variety", + { + "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, + "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, + "%{VARIETY_NAME}": variety_name, + }, + out = "{}/BUILD".format(variety_name), + ) + +def _python_autoconf_impl(repository_ctx): + """Implementation of the python_autoconf repository rule.""" + _create_single_version_package( + repository_ctx, + "_python2", + _PYTHON2_BIN_PATH, + "python2", + _PYTHON2_LIB_PATH, + True + ) + _create_single_version_package( + repository_ctx, + "_python3", + _PYTHON3_BIN_PATH, + "python3", + _PYTHON3_LIB_PATH, + False + ) + _tpl(repository_ctx, "BUILD") + +python_configure = repository_rule( + implementation = _python_autoconf_impl, + environ = [ + _BAZEL_SH, + _PYTHON2_BIN_PATH, + _PYTHON2_LIB_PATH, + _PYTHON3_BIN_PATH, + _PYTHON3_LIB_PATH, + ], + attrs = { + "_build_tpl": attr.label( + default = Label("//third_party/py:BUILD.tpl"), + allow_single_file = True, + ), + "_variety_tpl": attr.label( + default = Label("//third_party/py:variety.tpl"), + allow_single_file = True, + ), + }, +) +"""Detects and configures the local Python. + +It is expected that the system have both a working Python 2 and python 3 +installation + +Add the following to your WORKSPACE FILE: + +```python +python_configure(name = "local_config_python") +``` + +Args: + name: A unique name for this workspace rule. +""" diff --git a/third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl b/third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl new file mode 100644 index 00000000..3b1c6a41 --- /dev/null +++ b/third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl @@ -0,0 +1,1718 @@ +# Copyright 2019 The Bazel Authors. All rights reserved. +# +# 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. + +"""A Starlark cc_toolchain configuration rule""" + +load( + "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", + "artifact_name_pattern", + "env_entry", + "env_set", + "feature", + "feature_set", + "flag_group", + "flag_set", + "make_variable", + "tool", + "tool_path", + "variable_with_value", + "with_feature_set", +) +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") + +all_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ACTION_NAMES.lto_backend, +] + +all_cpp_compile_actions = [ + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, +] + +preprocessor_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, +] + +codegen_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, +] + +all_link_actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, +] + +def _windows_msvc_impl(ctx): + toolchain_identifier = "msvc_x64" + host_system_name = "local" + target_system_name = "local" + target_cpu = "x64_windows" + target_libc = "msvcrt" + compiler = "msvc-cl" + abi_version = "local" + abi_libc_version = "local" + cc_target_os = None + builtin_sysroot = None + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w", + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt", + ] + + cpp_link_nodeps_dynamic_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library, + implies = [ + "nologo", + "shared_flag", + "linkstamps", + "output_execpath_flags", + "input_param_flags", + "user_link_flags", + "default_link_flags", + "linker_subsystem_flag", + "linker_param_file", + "msvc_env", + "no_stripping", + "has_configured_linker_path", + "def_file", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")], + ) + + cpp_link_static_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_static_library, + implies = [ + "nologo", + "archiver_flags", + "input_param_flags", + "linker_param_file", + "msvc_env", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/lib.exe")], + ) + + assemble_action = action_config( + action_name = ACTION_NAMES.assemble, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "nologo", + "msvc_env", + "sysroot", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe")], + ) + + preprocess_assemble_action = action_config( + action_name = ACTION_NAMES.preprocess_assemble, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "nologo", + "msvc_env", + "sysroot", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe")], + ) + + c_compile_action = action_config( + action_name = ACTION_NAMES.c_compile, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "default_compile_flags", + "nologo", + "msvc_env", + "parse_showincludes", + "user_compile_flags", + "sysroot", + "unfiltered_compile_flags", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")], + ) + + cpp_compile_action = action_config( + action_name = ACTION_NAMES.cpp_compile, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "default_compile_flags", + "nologo", + "msvc_env", + "parse_showincludes", + "user_compile_flags", + "sysroot", + "unfiltered_compile_flags", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")], + ) + + cpp_link_executable_action = action_config( + action_name = ACTION_NAMES.cpp_link_executable, + implies = [ + "nologo", + "linkstamps", + "output_execpath_flags", + "input_param_flags", + "user_link_flags", + "default_link_flags", + "linker_subsystem_flag", + "linker_param_file", + "msvc_env", + "no_stripping", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")], + ) + + cpp_link_dynamic_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_dynamic_library, + implies = [ + "nologo", + "shared_flag", + "linkstamps", + "output_execpath_flags", + "input_param_flags", + "user_link_flags", + "default_link_flags", + "linker_subsystem_flag", + "linker_param_file", + "msvc_env", + "no_stripping", + "has_configured_linker_path", + "def_file", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")], + ) + + action_configs = [ + assemble_action, + preprocess_assemble_action, + c_compile_action, + cpp_compile_action, + cpp_link_executable_action, + cpp_link_dynamic_library_action, + cpp_link_nodeps_dynamic_library_action, + cpp_link_static_library_action, + ] + + msvc_link_env_feature = feature( + name = "msvc_link_env", + env_sets = [ + env_set( + actions = all_link_actions + + [ACTION_NAMES.cpp_link_static_library], + env_entries = [env_entry(key = "LIB", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.10240.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\um\\x64;")], + ), + ], + ) + + shared_flag_feature = feature( + name = "shared_flag", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [flag_group(flags = ["/DLL"])], + ), + ], + ) + + determinism_feature = feature( + name = "determinism", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [ + flag_group( + flags = [ + "/wd4117", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + ], + ), + ], + ), + ], + ) + + sysroot_feature = feature( + name = "sysroot", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["--sysroot=%{sysroot}"], + iterate_over = "sysroot", + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flags = ["%{unfiltered_compile_flags}"], + iterate_over = "unfiltered_compile_flags", + expand_if_available = "unfiltered_compile_flags", + ), + ], + ), + ], + ) + + compiler_param_file_feature = feature( + name = "compiler_param_file", + ) + + copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary") + + input_param_flags_feature = feature( + name = "input_param_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["/IMPLIB:%{interface_library_output_path}"], + expand_if_available = "interface_library_output_path", + ), + ], + ), + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{libopts}"], + iterate_over = "libopts", + expand_if_available = "libopts", + ), + ], + ), + flag_set( + actions = all_link_actions + + [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group( + iterate_over = "libraries_to_link", + flag_groups = [ + flag_group( + iterate_over = "libraries_to_link.object_files", + flag_groups = [flag_group(flags = ["%{libraries_to_link.object_files}"])], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file_group", + ), + ), + flag_group( + flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file", + ), + ), + flag_group( + flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "interface_library", + ), + ), + flag_group( + flag_groups = [ + flag_group( + flags = ["%{libraries_to_link.name}"], + expand_if_false = "libraries_to_link.is_whole_archive", + ), + flag_group( + flags = ["/WHOLEARCHIVE:%{libraries_to_link.name}"], + expand_if_true = "libraries_to_link.is_whole_archive", + ), + ], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "static_library", + ), + ), + ], + expand_if_available = "libraries_to_link", + ), + ], + ), + ], + ) + + fastbuild_feature = feature( + name = "fastbuild", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Od", "/Z7"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/DEBUG:FASTLINK", "/INCREMENTAL:NO"], + ), + ], + ), + ], + implies = ["generate_pdb_file"], + ) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + archiver_flags_feature = feature( + name = "archiver_flags", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group( + flags = ["/OUT:%{output_execpath}"], + expand_if_available = "output_execpath", + ), + flag_group( + flags = ["/MACHINE:X64"], + ), + ], + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/MACHINE:X64"])], + ), + ], + ) + + static_link_msvcrt_feature = feature(name = "static_link_msvcrt") + + dynamic_link_msvcrt_debug_feature = feature( + name = "dynamic_link_msvcrt_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MDd"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])], + ), + ], + requires = [feature_set(features = ["dbg"])], + ) + + dbg_feature = feature( + name = "dbg", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Od", "/Z7"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/DEBUG:FULL", "/INCREMENTAL:NO"], + ), + ], + ), + ], + implies = ["generate_pdb_file"], + ) + + opt_feature = feature( + name = "opt", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/O2"])], + ), + ], + implies = ["frame_pointer"], + ) + + supports_interface_shared_libraries_feature = feature( + name = "supports_interface_shared_libraries", + enabled = True, + ) + + user_link_flags_feature = feature( + name = "user_link_flags", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{user_link_flags}"], + iterate_over = "user_link_flags", + expand_if_available = "user_link_flags", + ), + ], + ), + ], + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "/DCOMPILER_MSVC", + "/DNOMINMAX", + "/D_WIN32_WINNT=0x0601", + "/D_CRT_SECURE_NO_DEPRECATE", + "/D_CRT_SECURE_NO_WARNINGS", + "/bigobj", + "/Zm500", + "/EHsc", + "/wd4351", + "/wd4291", + "/wd4250", + "/wd4996", + ], + ), + ], + ), + ], + ) + + msvc_compile_env_feature = feature( + name = "msvc_compile_env", + env_sets = [ + env_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ], + env_entries = [env_entry(key = "INCLUDE", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt;")], + ), + ], + ) + + preprocessor_defines_feature = feature( + name = "preprocessor_defines", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group( + flags = ["/D%{preprocessor_defines}"], + iterate_over = "preprocessor_defines", + ), + ], + ), + ], + ) + + generate_pdb_file_feature = feature( + name = "generate_pdb_file", + requires = [ + feature_set(features = ["dbg"]), + feature_set(features = ["fastbuild"]), + ], + ) + + output_execpath_flags_feature = feature( + name = "output_execpath_flags", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/OUT:%{output_execpath}"], + expand_if_available = "output_execpath", + ), + ], + ), + ], + ) + + dynamic_link_msvcrt_no_debug_feature = feature( + name = "dynamic_link_msvcrt_no_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MD"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])], + ), + ], + requires = [ + feature_set(features = ["fastbuild"]), + feature_set(features = ["opt"]), + ], + ) + + disable_assertions_feature = feature( + name = "disable_assertions", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/DNDEBUG"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + has_configured_linker_path_feature = feature(name = "has_configured_linker_path") + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + no_stripping_feature = feature(name = "no_stripping") + + linker_param_file_feature = feature( + name = "linker_param_file", + flag_sets = [ + flag_set( + actions = all_link_actions + + [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group( + flags = ["@%{linker_param_file}"], + expand_if_available = "linker_param_file", + ), + ], + ), + ], + ) + + ignore_noisy_warnings_feature = feature( + name = "ignore_noisy_warnings", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = [flag_group(flags = ["/ignore:4221"])], + ), + ], + ) + + no_legacy_features_feature = feature(name = "no_legacy_features") + + parse_showincludes_feature = feature( + name = "parse_showincludes", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_header_parsing, + ], + flag_groups = [flag_group(flags = ["/showIncludes"])], + ), + ], + ) + + static_link_msvcrt_no_debug_feature = feature( + name = "static_link_msvcrt_no_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MT"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])], + ), + ], + requires = [ + feature_set(features = ["fastbuild"]), + feature_set(features = ["opt"]), + ], + ) + + treat_warnings_as_errors_feature = feature( + name = "treat_warnings_as_errors", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/WX"])], + ), + ], + ) + + windows_export_all_symbols_feature = feature(name = "windows_export_all_symbols") + + no_windows_export_all_symbols_feature = feature(name = "no_windows_export_all_symbols") + + include_paths_feature = feature( + name = "include_paths", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group( + flags = ["/I%{quote_include_paths}"], + iterate_over = "quote_include_paths", + ), + flag_group( + flags = ["/I%{include_paths}"], + iterate_over = "include_paths", + ), + flag_group( + flags = ["/I%{system_include_paths}"], + iterate_over = "system_include_paths", + ), + ], + ), + ], + ) + + linkstamps_feature = feature( + name = "linkstamps", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{linkstamp_paths}"], + iterate_over = "linkstamp_paths", + expand_if_available = "linkstamp_paths", + ), + ], + ), + ], + ) + + targets_windows_feature = feature( + name = "targets_windows", + enabled = True, + implies = ["copy_dynamic_libraries_to_binary"], + ) + + linker_subsystem_flag_feature = feature( + name = "linker_subsystem_flag", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/SUBSYSTEM:CONSOLE"])], + ), + ], + ) + + static_link_msvcrt_debug_feature = feature( + name = "static_link_msvcrt_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MTd"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])], + ), + ], + requires = [feature_set(features = ["dbg"])], + ) + + frame_pointer_feature = feature( + name = "frame_pointer", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Oy-"])], + ), + ], + ) + + compiler_output_flags_feature = feature( + name = "compiler_output_flags", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.assemble], + flag_groups = [ + flag_group( + flag_groups = [ + flag_group( + flags = ["/Fo%{output_file}", "/Zi"], + expand_if_available = "output_file", + expand_if_not_available = "output_assembly_file", + ), + ], + expand_if_not_available = "output_preprocess_file", + ), + ], + ), + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flag_groups = [ + flag_group( + flags = ["/Fo%{output_file}"], + expand_if_not_available = "output_preprocess_file", + ), + ], + expand_if_available = "output_file", + expand_if_not_available = "output_assembly_file", + ), + flag_group( + flag_groups = [ + flag_group( + flags = ["/Fa%{output_file}"], + expand_if_available = "output_assembly_file", + ), + ], + expand_if_available = "output_file", + ), + flag_group( + flag_groups = [ + flag_group( + flags = ["/P", "/Fi%{output_file}"], + expand_if_available = "output_preprocess_file", + ), + ], + expand_if_available = "output_file", + ), + ], + ), + ], + ) + + nologo_feature = feature( + name = "nologo", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + flag_groups = [flag_group(flags = ["/nologo"])], + ), + ], + ) + + smaller_binary_feature = feature( + name = "smaller_binary", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Gy", "/Gw"])], + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/OPT:ICF", "/OPT:REF"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + compiler_input_flags_feature = feature( + name = "compiler_input_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flags = ["/c", "%{source_file}"], + expand_if_available = "source_file", + ), + ], + ), + ], + ) + + def_file_feature = feature( + name = "def_file", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/DEF:%{def_file_path}", "/ignore:4070"], + expand_if_available = "def_file_path", + ), + ], + ), + ], + ) + + msvc_env_feature = feature( + name = "msvc_env", + env_sets = [ + env_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + env_entries = [ + env_entry(key = "PATH", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x64;C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x86;;C:\\Windows\\system32"), + env_entry(key = "TMP", value = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp"), + env_entry(key = "TEMP", value = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp"), + ], + ), + ], + implies = ["msvc_compile_env", "msvc_link_env"], + ) + + features = [ + no_legacy_features_feature, + nologo_feature, + has_configured_linker_path_feature, + no_stripping_feature, + targets_windows_feature, + copy_dynamic_libraries_to_binary_feature, + default_compile_flags_feature, + msvc_env_feature, + msvc_compile_env_feature, + msvc_link_env_feature, + include_paths_feature, + preprocessor_defines_feature, + parse_showincludes_feature, + generate_pdb_file_feature, + shared_flag_feature, + linkstamps_feature, + output_execpath_flags_feature, + archiver_flags_feature, + input_param_flags_feature, + linker_subsystem_flag_feature, + user_link_flags_feature, + default_link_flags_feature, + linker_param_file_feature, + static_link_msvcrt_feature, + static_link_msvcrt_no_debug_feature, + dynamic_link_msvcrt_no_debug_feature, + static_link_msvcrt_debug_feature, + dynamic_link_msvcrt_debug_feature, + dbg_feature, + fastbuild_feature, + opt_feature, + frame_pointer_feature, + disable_assertions_feature, + determinism_feature, + treat_warnings_as_errors_feature, + smaller_binary_feature, + ignore_noisy_warnings_feature, + user_compile_flags_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + compiler_param_file_feature, + compiler_output_flags_feature, + compiler_input_flags_feature, + def_file_feature, + windows_export_all_symbols_feature, + no_windows_export_all_symbols_feature, + supports_dynamic_linker_feature, + supports_interface_shared_libraries_feature, + ] + + artifact_name_patterns = [ + artifact_name_pattern( + category_name = "object_file", + prefix = "", + extension = ".obj", + ), + artifact_name_pattern( + category_name = "static_library", + prefix = "", + extension = ".lib", + ), + artifact_name_pattern( + category_name = "alwayslink_static_library", + prefix = "", + extension = ".lo.lib", + ), + artifact_name_pattern( + category_name = "executable", + prefix = "", + extension = ".exe", + ), + artifact_name_pattern( + category_name = "dynamic_library", + prefix = "", + extension = ".dll", + ), + artifact_name_pattern( + category_name = "interface_library", + prefix = "", + extension = ".if.lib", + ), + ] + + make_variables = [] + + tool_paths = [ + tool_path(name = "ar", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/lib.exe"), + tool_path(name = "ml", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe"), + tool_path(name = "cpp", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe"), + tool_path(name = "gcc", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe"), + tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"), + tool_path(name = "ld", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe"), + tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"), + tool_path( + name = "objcopy", + path = "wrapper/bin/msvc_nop.bat", + ), + tool_path( + name = "objdump", + path = "wrapper/bin/msvc_nop.bat", + ), + tool_path( + name = "strip", + path = "wrapper/bin/msvc_nop.bat", + ), + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = None, + ) + +def _windows_msys_mingw_impl(ctx): + toolchain_identifier = "msys_x64_mingw" + host_system_name = "local" + target_system_name = "local" + target_cpu = "x64_windows" + target_libc = "mingw" + compiler = "mingw-gcc" + abi_version = "local" + abi_libc_version = "local" + cc_target_os = None + builtin_sysroot = None + action_configs = [] + + targets_windows_feature = feature( + name = "targets_windows", + implies = ["copy_dynamic_libraries_to_binary"], + enabled = True, + ) + + copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary") + + gcc_env_feature = feature( + name = "gcc_env", + enabled = True, + env_sets = [ + env_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + env_entries = [ + env_entry(key = "PATH", value = "c:/tools/msys64/mingw64/bin"), + ], + ), + ], + ) + + msys_mingw_flags = [ + "-std=gnu++0x", + ] + msys_mingw_link_flags = [ + "-lstdc++", + ] + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + ), + flag_set( + actions = [ + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = msys_mingw_flags)] if msys_mingw_flags else []), + ), + ], + ) + + compiler_param_file_feature = feature( + name = "compiler_param_file", + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = ([flag_group(flags = msys_mingw_link_flags)] if msys_mingw_link_flags else []), + ), + ], + ) + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + features = [ + targets_windows_feature, + copy_dynamic_libraries_to_binary_feature, + gcc_env_feature, + default_compile_flags_feature, + compiler_param_file_feature, + default_link_flags_feature, + supports_dynamic_linker_feature, + ] + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w", + "c:/tools/msys64/mingw64/", + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt", + ] + + artifact_name_patterns = [ + artifact_name_pattern( + category_name = "executable", + prefix = "", + extension = ".exe", + ), + ] + + make_variables = [] + tool_paths = [ + tool_path(name = "ar", path = "c:/tools/msys64/mingw64/bin/ar"), + tool_path(name = "compat-ld", path = "c:/tools/msys64/mingw64/bin/ld"), + tool_path(name = "cpp", path = "c:/tools/msys64/mingw64/bin/cpp"), + tool_path(name = "dwp", path = "c:/tools/msys64/mingw64/bin/dwp"), + tool_path(name = "gcc", path = "c:/tools/msys64/mingw64/bin/gcc"), + tool_path(name = "gcov", path = "c:/tools/msys64/mingw64/bin/gcov"), + tool_path(name = "ld", path = "c:/tools/msys64/mingw64/bin/ld"), + tool_path(name = "nm", path = "c:/tools/msys64/mingw64/bin/nm"), + tool_path(name = "objcopy", path = "c:/tools/msys64/mingw64/bin/objcopy"), + tool_path(name = "objdump", path = "c:/tools/msys64/mingw64/bin/objdump"), + tool_path(name = "strip", path = "c:/tools/msys64/mingw64/bin/strip"), + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = cc_target_os, + ) + +def _armeabi_impl(ctx): + toolchain_identifier = "stub_armeabi-v7a" + host_system_name = "armeabi-v7a" + target_system_name = "armeabi-v7a" + target_cpu = "armeabi-v7a" + target_libc = "armeabi-v7a" + compiler = "compiler" + abi_version = "armeabi-v7a" + abi_libc_version = "armeabi-v7a" + cc_target_os = None + builtin_sysroot = None + action_configs = [] + + supports_pic_feature = feature(name = "supports_pic", enabled = True) + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + features = [supports_dynamic_linker_feature, supports_pic_feature] + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w", + ] + artifact_name_patterns = [] + make_variables = [] + + tool_paths = [ + tool_path(name = "ar", path = "/bin/false"), + tool_path(name = "compat-ld", path = "/bin/false"), + tool_path(name = "cpp", path = "/bin/false"), + tool_path(name = "dwp", path = "/bin/false"), + tool_path(name = "gcc", path = "/bin/false"), + tool_path(name = "gcov", path = "/bin/false"), + tool_path(name = "ld", path = "/bin/false"), + tool_path(name = "nm", path = "/bin/false"), + tool_path(name = "objcopy", path = "/bin/false"), + tool_path(name = "objdump", path = "/bin/false"), + tool_path(name = "strip", path = "/bin/false"), + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = cc_target_os, + ) + +def _impl(ctx): + if ctx.attr.cpu == "armeabi-v7a": + return _armeabi_impl(ctx) + elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "msvc-cl": + return _windows_msvc_impl(ctx) + elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "mingw-gcc": + return _windows_msys_mingw_impl(ctx) + + tool_paths = [ + tool_path(name = "ar", path = "c:/tools/msys64/usr/bin/ar"), + tool_path(name = "compat-ld", path = "c:/tools/msys64/usr/bin/ld"), + tool_path(name = "cpp", path = "c:/tools/msys64/usr/bin/cpp"), + tool_path(name = "dwp", path = "c:/tools/msys64/usr/bin/dwp"), + tool_path(name = "gcc", path = "c:/tools/msys64/usr/bin/gcc"), + tool_path(name = "gcov", path = "c:/tools/msys64/usr/bin/gcov"), + tool_path(name = "ld", path = "c:/tools/msys64/usr/bin/ld"), + tool_path(name = "nm", path = "c:/tools/msys64/usr/bin/nm"), + tool_path(name = "objcopy", path = "c:/tools/msys64/usr/bin/objcopy"), + tool_path(name = "objdump", path = "c:/tools/msys64/usr/bin/objdump"), + tool_path(name = "strip", path = "c:/tools/msys64/usr/bin/strip"), + ] + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w", + "c:/tools/msys64/usr/", + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt", + ] + + action_configs = [] + + compile_flags = [ + ] + + dbg_compile_flags = [ + ] + + opt_compile_flags = [ + ] + + cxx_flags = [ + "-std=gnu++0x", + ] + + link_flags = [ + "-lstdc++", + ] + + opt_link_flags = [ + ] + + unfiltered_compile_flags = [ + ] + + targets_windows_feature = feature( + name = "targets_windows", + implies = ["copy_dynamic_libraries_to_binary"], + enabled = True, + ) + + copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary") + + gcc_env_feature = feature( + name = "gcc_env", + enabled = True, + env_sets = [ + env_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + env_entries = [ + env_entry(key = "PATH", value = "c:/tools/msys64/usr/bin"), + ], + ), + ], + ) + + windows_features = [ + targets_windows_feature, + copy_dynamic_libraries_to_binary_feature, + gcc_env_feature, + ] + + supports_pic_feature = feature( + name = "supports_pic", + enabled = True, + ) + supports_start_end_lib_feature = feature( + name = "supports_start_end_lib", + enabled = True, + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = compile_flags)] if compile_flags else []), + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = dbg_compile_flags)] if dbg_compile_flags else []), + with_features = [with_feature_set(features = ["dbg"])], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = opt_compile_flags)] if opt_compile_flags else []), + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = [ + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = cxx_flags)] if cxx_flags else []), + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = ([flag_group(flags = link_flags)] if link_flags else []), + ), + flag_set( + actions = all_link_actions, + flag_groups = ([flag_group(flags = opt_link_flags)] if opt_link_flags else []), + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + dbg_feature = feature(name = "dbg") + + opt_feature = feature(name = "opt") + + sysroot_feature = feature( + name = "sysroot", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["--sysroot=%{sysroot}"], + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + fdo_optimize_feature = feature( + name = "fdo_optimize", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [ + flag_group( + flags = [ + "-fprofile-use=%{fdo_profile_path}", + "-fprofile-correction", + ], + expand_if_available = "fdo_profile_path", + ), + ], + ), + ], + provides = ["profile"], + ) + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = unfiltered_compile_flags)] if unfiltered_compile_flags else []), + ), + ], + ) + + features = windows_features + [ + supports_pic_feature, + default_compile_flags_feature, + default_link_flags_feature, + fdo_optimize_feature, + supports_dynamic_linker_feature, + dbg_feature, + opt_feature, + user_compile_flags_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + ] + + artifact_name_patterns = [ + artifact_name_pattern(category_name = "executable", prefix = "", extension = ".exe"), + ] + + make_variables = [] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = "msys_x64", + host_system_name = "local", + target_system_name = "local", + target_cpu = "x64_windows", + target_libc = "msys", + compiler = "msys-gcc", + abi_version = "local", + abi_libc_version = "local", + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = "", + cc_target_os = None, + ) + +cc_toolchain_config = rule( + implementation = _impl, + attrs = { + "cpu": attr.string(mandatory = True), + "compiler": attr.string(), + }, + provides = [CcToolchainConfigInfo], +) diff --git a/third_party/upb/bazel/build_defs.bzl b/third_party/upb/bazel/build_defs.bzl new file mode 100644 index 00000000..acd474d3 --- /dev/null +++ b/third_party/upb/bazel/build_defs.bzl @@ -0,0 +1,169 @@ +# 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. + +"""Internal rules for building upb.""" + +load(":upb_proto_library.bzl", "GeneratedSrcsInfo") + +UPB_DEFAULT_CPPOPTS = select({ + "//:windows": [], + "//conditions:default": [ + # copybara:strip_for_google3_begin + "-Wextra", + # "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang) + "-Werror", + "-Wno-long-long", + # copybara:strip_end + ], +}) + +UPB_DEFAULT_COPTS = select({ + "//:windows": [], + "//:fasttable_enabled_setting": ["-std=gnu99", "-DUPB_ENABLE_FASTTABLE"], + "//conditions:default": [ + # copybara:strip_for_google3_begin + "-std=c99", + "-pedantic", + "-Werror=pedantic", + "-Wall", + "-Wstrict-prototypes", + # GCC (at least) emits spurious warnings for this that cannot be fixed + # without introducing redundant initialization (with runtime cost): + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 + #"-Wno-maybe-uninitialized", + # copybara:strip_end + ], +}) + +def _librule(name): + return name + "_lib" + +runfiles_init = """\ +# --- begin runfiles.bash initialization v2 --- +# Copy-pasted from the Bazel Bash runfiles library v2. +set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v2 --- +""" + +def _get_real_short_path(file): + # For some reason, files from other archives have short paths that look like: + # ../com_google_protobuf/google/protobuf/descriptor.proto + short_path = file.short_path + if short_path.startswith("../"): + second_slash = short_path.index("/", 3) + short_path = short_path[second_slash + 1:] + return short_path + +def _get_real_root(file): + real_short_path = _get_real_short_path(file) + return file.path[:-len(real_short_path) - 1] + +def _get_real_roots(files): + roots = {} + for file in files: + real_root = _get_real_root(file) + if real_root: + roots[real_root] = True + return roots.keys() + +def _remove_prefix(str, prefix): + if not str.startswith(prefix): + fail("%s doesn't start with %s" % (str, prefix)) + return str[len(prefix):] + +def _remove_suffix(str, suffix): + if not str.endswith(suffix): + fail("%s doesn't end with %s" % (str, suffix)) + return str[:-len(suffix)] + +def make_shell_script(name, contents, out): + contents = runfiles_init + contents # copybara:strip_for_google3 + contents = contents.replace("$", "$$") + native.genrule( + name = "gen_" + name, + outs = [out], + cmd = "(cat <<'HEREDOC'\n%s\nHEREDOC\n) > $@" % contents, + ) + +# upb_amalgamation() rule, with file_list aspect. + +SrcList = provider( + fields = { + "srcs": "list of srcs", + }, +) + +def _file_list_aspect_impl(target, ctx): + if GeneratedSrcsInfo in target: + srcs = target[GeneratedSrcsInfo] + return [SrcList(srcs = srcs.srcs + srcs.hdrs)] + + srcs = [] + for src in ctx.rule.attr.srcs: + srcs += src.files.to_list() + for hdr in ctx.rule.attr.hdrs: + srcs += hdr.files.to_list() + for hdr in ctx.rule.attr.textual_hdrs: + srcs += hdr.files.to_list() + return [SrcList(srcs = srcs)] + +_file_list_aspect = aspect( + implementation = _file_list_aspect_impl, +) + +def _upb_amalgamation(ctx): + inputs = [] + for lib in ctx.attr.libs: + inputs += lib[SrcList].srcs + srcs = [src for src in inputs if src.path.endswith("c")] + ctx.actions.run( + inputs = inputs, + outputs = ctx.outputs.outs, + arguments = [ctx.bin_dir.path + "/", ctx.attr.prefix] + [f.path for f in srcs] + ["-I" + root for root in _get_real_roots(inputs)], + progress_message = "Making amalgamation", + executable = ctx.executable.amalgamator, + ) + return [] + +upb_amalgamation = rule( + attrs = { + "amalgamator": attr.label( + executable = True, + cfg = "host", + ), + "prefix": attr.string( + default = "", + ), + "libs": attr.label_list(aspects = [_file_list_aspect]), + "outs": attr.output_list(), + }, + implementation = _upb_amalgamation, +) diff --git a/third_party/upb/bazel/upb_proto_library.bzl b/third_party/upb/bazel/upb_proto_library.bzl new file mode 100644 index 00000000..cc02a9aa --- /dev/null +++ b/third_party/upb/bazel/upb_proto_library.bzl @@ -0,0 +1,385 @@ +# 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. + +"""Public rules for using upb protos: + - upb_proto_library() + - upb_proto_reflection_library() +""" + +load("@bazel_skylib//lib:paths.bzl", "paths") +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") +load("@rules_proto//proto:defs.bzl", "ProtoInfo") # copybara:strip_for_google3 + +# Generic support code ######################################################### + +_is_bazel = True # copybara:replace_for_google3 _is_bazel = False + +def _get_real_short_path(file): + # For some reason, files from other archives have short paths that look like: + # ../com_google_protobuf/google/protobuf/descriptor.proto + short_path = file.short_path + if short_path.startswith("../"): + second_slash = short_path.index("/", 3) + short_path = short_path[second_slash + 1:] + + # Sometimes it has another few prefixes like: + # _virtual_imports/any_proto/google/protobuf/any.proto + # benchmarks/_virtual_imports/100_msgs_proto/benchmarks/100_msgs.proto + # We want just google/protobuf/any.proto. + virtual_imports = "_virtual_imports/" + if virtual_imports in short_path: + short_path = short_path.split(virtual_imports)[1].split("/", 1)[1] + return short_path + +def _get_real_root(file): + real_short_path = _get_real_short_path(file) + return file.path[:-len(real_short_path) - 1] + +def _generate_output_file(ctx, src, extension): + real_short_path = _get_real_short_path(src) + real_short_path = paths.relativize(real_short_path, ctx.label.package) + output_filename = paths.replace_extension(real_short_path, extension) + ret = ctx.actions.declare_file(output_filename) + return ret + +def _filter_none(elems): + out = [] + for elem in elems: + if elem: + out.append(elem) + return out + +def _cc_library_func(ctx, name, hdrs, srcs, copts, dep_ccinfos): + """Like cc_library(), but callable from rules. + + Args: + ctx: Rule context. + name: Unique name used to generate output files. + hdrs: Public headers that can be #included from other rules. + srcs: C/C++ source files. + dep_ccinfos: CcInfo providers of dependencies we should build/link against. + + Returns: + CcInfo provider for this compilation. + """ + + compilation_contexts = [info.compilation_context for info in dep_ccinfos] + linking_contexts = [info.linking_context for info in dep_ccinfos] + toolchain = find_cpp_toolchain(ctx) + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) + + blaze_only_args = {} + + if not _is_bazel: + blaze_only_args["grep_includes"] = ctx.file._grep_includes + + (compilation_context, compilation_outputs) = cc_common.compile( + actions = ctx.actions, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + name = name, + srcs = srcs, + public_hdrs = hdrs, + user_compile_flags = copts, + compilation_contexts = compilation_contexts, + **blaze_only_args + ) + (linking_context, linking_outputs) = cc_common.create_linking_context_from_compilation_outputs( + actions = ctx.actions, + name = name, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + compilation_outputs = compilation_outputs, + linking_contexts = linking_contexts, + **blaze_only_args + ) + + return CcInfo( + compilation_context = compilation_context, + linking_context = linking_context, + ) + +# Build setting for whether fasttable code generation is enabled ############### + +_FastTableEnabled = provider( + fields = { + "enabled": "whether fasttable is enabled", + }, +) + +def fasttable_enabled_impl(ctx): + raw_setting = ctx.build_setting_value + + if raw_setting: + # TODO(haberman): check that the target CPU supports fasttable. + pass + + return _FastTableEnabled(enabled = raw_setting) + +upb_fasttable_enabled = rule( + implementation = fasttable_enabled_impl, + build_setting = config.bool(flag = True), +) + +# Dummy rule to expose select() copts to aspects ############################## + +_UpbProtoLibraryCopts = provider( + fields = { + "copts": "copts for upb_proto_library()", + }, +) + +def upb_proto_library_copts_impl(ctx): + return _UpbProtoLibraryCopts(copts = ctx.attr.copts) + +upb_proto_library_copts = rule( + implementation = upb_proto_library_copts_impl, + attrs = {"copts": attr.string_list(default = [])}, +) + +# upb_proto_library / upb_proto_reflection_library shared code ################# + +GeneratedSrcsInfo = provider( + fields = { + "srcs": "list of srcs", + "hdrs": "list of hdrs", + }, +) + +_UpbWrappedCcInfo = provider(fields = ["cc_info"]) +_UpbDefsWrappedCcInfo = provider(fields = ["cc_info"]) +_WrappedGeneratedSrcsInfo = provider(fields = ["srcs"]) +_WrappedDefsGeneratedSrcsInfo = provider(fields = ["srcs"]) + +def _compile_upb_protos(ctx, generator, proto_info, proto_sources): + if len(proto_sources) == 0: + return GeneratedSrcsInfo(srcs = [], hdrs = []) + + ext = "." + generator + tool = getattr(ctx.executable, "_gen_" + generator) + srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources] + hdrs = [_generate_output_file(ctx, name, ext + ".h") for name in proto_sources] + transitive_sets = proto_info.transitive_descriptor_sets.to_list() + fasttable_enabled = (hasattr(ctx.attr, "_fasttable_enabled") and + ctx.attr._fasttable_enabled[_FastTableEnabled].enabled) + codegen_params = "fasttable:" if fasttable_enabled else "" + ctx.actions.run( + inputs = depset( + direct = [proto_info.direct_descriptor_set], + transitive = [proto_info.transitive_descriptor_sets], + ), + tools = [tool], + outputs = srcs + hdrs, + executable = ctx.executable._protoc, + arguments = [ + "--" + generator + "_out=" + codegen_params + _get_real_root(srcs[0]), + "--plugin=protoc-gen-" + generator + "=" + tool.path, + "--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets]), + ] + + [_get_real_short_path(file) for file in proto_sources], + progress_message = "Generating upb protos for :" + ctx.label.name, + ) + return GeneratedSrcsInfo(srcs = srcs, hdrs = hdrs) + +def _upb_proto_rule_impl(ctx): + if len(ctx.attr.deps) != 1: + fail("only one deps dependency allowed.") + dep = ctx.attr.deps[0] + + if _WrappedDefsGeneratedSrcsInfo in dep: + srcs = dep[_WrappedDefsGeneratedSrcsInfo].srcs + elif _WrappedGeneratedSrcsInfo in dep: + srcs = dep[_WrappedGeneratedSrcsInfo].srcs + else: + fail("proto_library rule must generate _WrappedGeneratedSrcsInfo or " + + "_WrappedDefsGeneratedSrcsInfo (aspect should have handled this).") + + if _UpbDefsWrappedCcInfo in dep: + cc_info = dep[_UpbDefsWrappedCcInfo].cc_info + elif _UpbWrappedCcInfo in dep: + cc_info = dep[_UpbWrappedCcInfo].cc_info + else: + fail("proto_library rule must generate _UpbWrappedCcInfo or " + + "_UpbDefsWrappedCcInfo (aspect should have handled this).") + + lib = cc_info.linking_context.linker_inputs.to_list()[0].libraries[0] + files = _filter_none([ + lib.static_library, + lib.pic_static_library, + lib.dynamic_library, + ]) + return [ + DefaultInfo(files = depset(files + srcs.hdrs + srcs.srcs)), + srcs, + cc_info, + ] + +def _upb_proto_aspect_impl(target, ctx, generator, cc_provider, file_provider): + proto_info = target[ProtoInfo] + files = _compile_upb_protos(ctx, generator, proto_info, proto_info.direct_sources) + deps = ctx.rule.attr.deps + getattr(ctx.attr, "_" + generator) + dep_ccinfos = [dep[CcInfo] for dep in deps if CcInfo in dep] + dep_ccinfos += [dep[_UpbWrappedCcInfo].cc_info for dep in deps if _UpbWrappedCcInfo in dep] + dep_ccinfos += [dep[_UpbDefsWrappedCcInfo].cc_info for dep in deps if _UpbDefsWrappedCcInfo in dep] + if generator == "upbdefs": + if _UpbWrappedCcInfo not in target: + fail("Target should have _UpbDefsWrappedCcInfo provider") + dep_ccinfos += [target[_UpbWrappedCcInfo].cc_info] + cc_info = _cc_library_func( + ctx = ctx, + name = ctx.rule.attr.name + "." + generator, + hdrs = files.hdrs, + srcs = files.srcs, + copts = ctx.attr._copts[_UpbProtoLibraryCopts].copts, + dep_ccinfos = dep_ccinfos, + ) + return [cc_provider(cc_info = cc_info), file_provider(srcs = files)] + +def _upb_proto_library_aspect_impl(target, ctx): + return _upb_proto_aspect_impl(target, ctx, "upb", _UpbWrappedCcInfo, _WrappedGeneratedSrcsInfo) + +def _upb_proto_reflection_library_aspect_impl(target, ctx): + return _upb_proto_aspect_impl(target, ctx, "upbdefs", _UpbDefsWrappedCcInfo, _WrappedDefsGeneratedSrcsInfo) + +def _maybe_add(d): + if not _is_bazel: + d["_grep_includes"] = attr.label( + allow_single_file = True, + cfg = "host", + default = "//tools/cpp:grep-includes", + ) + return d + +# upb_proto_library() ########################################################## + +_upb_proto_library_aspect = aspect( + attrs = _maybe_add({ + "_copts": attr.label( + default = "//:upb_proto_library_copts__for_generated_code_only_do_not_use", + ), + "_gen_upb": attr.label( + executable = True, + cfg = "host", + default = "//upbc:protoc-gen-upb", + ), + "_protoc": attr.label( + executable = True, + cfg = "host", + default = "@com_google_protobuf//:protoc", + ), + "_cc_toolchain": attr.label( + default = "@bazel_tools//tools/cpp:current_cc_toolchain", + ), + "_upb": attr.label_list(default = [ + "//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + "//:upb", + ]), + "_fasttable_enabled": attr.label(default = "//:fasttable_enabled"), + }), + implementation = _upb_proto_library_aspect_impl, + provides = [ + _UpbWrappedCcInfo, + _WrappedGeneratedSrcsInfo, + ], + attr_aspects = ["deps"], + fragments = ["cpp"], + toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], + incompatible_use_toolchain_transition = True, +) + +upb_proto_library = rule( + output_to_genfiles = True, + implementation = _upb_proto_rule_impl, + attrs = { + "deps": attr.label_list( + aspects = [_upb_proto_library_aspect], + allow_rules = ["proto_library"], + providers = [ProtoInfo], + ), + }, +) + +# upb_proto_reflection_library() ############################################### + +_upb_proto_reflection_library_aspect = aspect( + attrs = _maybe_add({ + "_copts": attr.label( + default = "//:upb_proto_library_copts__for_generated_code_only_do_not_use", + ), + "_gen_upbdefs": attr.label( + executable = True, + cfg = "host", + default = "//upbc:protoc-gen-upbdefs", + ), + "_protoc": attr.label( + executable = True, + cfg = "host", + default = "@com_google_protobuf//:protoc", + ), + "_cc_toolchain": attr.label( + default = "@bazel_tools//tools/cpp:current_cc_toolchain", + ), + "_upbdefs": attr.label_list( + default = [ + "//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + "//:upb", + "//:reflection", + ], + ), + }), + implementation = _upb_proto_reflection_library_aspect_impl, + provides = [ + _UpbDefsWrappedCcInfo, + _WrappedDefsGeneratedSrcsInfo, + ], + required_aspect_providers = [ + _UpbWrappedCcInfo, + _WrappedGeneratedSrcsInfo, + ], + attr_aspects = ["deps"], + fragments = ["cpp"], + toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], + incompatible_use_toolchain_transition = True, +) + +upb_proto_reflection_library = rule( + output_to_genfiles = True, + implementation = _upb_proto_rule_impl, + attrs = { + "deps": attr.label_list( + aspects = [ + _upb_proto_library_aspect, + _upb_proto_reflection_library_aspect, + ], + allow_rules = ["proto_library"], + providers = [ProtoInfo], + ), + }, +) diff --git a/third_party/upb/bazel/workspace_deps.bzl b/third_party/upb/bazel/workspace_deps.bzl new file mode 100644 index 00000000..b2f94992 --- /dev/null +++ b/third_party/upb/bazel/workspace_deps.bzl @@ -0,0 +1,50 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +def upb_deps(): + maybe( + git_repository, + name = "com_google_absl", + commit = "998805a4c79d5d7a771f7e5a8ee3cbbbcba04f94", + remote = "https://github.com/abseil/abseil-cpp.git", + shallow_since = "1583355457 -0500", + ) + + maybe( + http_archive, + name = "com_google_protobuf", + sha256 = "cf63d46ef743f4c30b0e36a562caf83cabed3f10e6ca49eb476913c4655394d5", + strip_prefix = "protobuf-3.17.3", + urls = [ + "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz", + "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz", + ], + ) + + maybe( + http_archive, + name = "rules_python", + sha256 = "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6", + strip_prefix = "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz", + "https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz", + ], + ) + + maybe( + http_archive, + name = "bazel_skylib", + strip_prefix = "bazel-skylib-main", + urls = ["https://github.com/bazelbuild/bazel-skylib/archive/main.tar.gz"], + ) + + maybe( + http_archive, + name = "zlib", + build_file = "@com_google_protobuf//:third_party/zlib.BUILD", + sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff", + strip_prefix = "zlib-1.2.11", + url = "https://github.com/madler/zlib/archive/v1.2.11.tar.gz", + ) diff --git a/third_party/upb/benchmarks/build_defs.bzl b/third_party/upb/benchmarks/build_defs.bzl new file mode 100644 index 00000000..f95a09ed --- /dev/null +++ b/third_party/upb/benchmarks/build_defs.bzl @@ -0,0 +1,87 @@ +# 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. + +# copybara:insert_for_google3_begin +# load("//tools/build_defs/proto/cpp:cc_proto_library.bzl", _cc_proto_library="cc_proto_library") +# copybara:insert_end + +# copybara:strip_for_google3_begin +_cc_proto_library = native.cc_proto_library +# copybara:strip_end + +def proto_library(**kwargs): + native.proto_library( + # copybara:insert_for_google3_begin + # cc_api_version = 2, + # copybara:insert_end + **kwargs, + ) + +def tmpl_cc_binary(name, gen, args, replacements = [], **kwargs): + srcs = [name + ".cc"] + native.genrule( + name = name + "_gen_srcs", + tools = [gen], + outs = srcs, + cmd = "$(location " + gen + ") " + " ".join(args) + " > $@", + ) + + native.cc_binary( + # copybara:insert_for_google3_begin + # malloc="//base:system_malloc", + # features = ["-static_linking_mode"], + # copybara:insert_end + name = name, + srcs = srcs, + **kwargs, + ) + +def cc_optimizefor_proto_library(name, srcs, outs, optimize_for): + if len(srcs) != 1: + fail("Currently srcs must have exactly 1 element") + + native.genrule( + name = name + "_gen_proto", + srcs = srcs, + outs = outs, + cmd = "cp $< $@ && chmod a+w $@ && echo 'option optimize_for = " + optimize_for + ";' >> $@", + ) + + proto_library( + name = name + "_proto", + srcs = outs, + ) + + _cc_proto_library( + name = name, + deps = [":" + name + "_proto"], + ) + +def expand_suffixes(vals, suffixes): + ret = [] + for val in vals: + for suffix in suffixes: + ret.append(val + suffix) + return ret diff --git a/third_party/upb/cmake/build_defs.bzl b/third_party/upb/cmake/build_defs.bzl new file mode 100644 index 00000000..4a6264b7 --- /dev/null +++ b/third_party/upb/cmake/build_defs.bzl @@ -0,0 +1,68 @@ +# 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. + +def generated_file_staleness_test(name, outs, generated_pattern): + """Tests that checked-in file(s) match the contents of generated file(s). + + The resulting test will verify that all output files exist and have the + correct contents. If the test fails, it can be invoked with --fix to + bring the checked-in files up to date. + + Args: + name: Name of the rule. + outs: the checked-in files that are copied from generated files. + generated_pattern: the pattern for transforming each "out" file into a + generated file. For example, if generated_pattern="generated/%s" then + a file foo.txt will look for generated file generated/foo.txt. + """ + + script_name = name + ".py" + script_src = ":staleness_test.py" + + # Filter out non-existing rules so Blaze doesn't error out before we even + # run the test. + existing_outs = native.glob(include = outs) + + # The file list contains a few extra bits of information at the end. + # These get unpacked by the Config class in staleness_test_lib.py. + file_list = outs + [generated_pattern, native.package_name() or ".", name] + + native.genrule( + name = name + "_makescript", + outs = [script_name], + srcs = [script_src], + testonly = 1, + cmd = "cat $(location " + script_src + ") > $@; " + + "sed -i.bak -e 's|INSERT_FILE_LIST_HERE|" + "\\\n ".join(file_list) + "|' $@", + ) + + native.py_test( + name = name, + srcs = [script_name], + data = existing_outs + [generated_pattern % file for file in outs], + deps = [ + ":staleness_test_lib", + ], + ) diff --git a/third_party/upb/upb/bindings/lua/lua_proto_library.bzl b/third_party/upb/upb/bindings/lua/lua_proto_library.bzl new file mode 100644 index 00000000..fa20cf79 --- /dev/null +++ b/third_party/upb/upb/bindings/lua/lua_proto_library.bzl @@ -0,0 +1,135 @@ +# 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. + +load("@bazel_skylib//lib:paths.bzl", "paths") + +# Generic support code ######################################################### + +_is_bazel = not hasattr(native, "genmpm") + +def _get_real_short_path(file): + # For some reason, files from other archives have short paths that look like: + # ../com_google_protobuf/google/protobuf/descriptor.proto + short_path = file.short_path + if short_path.startswith("../"): + second_slash = short_path.index("/", 3) + short_path = short_path[second_slash + 1:] + + # Sometimes it has another few prefixes like: + # _virtual_imports/any_proto/google/protobuf/any.proto + # We want just google/protobuf/any.proto. + if short_path.startswith("_virtual_imports"): + short_path = short_path.split("/", 2)[-1] + return short_path + +def _get_real_root(file): + real_short_path = _get_real_short_path(file) + return file.path[:-len(real_short_path) - 1] + +def _generate_output_file(ctx, src, extension): + real_short_path = _get_real_short_path(src) + real_short_path = paths.relativize(real_short_path, ctx.label.package) + output_filename = paths.replace_extension(real_short_path, extension) + ret = ctx.actions.declare_file(output_filename) + return ret + +# upb_proto_library / upb_proto_reflection_library shared code ################# + +_LuaFiles = provider(fields = ["files"]) + +def _compile_upb_protos(ctx, proto_info, proto_sources): + files = [_generate_output_file(ctx, name, "_pb.lua") for name in proto_sources] + transitive_sets = proto_info.transitive_descriptor_sets.to_list() + ctx.actions.run( + inputs = depset( + direct = [proto_info.direct_descriptor_set], + transitive = [proto_info.transitive_descriptor_sets], + ), + tools = [ctx.executable._upbc], + outputs = files, + executable = ctx.executable._protoc, + arguments = [ + "--lua_out=" + _get_real_root(files[0]), + "--plugin=protoc-gen-lua=" + ctx.executable._upbc.path, + "--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets]), + ] + + [_get_real_short_path(file) for file in proto_sources], + progress_message = "Generating Lua protos for :" + ctx.label.name, + ) + return files + +def _lua_proto_rule_impl(ctx): + if len(ctx.attr.deps) != 1: + fail("only one deps dependency allowed.") + dep = ctx.attr.deps[0] + if _LuaFiles not in dep: + fail("proto_library rule must generate _LuaFiles (aspect should have handled this).") + files = dep[_LuaFiles].files + return [ + DefaultInfo( + files = files, + data_runfiles = ctx.runfiles(files = files.to_list()), + ), + ] + +def _lua_proto_library_aspect_impl(target, ctx): + proto_info = target[ProtoInfo] + files = _compile_upb_protos(ctx, proto_info, proto_info.direct_sources) + deps = ctx.rule.attr.deps + transitive = [dep[_LuaFiles].files for dep in deps if _LuaFiles in dep] + return [_LuaFiles(files = depset(direct = files, transitive = transitive))] + +# lua_proto_library() ########################################################## + +_lua_proto_library_aspect = aspect( + attrs = { + "_upbc": attr.label( + executable = True, + cfg = "host", + default = "//upb/bindings/lua:protoc-gen-lua", + ), + "_protoc": attr.label( + executable = True, + cfg = "host", + default = "@com_google_protobuf//:protoc", + ), + }, + implementation = _lua_proto_library_aspect_impl, + provides = [_LuaFiles], + attr_aspects = ["deps"], + fragments = ["cpp"], +) + +lua_proto_library = rule( + output_to_genfiles = True, + implementation = _lua_proto_rule_impl, + attrs = { + "deps": attr.label_list( + aspects = [_lua_proto_library_aspect], + allow_rules = ["proto_library"], + providers = [ProtoInfo], + ), + }, +) diff --git a/tools/distrib/python/grpcio_tools/grpcio_tools.bzl b/tools/distrib/python/grpcio_tools/grpcio_tools.bzl new file mode 100644 index 00000000..603556c9 --- /dev/null +++ b/tools/distrib/python/grpcio_tools/grpcio_tools.bzl @@ -0,0 +1,94 @@ +# 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. + +def _generate_copied_files_impl(ctx): + srcs = ctx.attr.srcs[0] + strip_prefix = ctx.attr.strip_prefix + dest = ctx.attr.dest + + outs = [] + for f in srcs.files.to_list(): + destination_path = f.path + if f.path.startswith("external"): + external_separator = f.path.find("/") + repository_separator = f.path.find("/", external_separator + 1) + destination_path = f.path[repository_separator + 1:] + if not destination_path.startswith(strip_prefix): + fail("File '{}' did not start with '{}'.".format( + destination_path, + strip_prefix, + )) + destination_path = dest + destination_path[len(strip_prefix):] + destination_dir = destination_path.rfind("/") + out_file = ctx.actions.declare_file(destination_path) + outs.append(out_file) + ctx.actions.run_shell( + inputs = [f], + outputs = [out_file], + command = "mkdir -p {0} && cp {1} {2}".format( + out_file.dirname, + f.path, + out_file.path, + ), + ) + + return [DefaultInfo(files = depset(direct = outs))] + +_generate_copied_files = rule( + attrs = { + "srcs": attr.label_list( + mandatory = True, + allow_empty = False, + ), + "strip_prefix": attr.string( + default = "", + ), + "dest": attr.string( + mandatory = True, + ), + }, + implementation = _generate_copied_files_impl, +) + +def internal_copied_filegroup(name, srcs, strip_prefix, dest): + """Copies a file group to the current package. + + Useful for using an existing filegroup as a data dependency. + + Args: + name: The name of the rule. + srcs: A single filegroup. + strip_prefix: An optional string to strip from the beginning + of the path of each file in the filegroup. Must end in a slash. + dest: The directory in which to put the files, relative to the + current package. Must end in a slash. + """ + if len(srcs) != 1: + fail("srcs must be a single filegroup.") + + if not dest.endswith("/"): + fail("dest must end with a '/' character.") + + _symlink_target = name + "_symlink" + _generate_copied_files( + name = _symlink_target, + srcs = srcs, + strip_prefix = strip_prefix, + dest = dest, + ) + + native.filegroup( + name = name, + srcs = [":" + _symlink_target], + )