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
diff --git a/filesystem/logical_partition.go b/filesystem/logical_partition.go
index 988a57b..d0888a9 100644
--- a/filesystem/logical_partition.go
+++ b/filesystem/logical_partition.go
@@ -32,7 +32,7 @@
properties logicalPartitionProperties
- output android.OutputPath
+ output android.Path
installDir android.InstallPath
}
@@ -95,11 +95,14 @@
builder := android.NewRuleBuilder(pctx, ctx)
// Sparse the filesystem images and calculate their sizes
- sparseImages := make(map[string]android.OutputPath)
- sparseImageSizes := make(map[string]android.OutputPath)
+ sparseImages := make(map[string]android.Path)
+ sparseImageSizes := make(map[string]android.Path)
sparsePartitions := func(partitions []partitionProperties) {
for _, part := range partitions {
+ if part.Filesystem == nil {
+ continue
+ }
sparseImg, sizeTxt := sparseFilesystem(ctx, part, builder)
pName := proptools.String(part.Name)
sparseImages[pName] = sparseImg
@@ -185,31 +188,29 @@
addPartitionsToGroup(group.Partitions, gName)
}
- l.output = android.PathForModuleOut(ctx, l.installFileName()).OutputPath
- cmd.FlagWithOutput("--output=", l.output)
+ output := android.PathForModuleOut(ctx, l.installFileName())
+ cmd.FlagWithOutput("--output=", output)
builder.Build("build_logical_partition", fmt.Sprintf("Creating %s", l.BaseModuleName()))
l.installDir = android.PathForModuleInstall(ctx, "etc")
- ctx.InstallFile(l.installDir, l.installFileName(), l.output)
+ ctx.InstallFile(l.installDir, l.installFileName(), output)
- ctx.SetOutputFiles([]android.Path{l.output}, "")
+ ctx.SetOutputFiles([]android.Path{output}, "")
+ l.output = output
}
// Add a rule that converts the filesystem for the given partition to the given rule builder. The
// path to the sparse file and the text file having the size of the partition are returned.
-func sparseFilesystem(ctx android.ModuleContext, p partitionProperties, builder *android.RuleBuilder) (sparseImg android.OutputPath, sizeTxt android.OutputPath) {
- if p.Filesystem == nil {
- return
- }
- img := android.PathForModuleSrc(ctx, proptools.String(p.Filesystem))
+func sparseFilesystem(ctx android.ModuleContext, p partitionProperties, builder *android.RuleBuilder) (android.Path, android.Path) {
+ img := android.PathForModuleSrc(ctx, *p.Filesystem)
name := proptools.String(p.Name)
- sparseImg = android.PathForModuleOut(ctx, name+".img").OutputPath
+ sparseImg := android.PathForModuleOut(ctx, name+".img")
builder.Temporary(sparseImg)
builder.Command().BuiltTool("img2simg").Input(img).Output(sparseImg)
- sizeTxt = android.PathForModuleOut(ctx, name+"-size.txt").OutputPath
+ sizeTxt := android.PathForModuleOut(ctx, name+"-size.txt")
builder.Temporary(sizeTxt)
builder.Command().BuiltTool("sparse_img").Flag("--get_partition_size").Input(sparseImg).
Text("| ").Text("tr").FlagWithArg("-d ", "'\n'").