conditionally escape rule builder command

For rules which use RuleBuilder with Ninja variables (using the
BuildWithUnescapedNinjaVars function) but are not sandboxed, the command
output by RuleBuilder must not be escaped, or else Ninja variables will
not be evaluated until they are run on the command line.

Test: m libnum_traits liboid_registry crosvm droid
Change-Id: I81611368ab1975220f7f517df2f57646deac2af8
This commit is contained in:
Sam Delmerico 2023-09-14 21:34:13 +00:00
parent 0e2d63e4d2
commit d96a60685a

View file

@ -756,9 +756,13 @@ func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString b
pool = localPool
}
if ninjaEscapeCommandString {
commandString = proptools.NinjaEscape(commandString)
}
r.ctx.Build(r.pctx, BuildParams{
Rule: r.ctx.Rule(r.pctx, name, blueprint.RuleParams{
Command: proptools.NinjaEscape(commandString),
Command: commandString,
CommandDeps: proptools.NinjaEscapeList(tools.Strings()),
Restat: r.restat,
Rspfile: proptools.NinjaEscape(rspFile),