Allow target to overide rules.

This commit is contained in:
Sleepy Monax 2023-12-13 17:37:19 +01:00
parent f50a571afa
commit 0bbced54c4
3 changed files with 3 additions and 2 deletions

View file

@ -289,7 +289,7 @@ def gen(out: TextIO, scope: TargetScope):
w.variable(i + "flags", " ".join(rule.args + tool.args))
w.rule(
i,
f"{tool.cmd} {rule.rule.replace('$flags',f'${i}flags')}",
f"{tool.cmd} {(tool.rule or rule.rule).replace('$flags',f'${i}flags')}",
depfile=rule.deps,
)
w.newline()

View file

@ -248,6 +248,7 @@ class Tool(DataClassJsonMixin):
cmd: str = dt.field(default="")
args: list[str] = dt.field(default_factory=list)
files: list[str] = dt.field(default_factory=list)
rule: Optional[str] = None
Tools = dict[str, Tool]

View file

@ -51,7 +51,7 @@ rules: dict[str, Rule] = {
"ld",
["*.o", "*.a"],
"*.out",
"-o $out $objs -Wl,--whole-archive $wholeLibs -Wl,--no-whole-archive $libs $flags",
"-o $out $objs --whole-archive $wholeLibs --no-whole-archive $libs $flags",
),
}