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

Commit 4e9f5923 authored by Cole Faust's avatar Cole Faust
Browse files

Use fewer OutputPaths

A lot of the time, you really mean android.Path or android.WriteablePath
instead of OutputPath.

Also, many modules were holding onto OutputPaths/WriteablePaths
after the files had already been generated, meaning they should no
longer be treated as writable paths and are instead inputs into other
actions. Change the type of those paths to just android.Path.

Test: verified ninja files were unchanged on aosp_arm64-trunk_staging-userdebug
Change-Id: Id773171bef59d855ba33c4b85cef268031cbec39
parent 06540bb8
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ func registerBuildFlagsModuleType(ctx android.RegistrationContext) {
type buildFlags struct {
	android.ModuleBase

	outputPath android.OutputPath
	outputPath android.Path
}

func buildFlagsFactory() android.Module {
@@ -48,7 +48,7 @@ func (m *buildFlags) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	// Read the build_flags_<partition>.json file generated by soong
	// 'release-config' command.
	srcPath := android.PathForOutput(ctx, "release-config", fmt.Sprintf("build_flags_%s.json", m.PartitionTag(ctx.DeviceConfig())))
	m.outputPath = android.PathForModuleOut(ctx, outJsonFileName).OutputPath
	outputPath := android.PathForModuleOut(ctx, outJsonFileName)

	// The 'release-config' command is called for every build, and generates the
	// build_flags_<partition>.json file.
@@ -56,11 +56,12 @@ func (m *buildFlags) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	ctx.Build(pctx, android.BuildParams{
		Rule:   android.CpIfChanged,
		Input:  srcPath,
		Output: m.outputPath,
		Output: outputPath,
	})

	installPath := android.PathForModuleInstall(ctx, "etc")
	ctx.InstallFile(installPath, outJsonFileName, m.outputPath)
	ctx.InstallFile(installPath, outJsonFileName, outputPath)
	m.outputPath = outputPath
}

func (m *buildFlags) AndroidMkEntries() []android.AndroidMkEntries {
+9 −7
Original line number Diff line number Diff line
@@ -896,8 +896,8 @@ type ApexModuleDepInfo struct {
type DepNameToDepInfoMap map[string]ApexModuleDepInfo

type ApexBundleDepsInfo struct {
	flatListPath OutputPath
	fullListPath OutputPath
	flatListPath Path
	fullListPath Path
}

type ApexBundleDepsInfoIntf interface {
@@ -934,13 +934,15 @@ func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, minSdkVersion
		fmt.Fprintf(&flatContent, "%s\n", toName)
	}

	d.fullListPath = PathForModuleOut(ctx, "depsinfo", "fulllist.txt").OutputPath
	WriteFileRule(ctx, d.fullListPath, fullContent.String())
	fullListPath := PathForModuleOut(ctx, "depsinfo", "fulllist.txt")
	WriteFileRule(ctx, fullListPath, fullContent.String())
	d.fullListPath = fullListPath

	d.flatListPath = PathForModuleOut(ctx, "depsinfo", "flatlist.txt").OutputPath
	WriteFileRule(ctx, d.flatListPath, flatContent.String())
	flatListPath := PathForModuleOut(ctx, "depsinfo", "flatlist.txt")
	WriteFileRule(ctx, flatListPath, flatContent.String())
	d.flatListPath = flatListPath

	ctx.Phony(fmt.Sprintf("%s-depsinfo", ctx.ModuleName()), d.fullListPath, d.flatListPath)
	ctx.Phony(fmt.Sprintf("%s-depsinfo", ctx.ModuleName()), fullListPath, flatListPath)
}

// Function called while walking an APEX's payload dependencies.
+8 −7
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ type buildPropModule struct {

	properties buildPropProperties

	outputFilePath OutputPath
	outputFilePath Path
	installPath    InstallPath
}

@@ -128,7 +128,7 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
		ctx.ModuleErrorf("Android_info cannot be set if build.prop is not installed in vendor partition")
	}

	p.outputFilePath = PathForModuleOut(ctx, "build.prop").OutputPath
	outputFilePath := PathForModuleOut(ctx, "build.prop")

	partition := p.partition(ctx.DeviceConfig())

@@ -157,7 +157,7 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
	cmd.FlagWithInput("--product-config=", PathForModuleSrc(ctx, proptools.String(p.properties.Product_config)))
	cmd.FlagWithArg("--partition=", partition)
	cmd.FlagForEachInput("--prop-files=", p.propFiles(ctx))
	cmd.FlagWithOutput("--out=", p.outputFilePath)
	cmd.FlagWithOutput("--out=", outputFilePath)

	postProcessCmd := rule.Command().BuiltTool("post_process_props")
	if ctx.DeviceConfig().BuildBrokenDupSysprop() {
@@ -170,17 +170,18 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
		// still need to pass an empty string to kernel-version-file-for-uffd-gc
		postProcessCmd.FlagWithArg("--kernel-version-file-for-uffd-gc ", `""`)
	}
	postProcessCmd.Text(p.outputFilePath.String())
	postProcessCmd.Text(outputFilePath.String())
	postProcessCmd.Flags(p.properties.Block_list)

	rule.Command().Text("echo").Text(proptools.NinjaAndShellEscape("# end of file")).FlagWithArg(">> ", p.outputFilePath.String())
	rule.Command().Text("echo").Text(proptools.NinjaAndShellEscape("# end of file")).FlagWithArg(">> ", outputFilePath.String())

	rule.Build(ctx.ModuleName(), "generating build.prop")

	p.installPath = PathForModuleInstall(ctx, proptools.String(p.properties.Relative_install_path))
	ctx.InstallFile(p.installPath, p.stem(), p.outputFilePath)
	ctx.InstallFile(p.installPath, p.stem(), outputFilePath)

	ctx.SetOutputFiles(Paths{p.outputFilePath}, "")
	ctx.SetOutputFiles(Paths{outputFilePath}, "")
	p.outputFilePath = outputFilePath
}

func (p *buildPropModule) AndroidMkEntries() []AndroidMkEntries {
+2 −2
Original line number Diff line number Diff line
@@ -30,11 +30,11 @@ type csuiteConfigProperties struct {
type CSuiteConfig struct {
	ModuleBase
	properties     csuiteConfigProperties
	OutputFilePath OutputPath
	OutputFilePath Path
}

func (me *CSuiteConfig) GenerateAndroidBuildActions(ctx ModuleContext) {
	me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath
	me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName())
}

func (me *CSuiteConfig) AndroidMkEntries() []AndroidMkEntries {
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ func (p *productConfigModule) GenerateAndroidBuildActions(ctx ModuleContext) {
		ctx.ModuleErrorf("There can only be one product_config module in build/soong")
		return
	}
	outputFilePath := PathForModuleOut(ctx, p.Name()+".json").OutputPath
	outputFilePath := PathForModuleOut(ctx, p.Name()+".json")

	// DeviceProduct can be null so calling ctx.Config().DeviceProduct() may cause null dereference
	targetProduct := proptools.String(ctx.Config().config.productVariables.DeviceProduct)
Loading