Merge "Optimize buildPropFile()" into main

This commit is contained in:
Treehugger Robot
2024-03-08 10:24:50 +00:00
committed by Gerrit Code Review

View File

@@ -311,18 +311,16 @@ func (f *filesystem) salt() string {
} }
func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.OutputPath, toolDeps android.Paths) { 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 deps android.Paths
var propFileString strings.Builder
addStr := func(name string, value string) { 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) { addPath := func(name string, path android.Path) {
props = append(props, prop{name, path.String()}) addStr(name, path.String())
deps = append(deps, path) deps = append(deps, path)
} }
@@ -376,15 +374,7 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.
addStr("hash_seed", uuid) addStr("hash_seed", uuid)
} }
propFile = android.PathForModuleOut(ctx, "prop").OutputPath propFile = android.PathForModuleOut(ctx, "prop").OutputPath
builder := android.NewRuleBuilder(pctx, ctx) android.WriteFileRuleVerbatim(ctx, propFile, propFileString.String())
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()))
return propFile, deps return propFile, deps
} }