From 6d5b238bc03aac84ee4803ef68d82d29ec773c7a Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Mon, 16 May 2022 12:39:00 +0100 Subject: [PATCH] feat: Support multi-version generation This allows the generator repo to be imported multiple times with different versions, so the same Bazel workspace can have different APIs generated with different versions. --- repositories.bzl | 6 +++--- rules_csharp_gapic/csharp_gapic.bzl | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/repositories.bzl b/repositories.bzl index 03e60e0c..e268edae 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -16,7 +16,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//rules_csharp_gapic:csharp_compiler_repo.bzl", "csharp_compiler", "dotnet_restore") -def gapic_generator_csharp_repositories(): +def gapic_generator_csharp_repositories(gapic_generator_suffix = ""): _rules_gapic_version = "0.8.0" _rules_gapic_sha256 = "75705d03068ba07cc885a85bb4585e2a278414e31510e60577df8437a28a4ae1" @@ -34,6 +34,6 @@ def gapic_generator_csharp_repositories(): ) maybe( dotnet_restore, - name = "gapic_generator_restore", - csproj = "@gapic_generator_csharp//:Google.Api.Generator/Google.Api.Generator.csproj", + name = "gapic_generator_restore%s" % gapic_generator_suffix, + csproj = "@gapic_generator_csharp%s//:Google.Api.Generator/Google.Api.Generator.csproj" % gapic_generator_suffix, ) diff --git a/rules_csharp_gapic/csharp_gapic.bzl b/rules_csharp_gapic/csharp_gapic.bzl index 17d285b6..c41b608d 100644 --- a/rules_csharp_gapic/csharp_gapic.bzl +++ b/rules_csharp_gapic/csharp_gapic.bzl @@ -41,6 +41,7 @@ def csharp_gapic_library( grpc_service_config = None, common_resources_config = None, service_yaml = None, + generator_binary = "//rules_csharp_gapic:csharp_gapic_generator_binary", **kwargs): # Build zip file of gapic-generator output name_srcjar = "{name}_srcjar".format(name = name) @@ -54,7 +55,7 @@ def csharp_gapic_library( proto_custom_library( name = name_srcjar, deps = srcs, - plugin = Label("//rules_csharp_gapic:csharp_gapic_generator_binary"), + plugin = Label(generator_binary), plugin_file_args = plugin_file_args, output_type = "gapic", output_suffix = ".srcjar",