Replace android.WriteFile rule with android.WriteFileRule
The android.WriteFile rule takes careful escaping to produce the
right contents. Wrap it in an android.WriteFileRule that handles
the escaping.
Test: compare all android.WriteFile outputs
Change-Id: If71a5843af47a37ca61714e1a1ebb32d08536c31
diff --git a/cc/cc_test.go b/cc/cc_test.go
index b803cba..f616cf3 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -296,8 +296,8 @@
func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expected []string) {
t.Helper()
- assertString(t, params.Rule.String(), android.WriteFile.String())
- actual := strings.FieldsFunc(strings.ReplaceAll(params.Args["content"], "\\n", "\n"), func(r rune) bool { return r == '\n' })
+ content := android.ContentFromFileRuleForTests(t, params)
+ actual := strings.FieldsFunc(content, func(r rune) bool { return r == '\n' })
assertArrayString(t, actual, expected)
}
diff --git a/cc/fuzz.go b/cc/fuzz.go
index fe3c12b..dddfe94 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -278,14 +278,7 @@
if fuzz.Properties.Fuzz_config != nil {
configPath := android.PathForModuleOut(ctx, "config").Join(ctx, "config.json")
- ctx.Build(pctx, android.BuildParams{
- Rule: android.WriteFile,
- Description: "fuzzer infrastructure configuration",
- Output: configPath,
- Args: map[string]string{
- "content": fuzz.Properties.Fuzz_config.String(),
- },
- })
+ android.WriteFileRule(ctx, configPath, fuzz.Properties.Fuzz_config.String())
fuzz.config = configPath
}
diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go
index 238508d..05c06ac 100644
--- a/cc/snapshot_utils.go
+++ b/cc/snapshot_utils.go
@@ -93,13 +93,6 @@
func writeStringToFile(ctx android.SingletonContext, content, out string) android.OutputPath {
outPath := android.PathForOutput(ctx, out)
- ctx.Build(pctx, android.BuildParams{
- Rule: android.WriteFile,
- Output: outPath,
- Description: "WriteFile " + out,
- Args: map[string]string{
- "content": content,
- },
- })
+ android.WriteFileRule(ctx, outPath, content)
return outPath
}
diff --git a/cc/vndk.go b/cc/vndk.go
index 2cac03c..4a005f3 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -487,14 +487,7 @@
}
txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
- ctx.Build(pctx, android.BuildParams{
- Rule: android.WriteFile,
- Output: txt.outputFile,
- Description: "Writing " + txt.outputFile.String(),
- Args: map[string]string{
- "content": strings.Join(list, "\\n"),
- },
- })
+ android.WriteFileRule(ctx, txt.outputFile, strings.Join(list, "\n"))
installPath := android.PathForModuleInstall(ctx, "etc")
ctx.InstallFile(installPath, filename, txt.outputFile)
@@ -825,14 +818,7 @@
merged = append(merged, addPrefix(filterOutLibClangRt(vndkcore), "VNDK-core: ")...)
merged = append(merged, addPrefix(vndkprivate, "VNDK-private: ")...)
c.vndkLibrariesFile = android.PathForOutput(ctx, "vndk", "vndk.libraries.txt")
- ctx.Build(pctx, android.BuildParams{
- Rule: android.WriteFile,
- Output: c.vndkLibrariesFile,
- Description: "Writing " + c.vndkLibrariesFile.String(),
- Args: map[string]string{
- "content": strings.Join(merged, "\\n"),
- },
- })
+ android.WriteFileRule(ctx, c.vndkLibrariesFile, strings.Join(merged, "\n"))
}
func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {