Skip to content

Commit

Permalink
Make sure output directory for actool exists before invoking actool
Browse files Browse the repository at this point in the history
Previously, each "actool" compile action declared an output directory
but didn't create it. Instead, it relied on Bazel to create the
directory before invoking the tool. With a non-remote spawn strategy,
Bazel would implicitly create it for you; but with the remote spawn
strategy, it is not created by the remote worker.

Additionally, this was also against what was documented for
declare_directory, which says that "You must create an action that
generates the directory".

This patches the "actool" wrapper to create an empty directory if one
doesn't exist at the specified output path, to make it works with remote
execution.

#896

RELNOTES: None
PiperOrigin-RevId: 423797086
  • Loading branch information
thomasvl authored and swiple-rules-gardener committed Jan 24, 2022
1 parent 03f5eb9 commit 3d51e63
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/xctoolrunner/xctoolrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ def actool(_, toolargs):

xcrunargs += toolargs

# The argument coming after "--compile" is the output directory. "actool"
# expects an directory to exist at that path. Create an empty directory there
# if one doesn't exist yet.
for idx, arg in enumerate(toolargs):
if arg == "--compile":
output_dir = toolargs[idx + 1]
if not os.path.exists(output_dir):
os.makedirs(output_dir)
break

# If we are running into problems figuring out "actool" issues, there are a
# couple of environment variables that may help. Both of the following must be
# set to work.
Expand Down

1 comment on commit 3d51e63

@keith
Copy link
Member

@keith keith commented on 3d51e63 Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.