Optimize buildPropFile()
Use android.WriteFileRuleVerbatim instead of a custom RuleBuilder with echo commands. Test: m nothing --no-skip-soong-tests Change-Id: I9734305cbb404fd2ae841af2525f0db235622315
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user