Skip to content

Commit

Permalink
fix: Fix the transport bazel arg (it's not a file)
Browse files Browse the repository at this point in the history
At the same time, this moves to using opt_args and opt_file_args to
generate cleaner protoc invocations, and fixes numeric enum
parameter handling.
  • Loading branch information
jskeet committed Aug 17, 2022
1 parent b994d52 commit d0687d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Google.Api.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public static class Program
nameGrpcServiceConfig,
nameCommonResourcesConfig,
nameServiceConfigYaml,
nameTransport);
nameTransport,
nameRequestNumericEnumJsonEncoding);

public class Options
{
Expand Down Expand Up @@ -184,7 +185,7 @@ private static int GenerateFromProtoc(Stream stdin, Stream stdout)
var serviceConfigPath = extraParams.GetValueOrDefault(nameServiceConfigYaml)?.SingleOrDefault();
var commonResourcesConfigPaths = extraParams.GetValueOrDefault(nameCommonResourcesConfig);
var transports = ParseTransports(extraParams.GetValueOrDefault(nameTransport)?.SingleOrDefault());
var requestNumericEnumJsonEncoding = extraParams.GetValueOrDefault(nameRequestNumericEnumJsonEncoding)?.SingleOrDefault() == "true";
var requestNumericEnumJsonEncoding = string.Equals(extraParams.GetValueOrDefault(nameRequestNumericEnumJsonEncoding)?.SingleOrDefault(), "true", StringComparison.OrdinalIgnoreCase);

var results = CodeGenerator.Generate(codeGenRequest.ProtoFile, codeGenRequest.FileToGenerate,
SystemClock.Instance, grpcServiceConfigPath, serviceConfigPath, commonResourcesConfigPaths, transports, requestNumericEnumJsonEncoding);
Expand Down
16 changes: 9 additions & 7 deletions rules_csharp_gapic/csharp_gapic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,24 @@ def csharp_gapic_library(
**kwargs):
# Build zip file of gapic-generator output
name_srcjar = "{name}_srcjar".format(name = name)
plugin_file_args = {}
opt_file_args = {}
opt_args = []
if grpc_service_config:
plugin_file_args[grpc_service_config] = "grpc-service-config"
opt_file_args[grpc_service_config] = "grpc-service-config"
if common_resources_config:
plugin_file_args[common_resources_config] = "common-resources-config"
opt_file_args[common_resources_config] = "common-resources-config"
if service_yaml:
plugin_file_args[service_yaml] = "service-config"
opt_file_args[service_yaml] = "service-config"
if rest_numeric_enums:
plugin_file_args[rest_numeric_enums] = "rest-numeric-enums"
opt_args.append("rest-numeric-enums={}".format(rest_numeric_enums))
if transport:
plugin_file_args[transport] = "transport"
opt_args.append("transport={}".format(transport))
proto_custom_library(
name = name_srcjar,
deps = srcs,
plugin = Label(generator_binary),
plugin_file_args = plugin_file_args,
opt_file_args = opt_file_args,
opt_args = opt_args,
output_type = "gapic",
output_suffix = ".srcjar",
**kwargs
Expand Down

0 comments on commit d0687d0

Please sign in to comment.