Merge "bp2build/queryview: codegen control sequences literally." am: a5dcb03450
am: 8442e2a79c
am: 9ffae96f0b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1657881 Change-Id: If95509260666ea3ac027665836ee0b0e4f94315f
This commit is contained in:
commit
b9eef2ec4b
|
@ -568,6 +568,13 @@ func isZero(value reflect.Value) bool {
|
||||||
|
|
||||||
func escapeString(s string) string {
|
func escapeString(s string) string {
|
||||||
s = strings.ReplaceAll(s, "\\", "\\\\")
|
s = strings.ReplaceAll(s, "\\", "\\\\")
|
||||||
|
|
||||||
|
// b/184026959: Reverse the application of some common control sequences.
|
||||||
|
// These must be generated literally in the BUILD file.
|
||||||
|
s = strings.ReplaceAll(s, "\t", "\\t")
|
||||||
|
s = strings.ReplaceAll(s, "\n", "\\n")
|
||||||
|
s = strings.ReplaceAll(s, "\r", "\\r")
|
||||||
|
|
||||||
return strings.ReplaceAll(s, "\"", "\\\"")
|
return strings.ReplaceAll(s, "\"", "\\\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,22 @@ func TestGenerateBazelTargetModules(t *testing.T) {
|
||||||
"b",
|
"b",
|
||||||
],
|
],
|
||||||
string_prop = "a",
|
string_prop = "a",
|
||||||
|
)`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
bp: `custom {
|
||||||
|
name: "control_characters",
|
||||||
|
string_list_prop: ["\t", "\n"],
|
||||||
|
string_prop: "a\t\n\r",
|
||||||
|
bazel_module: { bp2build_available: true },
|
||||||
|
}`,
|
||||||
|
expectedBazelTarget: `custom(
|
||||||
|
name = "control_characters",
|
||||||
|
string_list_prop = [
|
||||||
|
"\t",
|
||||||
|
"\n",
|
||||||
|
],
|
||||||
|
string_prop = "a\t\n\r",
|
||||||
)`,
|
)`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue