Revert "allow Ninja variables in RuleBuilder API"
Revert submission 2605644-rulebuilder-ninja-vars Reason for revert: b/299568218 Reverted changes: /q/submissionid:2605644-rulebuilder-ninja-vars Change-Id: Ia738c100b8431dea6151939a800b992f877b5bb8
This commit is contained in:
committed by
Gerrit Code Review
parent
1f9bb26656
commit
7b02d8159e
@@ -474,23 +474,13 @@ func (r *RuleBuilder) depFileMergerCmd(depFiles WritablePaths) *RuleBuilderComma
|
||||
Inputs(depFiles.Paths())
|
||||
}
|
||||
|
||||
// BuildWithNinjaVars adds the built command line to the build graph, with dependencies on Inputs and Tools, and output files for
|
||||
// Outputs. This function will not escape Ninja variables, so it may be used to write sandbox manifests using Ninja variables.
|
||||
func (r *RuleBuilder) BuildWithUnescapedNinjaVars(name string, desc string) {
|
||||
r.build(name, desc, false)
|
||||
}
|
||||
|
||||
// Build adds the built command line to the build graph, with dependencies on Inputs and Tools, and output files for
|
||||
// Outputs.
|
||||
func (r *RuleBuilder) Build(name string, desc string) {
|
||||
r.build(name, desc, true)
|
||||
}
|
||||
|
||||
func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString bool) {
|
||||
name = ninjaNameEscape(name)
|
||||
|
||||
if len(r.missingDeps) > 0 {
|
||||
r.ctx.Build(r.pctx, BuildParams{
|
||||
r.ctx.Build(pctx, BuildParams{
|
||||
Rule: ErrorRule,
|
||||
Outputs: r.Outputs(),
|
||||
Description: desc,
|
||||
@@ -629,35 +619,12 @@ func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString b
|
||||
name, r.sboxManifestPath.String(), r.outDir.String())
|
||||
}
|
||||
|
||||
// Create a rule to write the manifest as textproto.
|
||||
// Create a rule to write the manifest as a the textproto.
|
||||
pbText, err := prototext.Marshal(&manifest)
|
||||
if err != nil {
|
||||
ReportPathErrorf(r.ctx, "sbox manifest failed to marshal: %q", err)
|
||||
}
|
||||
if ninjaEscapeCommandString {
|
||||
WriteFileRule(r.ctx, r.sboxManifestPath, string(pbText))
|
||||
} else {
|
||||
// We need to have a rule to write files that is
|
||||
// defined on the RuleBuilder's pctx in order to
|
||||
// write Ninja variables in the string.
|
||||
// The WriteFileRule function above rule can only write
|
||||
// raw strings because it is defined on the android
|
||||
// package's pctx, and it can't access variables defined
|
||||
// in another context.
|
||||
r.ctx.Build(r.pctx, BuildParams{
|
||||
Rule: r.ctx.Rule(r.pctx, "unescapedWriteFile", blueprint.RuleParams{
|
||||
Command: `rm -rf ${out} && cat ${out}.rsp > ${out}`,
|
||||
Rspfile: "${out}.rsp",
|
||||
RspfileContent: "${content}",
|
||||
Description: "write file",
|
||||
}, "content"),
|
||||
Output: r.sboxManifestPath,
|
||||
Description: "write sbox manifest " + r.sboxManifestPath.Base(),
|
||||
Args: map[string]string{
|
||||
"content": string(pbText),
|
||||
},
|
||||
})
|
||||
}
|
||||
WriteFileRule(r.ctx, r.sboxManifestPath, string(pbText))
|
||||
|
||||
// Generate a new string to use as the command line of the sbox rule. This uses
|
||||
// a RuleBuilderCommand as a convenience method of building the command line, then
|
||||
@@ -757,7 +724,7 @@ func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString b
|
||||
}
|
||||
|
||||
r.ctx.Build(r.pctx, BuildParams{
|
||||
Rule: r.ctx.Rule(r.pctx, name, blueprint.RuleParams{
|
||||
Rule: r.ctx.Rule(pctx, name, blueprint.RuleParams{
|
||||
Command: proptools.NinjaEscape(commandString),
|
||||
CommandDeps: proptools.NinjaEscapeList(tools.Strings()),
|
||||
Restat: r.restat,
|
||||
|
Reference in New Issue
Block a user