Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cec230a0 authored by Cole Faust's avatar Cole Faust
Browse files

Optimize buildPropFile()

Use android.WriteFileRuleVerbatim instead of a custom RuleBuilder
with echo commands.

Test: m nothing --no-skip-soong-tests
Change-Id: I9734305cbb404fd2ae841af2525f0db235622315
parent 092c3a56
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -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
}