Skip to content

Commit

Permalink
Fix remote execution for empty aspects
Browse files Browse the repository at this point in the history
  • Loading branch information
purkhusid committed Feb 13, 2021
1 parent b02507e commit 1763ce3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def proto_compile_impl(ctx):
# Build copy command for directory outputs
# Use cp {}/. rather than {}/* to allow for empty output directories from a plugin (e.g when no service exists,
# so no files generated)
command_parts = ["cp -r {} '{}'".format(
# We need to `mkdir` the new dir for the action work with remote execution when
# because the folder could possibly be empty: https://github.com/bazelbuild/bazel/issues/6393
command_parts = ["mkdir -p {} && cp -r {} '{}'".format(
new_dir.path,
" ".join(["'" + d.path + "/.'" for d in output_dirs.to_list()]),
new_dir.path,
)]
Expand Down Expand Up @@ -423,7 +426,10 @@ def proto_compile_aspect_impl(target, ctx):
###

mnemonic = "ProtoCompile"
command = ("mkdir -p '{}' && ".format(output_root)) + protoc.path + " $@" # $@ is replaced with args list
command = "mkdir -p '{}' && ".format(output_root)
if plugin.output_directory:
command = "mkdir -p '{}' && ".format(out_file) # Needed in case the folder is empty, see: https://github.com/bazelbuild/bazel/issues/6393
command = command + protoc.path + " $@" # $@ is replaced with args list
inputs = proto_info.transitive_descriptor_sets.to_list() + plugin_runfiles # Proto files are not inputs, as they come via the descriptor sets
tools = [protoc] + ([plugin_tool] if plugin_tool else [])

Expand Down

0 comments on commit 1763ce3

Please sign in to comment.