From 1f75d40cb3e3798d31d1560024e24aebbc35bf5e Mon Sep 17 00:00:00 2001 From: Andre Brisco Date: Wed, 2 Dec 2020 06:59:33 -0800 Subject: [PATCH] Updated `grpc` flag to `is_grpc` to make it more apparent it's a boolean value --- proto/proto.bzl | 16 ++++++++-------- proto/toolchain.bzl | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/proto/proto.bzl b/proto/proto.bzl index 797bb741b2..00769f86fa 100644 --- a/proto/proto.bzl +++ b/proto/proto.bzl @@ -165,7 +165,7 @@ def _expand_provider(lst, provider): """ return [el[provider] for el in lst if provider in el] -def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, grpc, compile_deps): +def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, is_grpc, compile_deps): """Create and run a rustc compile action based on the current rule's attributes Args: @@ -174,7 +174,7 @@ def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, grpc, imports (depset): A set of transitive protobuf Imports. crate_name (str): The name of the Crate for the current target ctx (ctx): The current rule's context object - grpc (bool): True if the current rule is a `gRPC` rule. + is_grpc (bool): True if the current rule is a `gRPC` rule. compile_deps (list): A list of Rust dependencies (`List[Target]`) Returns: @@ -183,7 +183,7 @@ def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, grpc, # Create all the source in a specific folder proto_toolchain = ctx.toolchains["@io_bazel_rules_rust//proto:toolchain"] - output_dir = "%s.%s.rust" % (crate_name, "grpc" if grpc else "proto") + output_dir = "%s.%s.rust" % (crate_name, "grpc" if is_grpc else "proto") # Generate the proto stubs srcs = _generate_proto( @@ -193,12 +193,12 @@ def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, grpc, imports = imports, output_dir = output_dir, proto_toolchain = proto_toolchain, - grpc = grpc, + is_grpc = is_grpc, ) # and lib.rs lib_rs = ctx.actions.declare_file("%s/lib.rs" % output_dir) - _gen_lib(ctx, grpc, protos, lib_rs) + _gen_lib(ctx, is_grpc, protos, lib_rs) srcs.append(lib_rs) # And simulate rust_library behavior @@ -228,12 +228,12 @@ def _rust_proto_compile(protos, descriptor_sets, imports, crate_name, ctx, grpc, output_hash = output_hash, ) -def _rust_protogrpc_library_impl(ctx, grpc): +def _rust_protogrpc_library_impl(ctx, is_grpc): """Implementation of the rust_(proto|grpc)_library. Args: ctx (ctx): The current rule's context object - grpc (bool): True if the current rule is a `gRPC` rule. + is_grpc (bool): True if the current rule is a `gRPC` rule. Returns: list: A list of providers, see `_rust_proto_compile` @@ -251,7 +251,7 @@ def _rust_protogrpc_library_impl(ctx, grpc): imports = depset(transitive = [p.transitive_imports for p in proto]), crate_name = ctx.label.name, ctx = ctx, - grpc = grpc, + is_grpc = is_grpc, compile_deps = ctx.attr.rust_deps, ) diff --git a/proto/toolchain.bzl b/proto/toolchain.bzl index 5e258a753b..46368e82ad 100644 --- a/proto/toolchain.bzl +++ b/proto/toolchain.bzl @@ -26,7 +26,7 @@ def rust_generate_proto( imports, output_dir, proto_toolchain, - grpc = False): + is_grpc = False): """Generate a proto compilation action. Args: @@ -36,7 +36,7 @@ def rust_generate_proto( imports (depset): directory, relative to the package, to output the list of stubs. output_dir (str): The basename of the output directory for for the output generated stubs proto_toolchain (ToolchainInfo): The toolchain for rust-proto compilation. See `rust_proto_toolchain` - grpc (bool, optional): generate gRPC stubs. Defaults to False. + is_grpc (bool, optional): generate gRPC stubs. Defaults to False. Returns: list: the list of generate stubs (File) @@ -55,7 +55,7 @@ def rust_generate_proto( outs = [ctx.actions.declare_file(path + ".rs") for path in paths] output_directory = outs[0].dirname - if grpc: + if is_grpc: # Add grpc stubs to the list of outputs grpc_files = [ctx.actions.declare_file(path + "_grpc.rs") for path in paths] outs.extend(grpc_files)