Remove unescaped spans support from RuleBuilder
Now that rsp files use an explicit path instead of $out.rsp the
unescaped spans and NinjaEscapedCommands() support can be removed
from RuleBuilder.
Bug: 182612695
Test: rule_builder_test.go
Change-Id: I6705151ff0528c59aa1af56ee52c294da15a7a66
diff --git a/android/rule_builder.go b/android/rule_builder.go
index cc0bfa6..17f211b 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -409,16 +409,6 @@
return commands
}
-// NinjaEscapedCommands returns a slice containing the built command line after ninja escaping for each call to
-// RuleBuilder.Command.
-func (r *RuleBuilder) NinjaEscapedCommands() []string {
- var commands []string
- for _, c := range r.commands {
- commands = append(commands, c.NinjaEscapedString())
- }
- return commands
-}
-
// BuilderContext is a subset of ModuleContext and SingletonContext.
type BuilderContext interface {
PathContext
@@ -473,7 +463,7 @@
}
tools := r.Tools()
- commands := r.NinjaEscapedCommands()
+ commands := r.Commands()
outputs := r.Outputs()
inputs := r.Inputs()
rspFileInputs := r.RspFileInputs()
@@ -547,7 +537,7 @@
}
// Create a rule to write the manifest as a the textproto.
- WriteFileRule(r.ctx, r.sboxManifestPath, proto.MarshalTextString(&manifest))
+ WriteFileRule(r.ctx, r.sboxManifestPath, proptools.NinjaEscape(proto.MarshalTextString(&manifest)))
// 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
@@ -601,7 +591,7 @@
r.ctx.Build(r.pctx, BuildParams{
Rule: r.ctx.Rule(pctx, name, blueprint.RuleParams{
- Command: commandString,
+ Command: proptools.NinjaEscape(commandString),
CommandDeps: proptools.NinjaEscapeList(tools.Strings()),
Restat: r.restat,
Rspfile: proptools.NinjaEscape(rspFile),
@@ -637,9 +627,6 @@
packagedTools []PackagingSpec
rspFileInputs Paths
rspFile WritablePath
-
- // spans [start,end) of the command that should not be ninja escaped
- unescapedSpans [][2]int
}
func (c *RuleBuilderCommand) addInput(path Path) string {
@@ -1069,11 +1056,6 @@
return c.buf.String()
}
-// String returns the command line.
-func (c *RuleBuilderCommand) NinjaEscapedString() string {
- return ninjaEscapeExceptForSpans(c.String(), c.unescapedSpans)
-}
-
// RuleBuilderSboxProtoForTests takes the BuildParams for the manifest passed to RuleBuilder.Sbox()
// and returns sbox testproto generated by the RuleBuilder.
func RuleBuilderSboxProtoForTests(t *testing.T, params TestingBuildParams) *sbox_proto.Manifest {
@@ -1087,25 +1069,6 @@
return &manifest
}
-func ninjaEscapeExceptForSpans(s string, spans [][2]int) string {
- if len(spans) == 0 {
- return proptools.NinjaEscape(s)
- }
-
- sb := strings.Builder{}
- sb.Grow(len(s) * 11 / 10)
-
- i := 0
- for _, span := range spans {
- sb.WriteString(proptools.NinjaEscape(s[i:span[0]]))
- sb.WriteString(s[span[0]:span[1]])
- i = span[1]
- }
- sb.WriteString(proptools.NinjaEscape(s[i:]))
-
- return sb.String()
-}
-
func ninjaNameEscape(s string) string {
b := []byte(s)
escaped := false