Defer \n quoting generatedContents until creating the ninja rule
Previously, when writing to generatedContents \n characters were
quoted (replaced with \\n) so as to allow them to be preserved through
ninja/rsp/bash and were unquoted (replaced \\n with \n) just before
redirecting to the output file. That meant that any code which wanted
to access the contents for other purposes, e.g. testing had to unquote
\\n.
This change moves the quoting to be part of the code that generates the
ninja rule which simplifies any other code that has to access the
contents.
Without quoting the generated Android.bp files are not formatted
properly, are all on one line and completely unreadable.
Bug: 156286550
Test: m art-module-sdk and check generated Android.bp file to make sure
it is properly formatted.
Merged-In: I768c3b96ed08a3daf251730e2a10d9d72338c49a
Change-Id: I768c3b96ed08a3daf251730e2a10d9d72338c49a
(cherry picked from commit 1110827b3f30bffb6cb811e8cb79bb03ac7d1f86)
diff --git a/sdk/testing.go b/sdk/testing.go
index 14a397c..4361754 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -207,7 +207,7 @@
// e.g. find the src/dest pairs from each cp command, the various zip files
// generated, etc.
func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo {
- androidBpContents := strings.NewReplacer("\\n", "\n").Replace(sdk.GetAndroidBpContentsForTests())
+ androidBpContents := sdk.GetAndroidBpContentsForTests()
info := &snapshotBuildInfo{
r: r,