diff options
author | 2024-11-13 16:09:23 -0800 | |
---|---|---|
committer | 2024-11-13 16:48:50 -0800 | |
commit | 4e9f5923c0e7cf0d7f845b90c7da65c24e44bcee (patch) | |
tree | 6d9fc3cdf89401a385e24e9e35ab67765cdef02d /filesystem/logical_partition.go | |
parent | 06540bb808debb9efe410e518ce9f420bac9042c (diff) |
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
Diffstat (limited to 'filesystem/logical_partition.go')
-rw-r--r-- | filesystem/logical_partition.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/filesystem/logical_partition.go b/filesystem/logical_partition.go index 988a57b08..d0888a9c8 100644 --- a/filesystem/logical_partition.go +++ b/filesystem/logical_partition.go @@ -32,7 +32,7 @@ type logicalPartition struct { properties logicalPartitionProperties - output android.OutputPath + output android.Path installDir android.InstallPath } @@ -95,11 +95,14 @@ func (l *logicalPartition) GenerateAndroidBuildActions(ctx android.ModuleContext 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 @@ func (l *logicalPartition) GenerateAndroidBuildActions(ctx android.ModuleContext 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'"). |