NinjaEscapeList is called on every input or output of a rule, and
most of the time does not escape anything. Optimize it by returning
the input slice when nothing was escaped. This avoids 1.336 GB of
allocations in my AOSP aosp_cf_x86_64_phone-userdebug build.
Test: TestNinjaEscapeList
Change-Id: I33b9e7b77b33d10401d1ec3546caa6794c567b16
Add a method that ninja and shell escapes each entry in a list
of strings as a single argument.
Test: escape_test.go
Change-Id: Iac05c64f1ae48cd6186f563790ea49b90618038d
ShellEscape(string) doesn't escape a string with spaces like "arg1
arg2". However, when we want to escape a string to use it as an
argument, then strings with spaces should be escaped.
For example,
"command " + ShellEscapeIncludingSpaces("a b")
becomes "command 'a b'" so that "command" will get "a b" as a single
argument.
Bug: 182092664
Test: Added tests to escape_test.go
Change-Id: I8f88c18bc4f9f7aacfe9e701b8f0876dd8b9a8c3
NinjaEscape and ShellEscape operated on lists, which led to
awkward NinjaEscape([]string{s})[0]. Replace NinjaEscape
and ShellEscape with NinjaEscapeList and ShellEscapeList,
and add new NinjaEscape and ShellEscape functions that
operate on a string.
Test: m checkbuild
Change-Id: I283d92cdddc8e0066a300015863a3eab66f77c23
Blueprint properties that end up as command line arguments need to be
both ninja and shell escaped. Provide helpers that primary builders can
use to appropriately escape them.
Change-Id: Ifd697d87edb1c6f0a910377835c391bbe8f95b42