Optimize buildPropFile()
Use android.WriteFileRuleVerbatim instead of a custom RuleBuilder
with echo commands.
Test: m nothing --no-skip-soong-tests
Change-Id: I9734305cbb404fd2ae841af2525f0db235622315
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 6612a6f..795a0aa 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -311,18 +311,16 @@
}
func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.OutputPath, toolDeps android.Paths) {
- type prop struct {
- name string
- value string
- }
-
- var props []prop
var deps android.Paths
+ var propFileString strings.Builder
addStr := func(name string, value string) {
- props = append(props, prop{name, value})
+ propFileString.WriteString(name)
+ propFileString.WriteRune('=')
+ propFileString.WriteString(value)
+ propFileString.WriteRune('\n')
}
addPath := func(name string, path android.Path) {
- props = append(props, prop{name, path.String()})
+ addStr(name, path.String())
deps = append(deps, path)
}
@@ -376,15 +374,7 @@
addStr("hash_seed", uuid)
}
propFile = android.PathForModuleOut(ctx, "prop").OutputPath
- builder := android.NewRuleBuilder(pctx, ctx)
- builder.Command().Text("rm").Flag("-rf").Output(propFile)
- for _, p := range props {
- builder.Command().
- Text("echo").
- Flag(`"` + p.name + "=" + p.value + `"`).
- Text(">>").Output(propFile)
- }
- builder.Build("build_filesystem_prop", fmt.Sprintf("Creating filesystem props for %s", f.BaseModuleName()))
+ android.WriteFileRuleVerbatim(ctx, propFile, propFileString.String())
return propFile, deps
}