aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-03-08 10:24:50 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-03-08 10:24:50 +0000
commit181a27986c8a18efe95ffca76facfd0d9034c697 (patch)
tree7ba72a3a1698a5899b898f67d5ecb749bf6c2acf
parent48872f5443ebbc62a3f2c771a65435113a82bbf2 (diff)
parentcec230a0eb2f2808e5c16c718d2213393beb9566 (diff)
downloadsoong-181a27986c8a18efe95ffca76facfd0d9034c697.tar.gz
Merge "Optimize buildPropFile()" into main
-rw-r--r--filesystem/filesystem.go24
1 files changed, 7 insertions, 17 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 6612a6f09..795a0aa02 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -311,18 +311,16 @@ func (f *filesystem) salt() string {
}
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 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.
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
}