Skip to content

Commit

Permalink
Allow the use of $in and $out in exec args
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Feb 28, 2024
1 parent 93fc4a6 commit b8290f8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Lib/gftools/builder/operations/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,21 @@ def validate(self):

if "args" not in self.original:
raise ValueError("No arguments given")

@property
def variables(self):
# We would like to be able to use the "$in" and
# "$out" template variables inside our "args" string,
# but ninja does not perform this second level of
# variable expansion. So we do it ourselves.
vars = {
"exe": self.original["exe"],
"args": self.original["args"],
}
all_input_files = " ".join([source.path for source in self._sources])
vars["args"] = vars["args"].replace("$in", all_input_files)
if "$out" in vars["args"]:
if len(self._targets) != 1:
raise ValueError("Multiple outputs, but $out used")
vars["args"] = vars["args"].replace("$out", self.first_target.path)
return vars

0 comments on commit b8290f8

Please sign in to comment.