diff --git a/aspect.bzl b/aspect.bzl index 55f1d820b..443d25710 100644 --- a/aspect.bzl +++ b/aspect.bzl @@ -414,6 +414,10 @@ def proto_compile_aspect_impl(target, ctx): out_arg = "{}:{}".format(opts_str, out_arg) args.add("--{}_out={}".format(plugin_name, out_arg)) + # Add any extra protoc args that the plugin has + if plugin.extra_protoc_args: + args.add_all(plugin.extra_protoc_args) + # Add source proto files as descriptor paths for proto in protos: args.add(descriptor_proto_path(proto, proto_info)) diff --git a/plugin.bzl b/plugin.bzl index 7424ef1ab..de5519662 100644 --- a/plugin.bzl +++ b/plugin.bzl @@ -1,6 +1,7 @@ ProtoPluginInfo = provider(fields = { "name": "The proto plugin name", "options": "A list of options to pass to the compiler for this plugin", + "extra_protoc_args": "A list of extra args to pass directly to protoc, not as plugin options", "outputs": "Output filenames generated on a per-proto basis. Example: '{basename}_pb2.py", "out": "Output filename generated on a per-plugin basis; to be used in the value for --NAME-out=OUT", "output_directory": "Flag that indicates that the plugin should just output a directory. Used for plugins that have no direct mapping from source file name to output name. Cannot be used in conjunction with outputs or out", @@ -20,6 +21,7 @@ def _proto_plugin_impl(ctx): ProtoPluginInfo( name = ctx.attr.name, options = ctx.attr.options, + extra_protoc_args = ctx.attr.extra_protoc_args, outputs = ctx.attr.outputs, out = ctx.attr.out, output_directory = ctx.attr.output_directory, @@ -41,6 +43,9 @@ proto_plugin = rule( "options": attr.string_list( doc = "A list of options to pass to the compiler for this plugin", ), + "extra_protoc_args": attr.string_list( + doc = "A list of extra args to pass directly to protoc, not as plugin options", + ), "outputs": attr.string_list( doc = "Output filenames generated on a per-proto basis. Example: '{basename}_pb2.py'", ),