Skip to content

Commit

Permalink
Add extra_protoc_args attr to plugin, closes #68
Browse files Browse the repository at this point in the history
  • Loading branch information
aaliddell committed Feb 13, 2021
1 parent f8cc9bb commit 66775a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 5 additions & 0 deletions plugin.bzl
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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,
Expand All @@ -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'",
),
Expand Down

0 comments on commit 66775a4

Please sign in to comment.