diff --git a/bazel/BUILD b/bazel/BUILD index aa6cb341dfe..3fe42fc7e7d 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Contains build targets used by Starlark files in the bazel/ directory. +""" + licenses(["notice"]) package(default_visibility = ["//:__subpackages__"]) -load(":cc_grpc_library.bzl", "cc_grpc_library") - filegroup( name = "_gevent_test_main", srcs = ["_gevent_test_main.py"], diff --git a/bazel/copts.bzl b/bazel/copts.bzl index 64c16cdd8bd..52bee89ed30 100644 --- a/bazel/copts.bzl +++ b/bazel/copts.bzl @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Includes default copts. +""" + # This is a list of llvm flags to be used when being built with use_strict_warning=1 GRPC_LLVM_WARNING_FLAGS = [ # Enable all & extra warnings diff --git a/bazel/custom_exec_properties.bzl b/bazel/custom_exec_properties.bzl index 6605f5cc403..514e120b6ab 100644 --- a/bazel/custom_exec_properties.bzl +++ b/bazel/custom_exec_properties.bzl @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Reimports constants from the grpc_custom_exec_properties repo. +""" + load("@grpc_custom_exec_properties//:constants.bzl", _LARGE_MACHINE = "LARGE_MACHINE") LARGE_MACHINE = _LARGE_MACHINE diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl index b419e13a4e2..bd1d5457996 100644 --- a/bazel/generate_cc.bzl +++ b/bazel/generate_cc.bzl @@ -54,7 +54,13 @@ def _join_directories(directories): return "/".join(massaged_directories) def generate_cc_impl(ctx): - """Implementation of the generate_cc rule.""" + """Implementation of the generate_cc rule. + + Args: + ctx: The context object. + Returns: + The provider for the generated files. + """ protos = [f for src in ctx.attr.srcs for f in src[ProtoInfo].check_deps_sources.to_list()] includes = [ f @@ -118,7 +124,7 @@ def generate_cc_impl(ctx): ) tools = [ctx.executable.plugin] else: - arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] + arguments.append("--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out) tools = [] arguments += [ @@ -128,7 +134,7 @@ def generate_cc_impl(ctx): # 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.append("--proto_path={0}{1}".format(dir_out, proto_root)) arguments += [_get_srcs_file_path(proto) for proto in protos] # create a list of well known proto files if the argument is non-None @@ -138,11 +144,11 @@ def generate_cc_impl(ctx): if f != "external/com_google_protobuf/src/google/protobuf": print( "Error: Only @com_google_protobuf//:well_known_protos is supported", - ) + ) # buildifier: disable=print else: # f points to "external/com_google_protobuf/src/google/protobuf" # add -I argument to protoc so it knows where to look for the proto files. - arguments += ["-I{0}".format(f + "/../..")] + arguments.append("-I{0}".format(f + "/../..")) well_known_proto_files = [ f for f in ctx.attr.well_known_protos.files.to_list() @@ -157,7 +163,7 @@ def generate_cc_impl(ctx): use_default_shell_env = True, ) - return struct(files = depset(out_files)) + return struct(files = depset(out_files)) # buildifier: disable=rule-impl-return _generate_cc = rule( attrs = { diff --git a/bazel/generate_objc.bzl b/bazel/generate_objc.bzl index f6424b383fb..b0e92114808 100644 --- a/bazel/generate_objc.bzl +++ b/bazel/generate_objc.bzl @@ -11,6 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +""" +This module contains build rules relating to gRPC Objective-C. +""" + load("@rules_proto//proto:defs.bzl", "ProtoInfo") load( "//bazel:protobuf.bzl", @@ -44,13 +49,13 @@ def _generate_objc_impl(ctx): 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)] + outs.append(_get_output_file_name_from_proto(proto, _PROTO_HEADER_FMT)) + outs.append(_get_output_file_name_from_proto(proto, _PROTO_SRC_FMT)) file_path = _get_full_path_from_file(proto) if file_path in files_with_rpc: - outs += [_get_output_file_name_from_proto(proto, _GRPC_PROTO_HEADER_FMT)] - outs += [_get_output_file_name_from_proto(proto, _GRPC_PROTO_SRC_FMT)] + outs.append(_get_output_file_name_from_proto(proto, _GRPC_PROTO_HEADER_FMT)) + outs.append(_get_output_file_name_from_proto(proto, _GRPC_PROTO_SRC_FMT)) out_files = [ctx.actions.declare_file(out) for out in outs] dir_out = _join_directories([ @@ -60,6 +65,7 @@ def _generate_objc_impl(ctx): ]) arguments = [] + tools = [] if ctx.executable.plugin: arguments += get_plugin_args( ctx.executable.plugin, @@ -68,9 +74,9 @@ def _generate_objc_impl(ctx): False, ) tools = [ctx.executable.plugin] - arguments += ["--objc_out=" + dir_out] + arguments.append("--objc_out=" + dir_out) - arguments += ["--proto_path=."] + arguments.append("--proto_path=.") arguments += [ "--proto_path={}".format(get_include_directory(i)) for i in protos @@ -78,7 +84,7 @@ def _generate_objc_impl(ctx): # Include the output directory so that protoc puts the generated code in the # right directory. - arguments += ["--proto_path={}".format(dir_out)] + arguments.append("--proto_path={}".format(dir_out)) arguments += ["--proto_path={}".format(_get_directory_from_proto(proto)) for proto in protos] arguments += [_get_full_path_from_file(proto) for proto in protos] @@ -88,7 +94,7 @@ def _generate_objc_impl(ctx): 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 + "/../..")] + arguments.append("-I{0}".format(f + "/../..")) well_known_proto_files = ctx.attr.well_known_protos.files.to_list() ctx.actions.run( inputs = protos + well_known_proto_files, @@ -98,7 +104,7 @@ def _generate_objc_impl(ctx): arguments = arguments, ) - return struct(files = depset(out_files)) + return struct(files = depset(out_files)) # buildifier: disable=rule-impl-return def _label_to_full_file_path(src, package): if not src.startswith("//"): @@ -198,7 +204,7 @@ def _group_objc_files_impl(ctx): for file in ctx.attr.src.files.to_list() if file.basename.endswith(suffix) ] - return struct(files = depset(out_files)) + return struct(files = depset(out_files)) # buildifier: disable=rule-impl-return generate_objc_hdrs = rule( attrs = { diff --git a/bazel/gevent_test.bzl b/bazel/gevent_test.bzl index 55444d32195..9be3ae003eb 100644 --- a/bazel/gevent_test.bzl +++ b/bazel/gevent_test.bzl @@ -11,6 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +""" +Houses py_grpc_gevent_test. +""" + load("@grpc_python_dependencies//:requirements.bzl", "requirement") _GRPC_LIB = "//src/python/grpcio/grpc:grpcio" @@ -24,6 +29,16 @@ def py_grpc_gevent_test( deps = None, data = None, **kwargs): + """Runs a Python test with gevent monkeypatched in. + + Args: + name: The name of the test. + srcs: The source files. + main: The main file of the test. + deps: The dependencies of the test. + data: The data dependencies of the test. + **kwargs: Any other test arguments. + """ if main == None: if len(srcs) != 1: fail("When main is not provided, srcs must be of size 1.") diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index bd404267e12..1cc4579590f 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -23,6 +23,10 @@ # each change must be ported from one to the other. # +""" +Contains macros used throughout the repo. +""" + load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") load("//bazel:copts.bzl", "GRPC_DEFAULT_COPTS") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library", "upb_proto_reflection_library") @@ -48,20 +52,20 @@ def _get_external_deps(external_deps): ret = [] for dep in external_deps: if dep == "address_sorting": - ret += ["//third_party/address_sorting"] + ret.append("//third_party/address_sorting") elif dep == "xxhash": - ret += ["//third_party/xxhash"] + ret.append("//third_party/xxhash") elif dep == "cares": ret += select({ "//:grpc_no_ares": [], "//conditions:default": ["//external:cares"], }) elif dep == "cronet_c_for_grpc": - ret += ["//third_party/objective_c/Cronet:cronet_c_for_grpc"] + ret.append("//third_party/objective_c/Cronet:cronet_c_for_grpc") elif dep.startswith("absl/"): - ret += ["@com_google_absl//" + dep] + ret.append("@com_google_absl//" + dep) else: - ret += ["//external:" + dep] + ret.append("//external:" + dep) return ret def _update_visibility(visibility): @@ -120,6 +124,27 @@ def grpc_cc_library( use_cfstream = False, tags = [], linkstatic = False): + """An internal wrapper around cc_library. + + Args: + name: The name of the library. + srcs: The source files. + public_hdrs: The public headers. + hdrs: The headers. + external_deps: External depdendencies to be resolved. + defines: Build defines to use. + deps: cc_library deps. + select_deps: deps included conditionally. + standalone: Unused. + language: The language of the library, e.g. C, C++. + testonly: Whether the target is for tests only. + visibility: The visibility of the target. + alwayslink: Whether to enable alwayslink on the cc_library. + data: Data dependencies. + use_cfstream: Whether to use cfstream. + tags: Tags to apply to the rule. + linkstatic: Whether to enable linkstatic on the cc_library. + """ visibility = _update_visibility(visibility) copts = [] if use_cfstream: @@ -197,6 +222,13 @@ def ios_cc_test( name, tags = [], **kwargs): + """An ios C++ test target. + + Args: + name: The name of the test. + tags: The tags to apply to the test. + **kwargs: All other arguments to apply. + """ ios_test_adapter = "//third_party/objective_c/google_toolbox_for_mac:GTM_GoogleTestRunner_GTM_USING_XCTEST" test_lib_ios = name + "_test_lib_ios" @@ -221,6 +253,28 @@ def ios_cc_test( ) 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 = []): + """A cc_test target for use in the gRPC repo. + + Args: + name: The name of the test. + srcs: The source files. + deps: The target deps. + external_deps: The external deps. + args: The args to supply to the test binary. + data: Data dependencies. + uses_polling: Whether the test uses polling. + language: The language of the test, e.g C, C++. + size: The size of the test. + timeout: The test timeout. + tags: The tags for the test. + exec_compatible_with: A list of constraint values that must be + satisifed for the platform. + exec_properties: A dictionary of strings that will be added to the + exec_properties of a platform selected for this target. + shard_count: The number of shards for this test. + flaky: Whether this test is flaky. + copts: Add these to the compiler invocation. + """ copts = copts + if_mac(["-DGRPC_CFSTREAM"]) if language.upper() == "C": copts = copts + if_not_windows(["-std=c99"]) @@ -283,6 +337,22 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data ) def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = [], features = []): + """Generates a cc_binary for use in the gRPC repo. + + Args: + name: The name of the target. + srcs: The source files. + deps: The dependencies. + external_deps: The external dependencies. + args: The arguments to supply to the binary. + data: The data dependencies. + language: The language of the binary, e.g. C, C++. + testonly: Whether the binary is for tests only. + linkshared: Enables linkshared on the binary. + linkopts: linkopts to supply to the cc_binary. + tags: Tags to apply to the target. + features: features to be supplied to the cc_binary. + """ copts = [] if language.upper() == "C": copts = ["-std=c99"] @@ -300,6 +370,7 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da features = features, ) +# buildifier: disable=unnamed-macro def grpc_generate_one_off_targets(): # In open-source, grpc_objc* libraries depend directly on //:grpc native.alias( @@ -345,6 +416,13 @@ def grpc_py_binary( ) def grpc_package(name, visibility = "private", features = []): + """Creates a package. + + Args: + name: The name of the target + visibility: The visibility of the target. + features: The features to enable. + """ if visibility == "tests": visibility = ["//test:__subpackages__"] elif visibility == "public": @@ -355,6 +433,7 @@ def grpc_package(name, visibility = "private", features = []): fail("Unknown visibility " + visibility) if len(visibility) != 0: + # buildifier: disable=native-package native.package( default_visibility = visibility, features = features, @@ -402,6 +481,7 @@ def grpc_upb_proto_library(name, deps): def grpc_upb_proto_reflection_library(name, deps): upb_proto_reflection_library(name = name, deps = deps) +# buildifier: disable=unnamed-macro def python_config_settings(): native.config_setting( name = "python3", diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index b089c853592..183edf28095 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -16,6 +16,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") +# buildifier: disable=unnamed-macro def grpc_deps(): """Loads dependencies need to compile and test the grpc library.""" @@ -447,9 +448,12 @@ def grpc_deps(): grpc_python_deps() # TODO: move some dependencies from "grpc_deps" here? +# buildifier: disable=unnamed-macro def grpc_test_only_deps(): """Internal, not intended for use by packages that are consuming grpc. - Loads dependencies that are only needed to run grpc library's tests.""" + + Loads dependencies that are only needed to run grpc library's tests. + """ native.bind( name = "twisted", actual = "@com_github_twisted_twisted//:twisted", diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl index ec171927eb8..c2cf0027a48 100644 --- a/bazel/grpc_extra_deps.bzl +++ b/bazel/grpc_extra_deps.bzl @@ -39,6 +39,10 @@ def grpc_extra_deps(ignore_version_differences = False): grpc_extra_deps() ``` + + Args: + ignore_version_differences: Plumbed directly to the invocation of + apple_rules_dependencies. """ protobuf_deps() diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index bbbaa2a1bb9..e52fafd16d3 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -16,7 +16,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@com_github_grpc_grpc//third_party/py:python_configure.bzl", "python_configure") +# buildifier: disable=unnamed-macro def grpc_python_deps(): + """Loads dependencies for gRPC Python.""" + # 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. diff --git a/bazel/grpc_util.bzl b/bazel/grpc_util.bzl index b85d9af264f..42278558f8e 100644 --- a/bazel/grpc_util.bzl +++ b/bazel/grpc_util.bzl @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # Follows convention set in objectivec_helpers.cc in the protobuf ObjC compiler. + +""" +Contains generic helper utilities. +""" + _upper_segments_list = ["url", "http", "https"] def strip_extension(str): @@ -24,6 +29,14 @@ def capitalize(word): return word.capitalize() def lower_underscore_to_upper_camel(str): + """Converts from lower underscore case to upper camel case. + + Args: + str: The snake case string to convert. + + Returns: + The title case version of str. + """ str = strip_extension(str) camel_case_str = "" word = "" diff --git a/bazel/internal_python_rules.bzl b/bazel/internal_python_rules.bzl index 6f3c8751b0d..c7c81727ce4 100644 --- a/bazel/internal_python_rules.bzl +++ b/bazel/internal_python_rules.bzl @@ -17,7 +17,12 @@ 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.""" + """Runs a test under all supported environments. + + Args: + name: The name of the test. + **kwargs: Any additional arguments to add to the test. + """ py2and3_test(name, **kwargs) py_grpc_gevent_test(name, **kwargs) diff --git a/bazel/objc_grpc_library.bzl b/bazel/objc_grpc_library.bzl index bfc04d11c8e..dbe07b1811d 100644 --- a/bazel/objc_grpc_library.bzl +++ b/bazel/objc_grpc_library.bzl @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +""" +Contains the objc_grpc_library rule. +""" + load( "//bazel:generate_objc.bzl", "generate_objc", @@ -18,7 +22,6 @@ load( "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 diff --git a/bazel/protobuf.bzl b/bazel/protobuf.bzl index d8d18ea8e16..aeacfba8da6 100644 --- a/bazel/protobuf.bzl +++ b/bazel/protobuf.bzl @@ -76,9 +76,10 @@ def proto_path_to_generated_filename(proto_path, fmt_str): 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. + """Returns the include directory path for the source_file. + + All of the include statements within the given source_file are calculated + relative to the directory returned by this method. The returned directory path can be used as the "--proto_path=" argument value. @@ -195,7 +196,15 @@ def includes_from_deps(deps): ] def get_proto_arguments(protos, genfiles_dir_path): - """Get the protoc arguments specifying which protos to compile.""" + """Get the protoc arguments specifying which protos to compile. + + Args: + protos: The protob files to supply. + genfiles_dir_path: The path to the genfiles directory. + + Returns: + The arguments to supply to protoc. + """ arguments = [] for proto in protos: strip_prefix_len = 0 @@ -211,7 +220,18 @@ def get_proto_arguments(protos, genfiles_dir_path): return arguments def declare_out_files(protos, context, generated_file_format): - """Declares and returns the files to be generated.""" + """Declares and returns the files to be generated. + + Args: + protos: A list of files. The protos to declare. + context: The context object. + generated_file_format: A format string. Will be passed to + proto_path_to_generated_filename to generate the filename of each + generated file. + + Returns: + A list of file providers. + """ out_file_paths = [] for proto in protos: @@ -232,8 +252,9 @@ def declare_out_files(protos, context, generated_file_format): ] def get_out_dir(protos, context): - """ Returns the calculated value for --_out= protoc argument based on - the input source proto files and current context. + """Returns the value to supply to the --_out= protoc flag. + + The result is based on the input source proto files and current context. Args: protos: A list of protos to be used as source files in protoc command @@ -264,10 +285,11 @@ def get_out_dir(protos, context): 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. + """Determines if source_file is virtual. + + A file is virtual if placed in the _virtual_imports subdirectory. The + output of all proto_library targets which use import_prefix and/or + strip_import_prefix arguments is placed under _virtual_imports directory. Args: source_file: A proto file. diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index b38672eaa25..fa63d4a2dc3 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -195,7 +195,7 @@ def _generate_pb2_grpc_src_impl(context): "--proto_path={}".format(get_include_directory(i)) for i in includes ] - arguments += ["--proto_path={}".format(context.genfiles_dir.path)] + arguments.append("--proto_path={}".format(context.genfiles_dir.path)) arguments += get_proto_arguments(protos, context.genfiles_dir.path) context.actions.run( diff --git a/examples/objective-c/BUILD b/examples/objective-c/BUILD index 2d9861b0e8d..422f851c912 100644 --- a/examples/objective-c/BUILD +++ b/examples/objective-c/BUILD @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - load("@com_github_grpc_grpc//bazel:objc_grpc_library.bzl", "objc_grpc_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application") +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + objc_grpc_library( name = "HelloWorld_grpc_proto", srcs = ["//examples/protos:helloworld.proto"], @@ -98,8 +98,7 @@ objc_library( data = glob([ "route_guide/Misc/Base.lproj/**", "route_guide/Misc/Images.xcassets/**", - "route_guide/route_guide_db.json", - ]), + ]) + ["route_guide/route_guide_db.json"], includes = ["route_guide/Misc"], tags = ["manual"], deps = [":RouteGuide"], diff --git a/examples/protos/BUILD b/examples/protos/BUILD index 911c868cf20..929cad93a6e 100644 --- a/examples/protos/BUILD +++ b/examples/protos/BUILD @@ -12,16 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") load("//bazel:grpc_build_system.bzl", "grpc_proto_library") load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library") +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + grpc_proto_library( name = "auth_sample", srcs = ["auth_sample.proto"], diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 0426cf0b943..1c23a390512 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library") diff --git a/examples/python/data_transmission/BUILD b/examples/python/data_transmission/BUILD index eaf2c109fe1..c8c4134eaac 100644 --- a/examples/python/data_transmission/BUILD +++ b/examples/python/data_transmission/BUILD @@ -14,8 +14,6 @@ licenses(["notice"]) -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - py_binary( name = "alts_server", srcs = [ diff --git a/examples/python/debug/BUILD.bazel b/examples/python/debug/BUILD.bazel index 9cc8e1672f6..680fad26bfc 100644 --- a/examples/python/debug/BUILD.bazel +++ b/examples/python/debug/BUILD.bazel @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - package(default_testonly = 1) py_binary( diff --git a/examples/python/wait_for_ready/BUILD.bazel b/examples/python/wait_for_ready/BUILD.bazel index e783af88dce..e36d05dee9e 100644 --- a/examples/python/wait_for_ready/BUILD.bazel +++ b/examples/python/wait_for_ready/BUILD.bazel @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - package(default_testonly = 1) py_binary( diff --git a/grpc.bzl b/grpc.bzl index 06de3bca99e..5eb25dc0a32 100644 --- a/grpc.bzl +++ b/grpc.bzl @@ -23,7 +23,7 @@ This file declares two macros: def _lower_underscore_to_upper_camel(str): humps = [] for hump in str.split("_"): - humps += [hump[0].upper() + hump[1:]] + humps.append(hump[0].upper() + hump[1:]) return "".join(humps) def _file_to_upper_camel(src): @@ -37,8 +37,9 @@ def _file_with_extension(src, ext): 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. + """Returns a CLI command to invoke protoc. + + Uses the given sources and flags. Suitable for use in a genrule. """ protoc_command = "$(location //external:protoc) -I . " srcs_params = "" @@ -47,15 +48,22 @@ def _protoc_invocation(srcs, flags): 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. + """Declares an objc_library for the code generated by protoc. + + Uses the given proto sources. This generated code doesn't include proto + services. + + Args: + name: The name of the library. + srcs: A list of .proto file sources. + visibility: The visibility label to apply to the target. """ 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")] + h_files.append(_file_with_extension(src, ".pbobjc.h")) + m_files.append(_file_with_extension(src, ".pbobjc.m")) protoc_flags = "--objc_out=$(GENDIR)" @@ -75,9 +83,15 @@ def objc_proto_library(name, srcs, visibility = None): ) 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. + """Declares an objc_library for the code generated by the gRPC ObjC plugin. + + The generated code does not include the services of the files in other_messages. + + Args: + name: The name of the library. + services: The .proto files from which to generate the library. + other_messages: A list of .proto files containing messages needed for the library. + visibility: The visibility label to apply to the library. """ objc_proto_library(name + "_messages", services + other_messages) @@ -85,8 +99,8 @@ def objc_grpc_library(name, services, other_messages, visibility = None): 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")] + h_files.append(_file_with_extension(src, ".pbrpc.h")) + m_files.append(_file_with_extension(src, ".pbrpc.m")) protoc_flags = ("--grpc_out=$(GENDIR) --plugin=" + "protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)") diff --git a/src/compiler/BUILD b/src/compiler/BUILD index c11616dc74a..ad40a828e86 100644 --- a/src/compiler/BUILD +++ b/src/compiler/BUILD @@ -14,9 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - -exports_files(["LICENSE"]) +load( + "//bazel:grpc_build_system.bzl", + "grpc_cc_library", + "grpc_proto_plugin", +) package( default_visibility = ["//visibility:public"], @@ -26,11 +28,9 @@ package( ], ) -load( - "//bazel:grpc_build_system.bzl", - "grpc_cc_library", - "grpc_proto_plugin", -) +licenses(["notice"]) + +exports_files(["LICENSE"]) grpc_cc_library( name = "grpc_plugin_support", diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index a080aeff0ad..d4079012156 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -14,10 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - load( "//src/objective-c:grpc_objc_internal_library.bzl", "grpc_objc_examples_library", @@ -28,6 +24,10 @@ load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application") load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_application", "watchos_extension") +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + proto_library_objc_wrapper( name = "messages_proto", srcs = ["RemoteTestClient/messages.proto"], diff --git a/src/objective-c/grpc_objc_internal_library.bzl b/src/objective-c/grpc_objc_internal_library.bzl index ad212d13715..edd0550752a 100644 --- a/src/objective-c/grpc_objc_internal_library.bzl +++ b/src/objective-c/grpc_objc_internal_library.bzl @@ -12,16 +12,16 @@ # 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. -# +""" +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( @@ -37,8 +37,13 @@ def proto_library_objc_wrapper( 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 for adding dependencies to google/protobuf protos. + + Args: + name: The name of the target. + srcs: The sources to include. + deps: The dependencies of the target. + use_well_known_protos: ignored in open source version. """ proto_library( name = name, @@ -109,7 +114,7 @@ def grpc_objc_testing_library( ] if not name == "TestConfigs": - additional_deps += [":TestConfigs"] + additional_deps.append(":TestConfigs") native.objc_library( name = name, @@ -123,7 +128,17 @@ def grpc_objc_testing_library( ) 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_library for use within the repo. + + For local targets within the gRPC repository only. Will not work outside of the repo. + + Args: + name: The name of the library. + deps: The library dependencies. + testing: Whether or not to include testing dependencies. + srcs: The source files for the rule. + use_well_known_protos: Whether or not to include well known protos. + **kwargs: Other arguments to apply to the library. """ objc_grpc_library_name = "_" + name + "_objc_grpc_library" @@ -155,9 +170,9 @@ def local_objc_grpc_library(name, deps, testing = True, srcs = [], use_well_know library_deps = ["@com_google_protobuf//:protobuf_objc"] if testing: - library_deps += ["//src/objective-c:grpc_objc_client_internal_testing"] + library_deps.append("//src/objective-c:grpc_objc_client_internal_testing") else: - library_deps += ["//src/objective-c:proto_objc_rpc"] + library_deps.append("//src/objective-c:proto_objc_rpc") native.objc_library( name = name, diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index ec59473f4ba..9c66e79e081 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -14,10 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - load( "//src/objective-c:grpc_objc_internal_library.bzl", "grpc_objc_testing_library", @@ -29,6 +25,10 @@ load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_tes load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test") load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application", "tvos_unit_test") +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + exports_files(["LICENSE"]) proto_library_objc_wrapper( diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD index 03a8ce1b9a9..9c02458695e 100644 --- a/src/proto/grpc/channelz/BUILD +++ b/src/proto/grpc/channelz/BUILD @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "channelz", visibility = "public", diff --git a/src/proto/grpc/core/BUILD b/src/proto/grpc/core/BUILD index 073c68e786d..a28519cc60c 100644 --- a/src/proto/grpc/core/BUILD +++ b/src/proto/grpc/core/BUILD @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") load("//bazel:python_rules.bzl", "py_proto_library") +licenses(["notice"]) + grpc_package( name = "core", visibility = "public", diff --git a/src/proto/grpc/gcp/BUILD b/src/proto/grpc/gcp/BUILD index fd7c7b4985f..3a490e9cc97 100644 --- a/src/proto/grpc/gcp/BUILD +++ b/src/proto/grpc/gcp/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("@rules_proto//proto:defs.bzl", "proto_library") +licenses(["notice"]) + proto_library( name = "alts_handshaker_proto", srcs = [ diff --git a/src/proto/grpc/health/v1/BUILD b/src/proto/grpc/health/v1/BUILD index 702f5b0ec5a..09cd333bd3a 100644 --- a/src/proto/grpc/health/v1/BUILD +++ b/src/proto/grpc/health/v1/BUILD @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "health", visibility = "public", diff --git a/src/proto/grpc/lb/v1/BUILD b/src/proto/grpc/lb/v1/BUILD index 882c8a56b9a..7bfffe34cd8 100644 --- a/src/proto/grpc/lb/v1/BUILD +++ b/src/proto/grpc/lb/v1/BUILD @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "lb", visibility = "public", diff --git a/src/proto/grpc/lookup/v1/BUILD b/src/proto/grpc/lookup/v1/BUILD index 767a1515013..0701ec0e674 100644 --- a/src/proto/grpc/lookup/v1/BUILD +++ b/src/proto/grpc/lookup/v1/BUILD @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "src/proto/grpc/lookup/v1", visibility = "public", diff --git a/src/proto/grpc/reflection/v1alpha/BUILD b/src/proto/grpc/reflection/v1alpha/BUILD index cb8e8c5b8bc..1c125225477 100644 --- a/src/proto/grpc/reflection/v1alpha/BUILD +++ b/src/proto/grpc/reflection/v1alpha/BUILD @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "reflection", visibility = "public", diff --git a/src/proto/grpc/status/BUILD b/src/proto/grpc/status/BUILD index cd4501a2b52..fd17ef512a7 100644 --- a/src/proto/grpc/status/BUILD +++ b/src/proto/grpc/status/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "status", visibility = "public", diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 9d462f02a49..6b9223c1c4a 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - -load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("@rules_proto//proto:defs.bzl", "proto_library") load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library") +licenses(["notice"]) + grpc_package( name = "testing", visibility = "public", diff --git a/src/proto/grpc/testing/duplicate/BUILD b/src/proto/grpc/testing/duplicate/BUILD index 90756ad569c..6f7abbc8993 100644 --- a/src/proto/grpc/testing/duplicate/BUILD +++ b/src/proto/grpc/testing/duplicate/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "duplicate", visibility = "public", diff --git a/src/proto/grpc/testing/proto2/BUILD.bazel b/src/proto/grpc/testing/proto2/BUILD.bazel index f38bc9b7ceb..d5ffa13a8e0 100644 --- a/src/proto/grpc/testing/proto2/BUILD.bazel +++ b/src/proto/grpc/testing/proto2/BUILD.bazel @@ -12,12 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. load("@rules_proto//proto:defs.bzl", "proto_library") -load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py_proto_library") package(default_visibility = ["//visibility:public"]) -load("//bazel:python_rules.bzl", "py_proto_library") - proto_library( name = "empty2_proto_descriptor", srcs = ["empty2.proto"], diff --git a/src/proto/grpc/testing/xds/BUILD b/src/proto/grpc/testing/xds/BUILD index 6ae8825ec2f..e854b5825d4 100644 --- a/src/proto/grpc/testing/xds/BUILD +++ b/src/proto/grpc/testing/xds/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "xds", visibility = "public", diff --git a/src/proto/grpc/testing/xds/v3/BUILD b/src/proto/grpc/testing/xds/v3/BUILD index c6f15dfe6f8..538ee8f73c0 100644 --- a/src/proto/grpc/testing/xds/v3/BUILD +++ b/src/proto/grpc/testing/xds/v3/BUILD @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library") +licenses(["notice"]) + grpc_package( name = "xds_v3", visibility = "public", diff --git a/src/python/grpcio/grpc/_cython/BUILD.bazel b/src/python/grpcio/grpc/_cython/BUILD.bazel index 96e6d9d380a..e31aded652e 100644 --- a/src/python/grpcio/grpc/_cython/BUILD.bazel +++ b/src/python/grpcio/grpc/_cython/BUILD.bazel @@ -1,3 +1,5 @@ +load("//bazel:cython_library.bzl", "pyx_library") + # Copyright 2021 The gRPC Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,8 +15,6 @@ # limitations under the License. package(default_visibility = ["//visibility:public"]) -load("//bazel:cython_library.bzl", "pyx_library") - genrule( name = "copy_roots_pem", srcs = ["//:etc/roots.pem"], @@ -26,10 +26,11 @@ pyx_library( name = "cygrpc", srcs = glob([ "**/*.pxi", + "**/__init__.py", + ]) + [ "cygrpc.pxd", "cygrpc.pyx", - "**/__init__.py", - ]), + ], data = [":copy_roots_pem"], deps = [ "//:grpc", diff --git a/src/python/grpcio_csds/grpc_csds/BUILD.bazel b/src/python/grpcio_csds/grpc_csds/BUILD.bazel index 2e799ef58ab..4f8886668ac 100644 --- a/src/python/grpcio_csds/grpc_csds/BUILD.bazel +++ b/src/python/grpcio_csds/grpc_csds/BUILD.bazel @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - package(default_visibility = ["//visibility:public"]) py_library( diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel index cdbdb467797..b94377120bd 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library") -load("@grpc_python_dependencies//:requirements.bzl", "requirement") package(default_visibility = ["//visibility:public"]) diff --git a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel index 5e4a358ddca..1e3ced857f7 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel @@ -1,4 +1,4 @@ -# Copyright 2021 The gRPC Authors +# 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. @@ -11,7 +11,7 @@ # 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") + load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) diff --git a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel index 3e6a48c77d0..53653e5caf3 100644 --- a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel @@ -1,3 +1,5 @@ +load("//bazel:python_rules.bzl", "py2and3_test") + # Copyright 2021 The gRPC Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,8 +15,6 @@ # limitations under the License. package(default_visibility = ["//visibility:public"]) -load("//bazel:python_rules.bzl", "py2and3_test") - py_library( name = "stream_testing", srcs = ["stream_testing.py"], diff --git a/test/build_test/BUILD b/test/build_test/BUILD index 3a419fb5784..c06806d927a 100644 --- a/test/build_test/BUILD +++ b/test/build_test/BUILD @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@bazel_skylib//rules:build_test.bzl", "build_test") + licenses(["notice"]) package(default_visibility = ["//visibility:public"]) -load("@bazel_skylib//rules:build_test.bzl", "build_test") - # build test //test/build_test:objective_c_examples_test build_test( name = "objective_c_examples_test", diff --git a/test/core/avl/BUILD b/test/core/avl/BUILD index f8108b62a84..6c77ff5353d 100644 --- a/test/core/avl/BUILD +++ b/test/core/avl/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/core/backoff/BUILD b/test/core/backoff/BUILD index 1d0689e3a0e..1b406d75fb6 100644 --- a/test/core/backoff/BUILD +++ b/test/core/backoff/BUILD @@ -12,7 +12,7 @@ # 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") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test") licenses(["notice"]) diff --git a/test/core/bad_client/BUILD b/test/core/bad_client/BUILD index 096582f8f10..26b05290635 100644 --- a/test/core/bad_client/BUILD +++ b/test/core/bad_client/BUILD @@ -12,12 +12,11 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_package") +load(":generate_tests.bzl", "grpc_bad_client_tests") grpc_package(name = "test/core/bad_client") licenses(["notice"]) -load(":generate_tests.bzl", "grpc_bad_client_tests") - grpc_bad_client_tests() diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl index 272c2bb86a4..85aafed655b 100755 --- a/test/core/bad_client/generate_tests.bzl +++ b/test/core/bad_client/generate_tests.bzl @@ -37,6 +37,7 @@ BAD_CLIENT_TESTS = { "unknown_frame": test_options(), } +# buildifier: disable=unnamed-macro def grpc_bad_client_tests(): grpc_cc_library( name = "bad_client_test", diff --git a/test/core/bad_connection/BUILD b/test/core/bad_connection/BUILD index d2e15b92339..b6515ac136f 100644 --- a/test/core/bad_connection/BUILD +++ b/test/core/bad_connection/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_package") licenses(["notice"]) diff --git a/test/core/bad_ssl/BUILD b/test/core/bad_ssl/BUILD index 3bf44cb3cd1..d0bbe83e879 100644 --- a/test/core/bad_ssl/BUILD +++ b/test/core/bad_ssl/BUILD @@ -12,12 +12,11 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_package") +load(":generate_tests.bzl", "grpc_bad_ssl_tests") grpc_package(name = "test/core/bad_ssl") licenses(["notice"]) -load(":generate_tests.bzl", "grpc_bad_ssl_tests") - grpc_bad_ssl_tests() diff --git a/test/core/bad_ssl/generate_tests.bzl b/test/core/bad_ssl/generate_tests.bzl index 79e82b3093b..64c8697a63c 100755 --- a/test/core/bad_ssl/generate_tests.bzl +++ b/test/core/bad_ssl/generate_tests.bzl @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Houses grpc_bad_ssl_tests. +""" + load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test") def test_options(): @@ -21,7 +25,10 @@ def test_options(): # maps test names to options BAD_SSL_TESTS = ["cert", "alpn"] +# buildifier: disable=unnamed-macro def grpc_bad_ssl_tests(): + """Instantiates gRPC bad SSL tests.""" + grpc_cc_library( name = "bad_ssl_test_server", srcs = ["server_common.cc"], diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 14edcf4d787..fba0fe3f377 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") grpc_package(name = "test/core/channel") diff --git a/test/core/client_channel/resolvers/BUILD b/test/core/client_channel/resolvers/BUILD index 224df41d229..c2a52768725 100644 --- a/test/core/client_channel/resolvers/BUILD +++ b/test/core/client_channel/resolvers/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") grpc_package(name = "test/core/client_channel/resolvers") diff --git a/test/core/compression/BUILD b/test/core/compression/BUILD index 94ba177416b..33928564c56 100644 --- a/test/core/compression/BUILD +++ b/test/core/compression/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_package(name = "test/core/compression") diff --git a/test/core/debug/BUILD b/test/core/debug/BUILD index 62d4cb3daad..24bc416b62e 100644 --- a/test/core/debug/BUILD +++ b/test/core/debug/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") grpc_package(name = "test/core/debug") diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD index 801c5591f7a..bc19df9cf75 100644 --- a/test/core/end2end/BUILD +++ b/test/core/end2end/BUILD @@ -12,14 +12,13 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") +load(":generate_tests.bzl", "grpc_end2end_nosec_tests", "grpc_end2end_tests") licenses(["notice"]) grpc_package(name = "test/core/end2end") -load(":generate_tests.bzl", "grpc_end2end_nosec_tests", "grpc_end2end_tests") - grpc_cc_library( name = "cq_verifier", srcs = ["cq_verifier.cc"], diff --git a/test/core/end2end/fuzzers/BUILD b/test/core/end2end/fuzzers/BUILD index 3b10d72fa58..b8ed88ad996 100644 --- a/test/core/end2end/fuzzers/BUILD +++ b/test/core/end2end/fuzzers/BUILD @@ -12,14 +12,13 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer", "grpc_proto_fuzzer") grpc_package(name = "test/core/end2end/fuzzers") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer", "grpc_proto_fuzzer") - grpc_proto_fuzzer( name = "api_fuzzer", size = "enormous", diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl index a2a9d2b7c1d..18b3de6282c 100755 --- a/test/core/end2end/generate_tests.bzl +++ b/test/core/end2end/generate_tests.bzl @@ -394,14 +394,16 @@ def _compatible(fopt, topt): def _platform_support_tags(fopt): result = [] if not "windows" in fopt._platforms: - result += ["no_windows"] + result.append("no_windows") if not "mac" in fopt._platforms: - result += ["no_mac"] + result.append("no_mac") if not "linux" in fopt._platforms: - result += ["no_linux"] + result.append("no_linux") return result +# buildifier: disable=unnamed-macro def grpc_end2end_tests(): + """Instantiates the gRPC end2end tests.""" grpc_cc_library( name = "end2end_tests", srcs = ["end2end_tests.cc", "end2end_test_utils.cc"] + [ @@ -479,7 +481,9 @@ def grpc_end2end_tests(): flaky = t in fopt.flaky_tests, ) +# buildifier: disable=unnamed-macro def grpc_end2end_nosec_tests(): + """Instantiates the gRPC end2end no security tests""" grpc_cc_library( name = "end2end_nosec_tests", srcs = ["end2end_nosec_tests.cc", "end2end_test_utils.cc"] + [ diff --git a/test/core/fling/BUILD b/test/core/fling/BUILD index a1ebec9c564..d0c2d4212a6 100644 --- a/test/core/fling/BUILD +++ b/test/core/fling/BUILD @@ -12,14 +12,12 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_test", "grpc_package") grpc_package(name = "test/core/fling") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_cc_binary( name = "fling_client", testonly = 1, diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index f9d2392cd2a..76c920d97d5 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index 12d99c62261..5b2a3c6bf87 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -12,15 +12,14 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") load("//bazel:custom_exec_properties.bzl", "LARGE_MACHINE") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") licenses(["notice"]) grpc_package(name = "test/core/gprpp") -load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") - grpc_cc_test( name = "examine_stack_test", srcs = ["examine_stack_test.cc"], diff --git a/test/core/handshake/BUILD b/test/core/handshake/BUILD index 49ff6388eec..8b4aeb7b132 100644 --- a/test/core/handshake/BUILD +++ b/test/core/handshake/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") grpc_package(name = "test/core/handshake") diff --git a/test/core/http/BUILD b/test/core/http/BUILD index e1ffdd7e4d5..86852b1f1c2 100644 --- a/test/core/http/BUILD +++ b/test/core/http/BUILD @@ -12,14 +12,13 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_package(name = "test/core/http") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_fuzzer( name = "response_fuzzer", srcs = ["response_fuzzer.cc"], @@ -62,8 +61,6 @@ grpc_fuzzer( licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_cc_test( name = "httpcli_test", srcs = ["httpcli_test.cc"], diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD index 5be930a3f6e..610527406f9 100644 --- a/test/core/iomgr/BUILD +++ b/test/core/iomgr/BUILD @@ -12,13 +12,11 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") load("//bazel:custom_exec_properties.bzl", "LARGE_MACHINE") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_package( name = "test/core/iomgr", visibility = "public", diff --git a/test/core/json/BUILD b/test/core/json/BUILD index 5ad82ced2da..c3157542559 100644 --- a/test/core/json/BUILD +++ b/test/core/json/BUILD @@ -12,14 +12,13 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_package(name = "test/core/json") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_fuzzer( name = "json_fuzzer", srcs = ["fuzzer.cc"], diff --git a/test/core/nanopb/BUILD b/test/core/nanopb/BUILD index ce827545ba4..1a868eb52ec 100644 --- a/test/core/nanopb/BUILD +++ b/test/core/nanopb/BUILD @@ -12,14 +12,13 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_package(name = "test/core/nanopb") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_fuzzer( name = "fuzzer_response", srcs = ["fuzzer_response.cc"], diff --git a/test/core/network_benchmarks/BUILD b/test/core/network_benchmarks/BUILD index 259cb7952ad..2a9b4dada18 100644 --- a/test/core/network_benchmarks/BUILD +++ b/test/core/network_benchmarks/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_package") grpc_package( name = "test/core/network_benchmarks", diff --git a/test/core/promise/BUILD b/test/core/promise/BUILD index 838f21ad1b1..04fe2bafc20 100644 --- a/test/core/promise/BUILD +++ b/test/core/promise/BUILD @@ -13,13 +13,12 @@ # limitations under the License. load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") licenses(["notice"]) grpc_package(name = "test/core/promise") -load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") - grpc_cc_library( name = "test_wakeup_schedulers", testonly = True, diff --git a/test/core/promise/benchmark/BUILD b/test/core/promise/benchmark/BUILD index ad34a1f4091..772bb8dd268 100644 --- a/test/core/promise/benchmark/BUILD +++ b/test/core/promise/benchmark/BUILD @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +load("//test/cpp/microbenchmarks:grpc_benchmark_config.bzl", "grpc_benchmark_args") -grpc_package(name = "test/core/promise/benchmark") +licenses(["notice"]) -load("//test/cpp/microbenchmarks:grpc_benchmark_config.bzl", "grpc_benchmark_args") +grpc_package(name = "test/core/promise/benchmark") grpc_cc_test( name = "competition", diff --git a/test/core/resource_quota/BUILD b/test/core/resource_quota/BUILD index 69b4df43922..31ccb2b57cc 100644 --- a/test/core/resource_quota/BUILD +++ b/test/core/resource_quota/BUILD @@ -13,13 +13,12 @@ # limitations under the License. load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") licenses(["notice"]) grpc_package(name = "test/core/resource_quota") -load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") - grpc_cc_library( name = "call_checker", testonly = True, diff --git a/test/core/security/BUILD b/test/core/security/BUILD index d5db0d73561..05659fb0f47 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -13,13 +13,12 @@ # limitations under the License. load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") licenses(["notice"]) grpc_package(name = "test/core/security") -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_fuzzer( name = "alts_credentials_fuzzer", srcs = ["alts_credentials_fuzzer.cc"], diff --git a/test/core/slice/BUILD b/test/core/slice/BUILD index da209fb4f61..854418a2bf1 100644 --- a/test/core/slice/BUILD +++ b/test/core/slice/BUILD @@ -12,14 +12,13 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_package(name = "test/core/slice") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_fuzzer( name = "b64_encode_fuzzer", srcs = ["b64_encode_fuzzer.cc"], diff --git a/test/core/surface/BUILD b/test/core/surface/BUILD index 3307af149dc..9d558059039 100644 --- a/test/core/surface/BUILD +++ b/test/core/surface/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/core/transport/BUILD b/test/core/transport/BUILD index ecb3a8e728c..ce79187e2bc 100644 --- a/test/core/transport/BUILD +++ b/test/core/transport/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/core/transport/chttp2/BUILD b/test/core/transport/chttp2/BUILD index 59cdf3f6dfd..4ea6394c08b 100644 --- a/test/core/transport/chttp2/BUILD +++ b/test/core/transport/chttp2/BUILD @@ -12,15 +12,14 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") +load("//bazel:custom_exec_properties.bzl", "LARGE_MACHINE") licenses(["notice"]) grpc_package(name = "test/core/transport/chttp2") -load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") -load("//bazel:custom_exec_properties.bzl", "LARGE_MACHINE") - grpc_proto_fuzzer( name = "hpack_parser_fuzzer", srcs = ["hpack_parser_fuzzer_test.cc"], @@ -164,7 +163,7 @@ grpc_cc_test( ) grpc_cc_test( - "too_many_pings_test", + name = "too_many_pings_test", timeout = "long", # Required for internal test infrastructure (cl/325757166) srcs = ["too_many_pings_test.cc"], external_deps = ["gtest"], diff --git a/test/core/tsi/BUILD b/test/core/tsi/BUILD index 50f86a21742..14cf42afbc7 100644 --- a/test/core/tsi/BUILD +++ b/test/core/tsi/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/core/tsi/alts/fake_handshaker/BUILD b/test/core/tsi/alts/fake_handshaker/BUILD index e4c8e0001ef..bd10037a708 100644 --- a/test/core/tsi/alts/fake_handshaker/BUILD +++ b/test/core/tsi/alts/fake_handshaker/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_package", "grpc_proto_library") +licenses(["notice"]) + grpc_package( name = "test/core/tsi/alts/fake_handshaker", visibility = "public", diff --git a/test/core/tsi/alts/frame_protector/BUILD b/test/core/tsi/alts/frame_protector/BUILD index 39cc825bc9c..33a1bef3f5c 100644 --- a/test/core/tsi/alts/frame_protector/BUILD +++ b/test/core/tsi/alts/frame_protector/BUILD @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/core/uri/BUILD b/test/core/uri/BUILD index fd2990c52c9..bf8d3699135 100644 --- a/test/core/uri/BUILD +++ b/test/core/uri/BUILD @@ -13,13 +13,12 @@ # limitations under the License. load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_package(name = "test/core/uri") licenses(["notice"]) -load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") - grpc_fuzzer( name = "uri_fuzzer_test", srcs = ["uri_fuzzer_test.cc"], diff --git a/test/core/util/BUILD b/test/core/util/BUILD index d9884d5a011..7777d9f452c 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -12,7 +12,7 @@ # 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", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/core/util/grpc_fuzzer.bzl b/test/core/util/grpc_fuzzer.bzl index c85a8f3d31c..8ae71b61f35 100644 --- a/test/core/util/grpc_fuzzer.bzl +++ b/test/core/util/grpc_fuzzer.bzl @@ -12,11 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Includes fuzzer rules. +""" + 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): + """Instantiates a fuzzer test. + + Args: + name: The name of the test. + corpus: The corpus for the test. + srcs: The source files for the test. + deps: The dependencies of the test. + data: The data dependencies of the test. + size: The size of the test. + **kwargs: Other arguments to supply to the test. + """ CORPUS_DIR = native.package_name() + "/" + corpus grpc_cc_test( name = name, @@ -38,6 +53,18 @@ def grpc_fuzzer(name, corpus, srcs = [], deps = [], data = [], size = "large", * ) def grpc_proto_fuzzer(name, corpus, proto, srcs = [], deps = [], data = [], size = "large", **kwargs): + """Instantiates a protobuf mutator fuzzer test. + + Args: + name: The name of the test. + corpus: The corpus for the test. + proto: The proto for the test. + srcs: The source files for the test. + deps: The dependencies of the test. + data: The data dependencies of the test. + size: The size of the test. + **kwargs: Other arguments to supply to the test. + """ PROTO_LIBRARY = "_%s_proto" % name CC_PROTO_LIBRARY = "_%s_cc_proto" % name CORPUS_DIR = native.package_name() + "/" + corpus diff --git a/test/cpp/client/BUILD b/test/cpp/client/BUILD index af0d86d5968..9e443233d14 100644 --- a/test/cpp/client/BUILD +++ b/test/cpp/client/BUILD @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") -load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) grpc_package(name = "test/cpp/client") diff --git a/test/cpp/codegen/BUILD b/test/cpp/codegen/BUILD index 560f5128e59..2b11e8d2272 100644 --- a/test/cpp/codegen/BUILD +++ b/test/cpp/codegen/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_test", "grpc_package", "grpc_sh_test") +licenses(["notice"]) + grpc_package(name = "test/cpp/codegen") grpc_cc_test( diff --git a/test/cpp/common/BUILD b/test/cpp/common/BUILD index 1e25f28d762..ad577c93ced 100644 --- a/test/cpp/common/BUILD +++ b/test/cpp/common/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +licenses(["notice"]) + grpc_package(name = "test/cpp/common") grpc_cc_test( diff --git a/test/cpp/ext/filters/census/BUILD b/test/cpp/ext/filters/census/BUILD index ffb4cc319c7..94ec048dfdf 100644 --- a/test/cpp/ext/filters/census/BUILD +++ b/test/cpp/ext/filters/census/BUILD @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") -load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") licenses(["notice"]) diff --git a/test/cpp/grpclb/BUILD b/test/cpp/grpclb/BUILD index b9203e7d904..cc557badea7 100644 --- a/test/cpp/grpclb/BUILD +++ b/test/cpp/grpclb/BUILD @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") -load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) grpc_package( name = "test/cpp/grpclb", diff --git a/test/cpp/interop/BUILD b/test/cpp/interop/BUILD index 85f0bef13f0..895f449fbcd 100644 --- a/test/cpp/interop/BUILD +++ b/test/cpp/interop/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) + grpc_package( name = "test/cpp/interop", visibility = "public", diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 6b52891fae4..4c777bf9455 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") +load("//test/cpp/microbenchmarks:grpc_benchmark_config.bzl", "grpc_benchmark_args") -grpc_package(name = "test/cpp/microbenchmarks") +licenses(["notice"]) -load("//test/cpp/microbenchmarks:grpc_benchmark_config.bzl", "grpc_benchmark_args") +grpc_package(name = "test/cpp/microbenchmarks") grpc_cc_test( name = "noop-benchmark", diff --git a/test/cpp/naming/BUILD b/test/cpp/naming/BUILD index 85bb419c43c..f2653c2cf99 100644 --- a/test/cpp/naming/BUILD +++ b/test/cpp/naming/BUILD @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_py_binary") +load(":generate_resolver_component_tests.bzl", "generate_resolver_component_tests") + package( default_visibility = ["//visibility:public"], features = [ @@ -22,9 +25,6 @@ package( licenses(["notice"]) -load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_py_binary") -load(":generate_resolver_component_tests.bzl", "generate_resolver_component_tests") - # Meant to be invoked only through the top-level shell script driver. grpc_py_binary( name = "resolver_component_tests_runner", diff --git a/test/cpp/naming/generate_resolver_component_tests.bzl b/test/cpp/naming/generate_resolver_component_tests.bzl index 45c7ab34e2c..19dc6b9b48d 100755 --- a/test/cpp/naming/generate_resolver_component_tests.bzl +++ b/test/cpp/naming/generate_resolver_component_tests.bzl @@ -13,8 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Houses generate_resolver_component_tests. +""" + load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_test") +# buildifier: disable=unnamed-macro def generate_resolver_component_tests(): for unsecure_build_config_suffix in ["_unsecure", ""]: grpc_cc_test( diff --git a/test/cpp/naming/utils/BUILD b/test/cpp/naming/utils/BUILD index 10af8bf3b59..02b82b03392 100644 --- a/test/cpp/naming/utils/BUILD +++ b/test/cpp/naming/utils/BUILD @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("//bazel:grpc_build_system.bzl", "grpc_py_binary") + package( default_visibility = ["//visibility:public"], features = [ @@ -22,8 +24,6 @@ package( licenses(["notice"]) -load("//bazel:grpc_build_system.bzl", "grpc_py_binary") - grpc_py_binary( name = "dns_server", testonly = True, diff --git a/test/cpp/performance/BUILD b/test/cpp/performance/BUILD index 04506a14d8b..03c16ece80a 100644 --- a/test/cpp/performance/BUILD +++ b/test/cpp/performance/BUILD @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") -load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) grpc_package(name = "test/cpp/performance") diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD index c856a50506e..73ae7056d13 100644 --- a/test/cpp/qps/BUILD +++ b/test/cpp/qps/BUILD @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") load("//test/cpp/qps:qps_benchmark_script.bzl", "json_run_localhost_batch", "qps_json_driver_batch") load("//bazel:custom_exec_properties.bzl", "LARGE_MACHINE") +licenses(["notice"]) + grpc_package(name = "test/cpp/qps") grpc_cc_library( diff --git a/test/cpp/qps/qps_benchmark_script.bzl b/test/cpp/qps/qps_benchmark_script.bzl index 6f4def977de..9af16a132fa 100644 --- a/test/cpp/qps/qps_benchmark_script.bzl +++ b/test/cpp/qps/qps_benchmark_script.bzl @@ -38,6 +38,7 @@ def add_suffix(name): else: return name +# buildifier: disable=unnamed-macro def qps_json_driver_batch(): for scenario in QPS_JSON_DRIVER_SCENARIOS: grpc_cc_test( @@ -63,6 +64,7 @@ def qps_json_driver_batch(): flaky = True, ) +# buildifier: disable=unnamed-macro def json_run_localhost_batch(): for scenario in JSON_RUN_LOCALHOST_SCENARIOS: grpc_cc_test( diff --git a/test/cpp/server/BUILD b/test/cpp/server/BUILD index 225fa0220f6..f8ba1246ecc 100644 --- a/test/cpp/server/BUILD +++ b/test/cpp/server/BUILD @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") -load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) grpc_package(name = "test/cpp/server") diff --git a/test/cpp/server/load_reporter/BUILD b/test/cpp/server/load_reporter/BUILD index 272b116e2f6..2fd5da92472 100644 --- a/test/cpp/server/load_reporter/BUILD +++ b/test/cpp/server/load_reporter/BUILD @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") -load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) grpc_package(name = "test/cpp/server/load_reporter") diff --git a/test/cpp/test/BUILD b/test/cpp/test/BUILD index 92b3159185f..2ff46cf3293 100644 --- a/test/cpp/test/BUILD +++ b/test/cpp/test/BUILD @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") -load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) grpc_package( name = "test/cpp/test", diff --git a/test/cpp/thread_manager/BUILD b/test/cpp/thread_manager/BUILD index 2f8ca7c37c3..e9497211091 100644 --- a/test/cpp/thread_manager/BUILD +++ b/test/cpp/thread_manager/BUILD @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") -load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) grpc_package( name = "test/cpp/thread_manager", diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index 897dd08758b..046fbc8ea2e 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -licenses(["notice"]) - load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") +licenses(["notice"]) + grpc_package( name = "test/cpp/util", visibility = "public", diff --git a/tools/distrib/buildifier_format_code.sh b/tools/distrib/buildifier_format_code.sh index 8245cd4ae50..8d023e2f473 100755 --- a/tools/distrib/buildifier_format_code.sh +++ b/tools/distrib/buildifier_format_code.sh @@ -15,9 +15,9 @@ set -e -BUILDIFIER_VERSION="0.29.0" +BUILDIFIER_VERSION="4.2.2" TEMP_BUILDIFIER_PATH="/tmp/buildifier" -EXTRA_BUILDIFIER_FLAGS=$* +EXTRA_BUILDIFIER_FLAGS="$*" function error_handling() { error=$1 diff --git a/tools/distrib/buildifier_format_code_strict.sh b/tools/distrib/buildifier_format_code_strict.sh index e8a984184c2..c50e6ea6c1a 100755 --- a/tools/distrib/buildifier_format_code_strict.sh +++ b/tools/distrib/buildifier_format_code_strict.sh @@ -17,4 +17,4 @@ dir=$(dirname "${0}") buildifier_format_script="${dir}/buildifier_format_code.sh" -${buildifier_format_script} -lint warn +${buildifier_format_script} -lint fix diff --git a/tools/distrib/python/grpcio_tools/BUILD.bazel b/tools/distrib/python/grpcio_tools/BUILD.bazel index e85ea461fb4..c397e823673 100644 --- a/tools/distrib/python/grpcio_tools/BUILD.bazel +++ b/tools/distrib/python/grpcio_tools/BUILD.bazel @@ -12,15 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("//bazel:cython_library.bzl", "pyx_library") +load("grpcio_tools.bzl", "internal_copied_filegroup") + package(default_visibility = [ "//examples/python:__subpackages__", "//src/python:__subpackages__", "//tools/distrib/python/grpcio_tools:__subpackages__", ]) -load("//bazel:cython_library.bzl", "pyx_library") -load("grpcio_tools.bzl", "internal_copied_filegroup") - cc_library( name = "protoc_lib", srcs = ["grpc_tools/main.cc"], diff --git a/tools/distrib/python/grpcio_tools/grpc_tools/test/BUILD.bazel b/tools/distrib/python/grpcio_tools/grpc_tools/test/BUILD.bazel index 53dae10a9f6..3104d30311f 100644 --- a/tools/distrib/python/grpcio_tools/grpc_tools/test/BUILD.bazel +++ b/tools/distrib/python/grpcio_tools/grpc_tools/test/BUILD.bazel @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -package(default_testonly = 1) +load("//bazel:python_rules.bzl", "py_proto_library") -load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library") +package(default_testonly = 1) proto_library( name = "simplest_proto", diff --git a/tools/distrib/python/grpcio_tools/grpcio_tools.bzl b/tools/distrib/python/grpcio_tools/grpcio_tools.bzl index 603556c9d86..59e8e878062 100644 --- a/tools/distrib/python/grpcio_tools/grpcio_tools.bzl +++ b/tools/distrib/python/grpcio_tools/grpcio_tools.bzl @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Houses utility rules for grpcio-tools. +""" + def _generate_copied_files_impl(ctx): srcs = ctx.attr.srcs[0] strip_prefix = ctx.attr.strip_prefix diff --git a/tools/run_tests/sanity/check_buildifier.sh b/tools/run_tests/sanity/check_buildifier.sh index bb183711c42..c0e81176628 100755 --- a/tools/run_tests/sanity/check_buildifier.sh +++ b/tools/run_tests/sanity/check_buildifier.sh @@ -16,14 +16,14 @@ # The script to check if Bazel files need to be formatted. GIT_ROOT="$(dirname "$0")/../../.." -"$GIT_ROOT/tools/distrib/buildifier_format_code.sh" -mode=diff +"$GIT_ROOT/tools/distrib/buildifier_format_code.sh" -mode=diff -lint warn result=$? if [[ ${result} != 0 ]]; then echo "==========BUILDIFIER CHECK FAILED==========" echo "Please try using the following script to fix automatically:" echo "" - echo " tools/distrib/buildifier_format_code.sh" + echo " tools/distrib/buildifier_format_code_strict.sh" echo "" exit 1 else