diff options
Diffstat (limited to 'filesystem')
-rw-r--r-- | filesystem/avb_add_hash_footer.go | 11 | ||||
-rw-r--r-- | filesystem/avb_gen_vbmeta_image.go | 9 | ||||
-rw-r--r-- | filesystem/bootimg.go | 24 | ||||
-rw-r--r-- | filesystem/filesystem.go | 29 | ||||
-rw-r--r-- | filesystem/fsverity_metadata.go | 6 | ||||
-rw-r--r-- | filesystem/logical_partition.go | 29 | ||||
-rw-r--r-- | filesystem/raw_binary.go | 10 | ||||
-rw-r--r-- | filesystem/vbmeta.go | 14 |
8 files changed, 68 insertions, 64 deletions
diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go index 469f1fb0a..9d4ba3e95 100644 --- a/filesystem/avb_add_hash_footer.go +++ b/filesystem/avb_add_hash_footer.go @@ -29,7 +29,7 @@ type avbAddHashFooter struct { properties avbAddHashFooterProperties - output android.OutputPath + output android.Path installDir android.InstallPath } @@ -97,8 +97,8 @@ func (a *avbAddHashFooter) GenerateAndroidBuildActions(ctx android.ModuleContext return } input := android.PathForModuleSrc(ctx, proptools.String(a.properties.Src)) - a.output = android.PathForModuleOut(ctx, a.installFileName()).OutputPath - builder.Command().Text("cp").Input(input).Output(a.output) + output := android.PathForModuleOut(ctx, a.installFileName()) + builder.Command().Text("cp").Input(input).Output(output) cmd := builder.Command().BuiltTool("avbtool").Text("add_hash_footer") @@ -141,12 +141,13 @@ func (a *avbAddHashFooter) GenerateAndroidBuildActions(ctx android.ModuleContext cmd.Flag(fmt.Sprintf(" --rollback_index %d", rollbackIndex)) } - cmd.FlagWithOutput("--image ", a.output) + cmd.FlagWithOutput("--image ", output) builder.Build("avbAddHashFooter", fmt.Sprintf("avbAddHashFooter %s", ctx.ModuleName())) a.installDir = android.PathForModuleInstall(ctx, "etc") - ctx.InstallFile(a.installDir, a.installFileName(), a.output) + ctx.InstallFile(a.installDir, a.installFileName(), output) + a.output = output } func addAvbProp(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, prop avbProp) { diff --git a/filesystem/avb_gen_vbmeta_image.go b/filesystem/avb_gen_vbmeta_image.go index a7fd7829e..0669a2c20 100644 --- a/filesystem/avb_gen_vbmeta_image.go +++ b/filesystem/avb_gen_vbmeta_image.go @@ -28,7 +28,7 @@ type avbGenVbmetaImage struct { properties avbGenVbmetaImageProperties - output android.OutputPath + output android.Path installDir android.InstallPath } @@ -78,11 +78,12 @@ func (a *avbGenVbmetaImage) GenerateAndroidBuildActions(ctx android.ModuleContex } cmd.FlagWithArg("--salt ", proptools.String(a.properties.Salt)) - a.output = android.PathForModuleOut(ctx, a.installFileName()).OutputPath - cmd.FlagWithOutput("--output_vbmeta_image ", a.output) + output := android.PathForModuleOut(ctx, a.installFileName()) + cmd.FlagWithOutput("--output_vbmeta_image ", output) builder.Build("avbGenVbmetaImage", fmt.Sprintf("avbGenVbmetaImage %s", ctx.ModuleName())) - ctx.SetOutputFiles([]android.Path{a.output}, "") + ctx.SetOutputFiles([]android.Path{output}, "") + a.output = output } var _ android.AndroidMkEntriesProvider = (*avbGenVbmetaImage)(nil) diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go index 9d9392596..c9bd61788 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go @@ -34,7 +34,7 @@ type bootimg struct { properties bootimgProperties - output android.OutputPath + output android.Path installDir android.InstallPath } @@ -115,20 +115,20 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { vendor := proptools.Bool(b.properties.Vendor_boot) unsignedOutput := b.buildBootImage(ctx, vendor) + output := unsignedOutput if proptools.Bool(b.properties.Use_avb) { - b.output = b.signImage(ctx, unsignedOutput) - } else { - b.output = unsignedOutput + output = b.signImage(ctx, unsignedOutput) } b.installDir = android.PathForModuleInstall(ctx, "etc") - ctx.InstallFile(b.installDir, b.installFileName(), b.output) + ctx.InstallFile(b.installDir, b.installFileName(), output) - ctx.SetOutputFiles([]android.Path{b.output}, "") + ctx.SetOutputFiles([]android.Path{output}, "") + b.output = output } -func (b *bootimg) buildBootImage(ctx android.ModuleContext, vendor bool) android.OutputPath { - output := android.PathForModuleOut(ctx, "unsigned", b.installFileName()).OutputPath +func (b *bootimg) buildBootImage(ctx android.ModuleContext, vendor bool) android.Path { + output := android.PathForModuleOut(ctx, "unsigned", b.installFileName()) builder := android.NewRuleBuilder(pctx, ctx) cmd := builder.Command().BuiltTool("mkbootimg") @@ -215,10 +215,10 @@ func (b *bootimg) buildBootImage(ctx android.ModuleContext, vendor bool) android return output } -func (b *bootimg) signImage(ctx android.ModuleContext, unsignedImage android.OutputPath) android.OutputPath { +func (b *bootimg) signImage(ctx android.ModuleContext, unsignedImage android.Path) android.Path { propFile, toolDeps := b.buildPropFile(ctx) - output := android.PathForModuleOut(ctx, b.installFileName()).OutputPath + output := android.PathForModuleOut(ctx, b.installFileName()) builder := android.NewRuleBuilder(pctx, ctx) builder.Command().Text("cp").Input(unsignedImage).Output(output) builder.Command().BuiltTool("verity_utils"). @@ -239,7 +239,7 @@ func (b *bootimg) salt() string { return sha1sum(input) } -func (b *bootimg) buildPropFile(ctx android.ModuleContext) (propFile android.OutputPath, toolDeps android.Paths) { +func (b *bootimg) buildPropFile(ctx android.ModuleContext) (android.Path, android.Paths) { var sb strings.Builder var deps android.Paths addStr := func(name string, value string) { @@ -261,7 +261,7 @@ func (b *bootimg) buildPropFile(ctx android.ModuleContext) (propFile android.Out addStr("partition_name", partitionName) addStr("avb_salt", b.salt()) - propFile = android.PathForModuleOut(ctx, "prop").OutputPath + propFile := android.PathForModuleOut(ctx, "prop") android.WriteFileRule(ctx, propFile, sb.String()) return propFile, deps } diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index fa6645187..c34677060 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -52,10 +52,10 @@ type filesystem struct { properties FilesystemProperties - output android.OutputPath + output android.Path installDir android.InstallPath - fileListFile android.OutputPath + fileListFile android.Path // Keeps the entries installed from this filesystem entries []string @@ -340,19 +340,20 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.InstallFile(f.installDir, f.installFileName(), f.output) ctx.SetOutputFiles([]android.Path{f.output}, "") - f.fileListFile = android.PathForModuleOut(ctx, "fileList").OutputPath - android.WriteFileRule(ctx, f.fileListFile, f.installedFilesList()) + fileListFile := android.PathForModuleOut(ctx, "fileList") + android.WriteFileRule(ctx, fileListFile, f.installedFilesList()) android.SetProvider(ctx, FilesystemProvider, FilesystemInfo{ - FileListFile: f.fileListFile, + FileListFile: fileListFile, }) + f.fileListFile = fileListFile if proptools.Bool(f.properties.Unchecked_module) { ctx.UncheckedModule() } } -func (f *filesystem) appendToEntry(ctx android.ModuleContext, installedFile android.OutputPath) { +func (f *filesystem) appendToEntry(ctx android.ModuleContext, installedFile android.Path) { partitionBaseDir := android.PathForModuleOut(ctx, "root", f.partitionName()).String() + "/" relPath, inTargetPartition := strings.CutPrefix(installedFile.String(), partitionBaseDir) @@ -443,7 +444,7 @@ func (f *filesystem) copyFilesToProductOut(ctx android.ModuleContext, builder *a builder.Command().Textf("cp -prf %s/* %s", rebasedDir, installPath) } -func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.OutputPath { +func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.Path { rootDir := android.PathForModuleOut(ctx, "root").OutputPath rebasedDir := rootDir if f.properties.Base_dir != nil { @@ -472,7 +473,7 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) androi FlagWithArg("--out_system=", rootDir.String()+"/system") propFile, toolDeps := f.buildPropFile(ctx) - output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath + output := android.PathForModuleOut(ctx, f.installFileName()) builder.Command().BuiltTool("build_image"). Text(rootDir.String()). // input directory Input(propFile). @@ -486,14 +487,14 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) androi return output } -func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.OutputPath { +func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path { builder := android.NewRuleBuilder(pctx, ctx) fcBin := android.PathForModuleOut(ctx, "file_contexts.bin") builder.Command().BuiltTool("sefcontext_compile"). FlagWithOutput("-o ", fcBin). Input(android.PathForModuleSrc(ctx, proptools.String(f.properties.File_contexts))) builder.Build("build_filesystem_file_contexts", fmt.Sprintf("Creating filesystem file contexts for %s", f.BaseModuleName())) - return fcBin.OutputPath + return fcBin } // Calculates avb_salt from entry list (sorted) for deterministic output. @@ -501,7 +502,7 @@ func (f *filesystem) salt() string { return sha1sum(f.entries) } -func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android.OutputPath, toolDeps android.Paths) { +func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, android.Paths) { var deps android.Paths var propFileString strings.Builder addStr := func(name string, value string) { @@ -597,7 +598,7 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android. } f.checkFsTypePropertyError(ctx, fst, fsTypeStr(fst)) - propFile = android.PathForModuleOut(ctx, "prop").OutputPath + propFile := android.PathForModuleOut(ctx, "prop") android.WriteFileRuleVerbatim(ctx, propFile, propFileString.String()) return propFile, deps } @@ -622,7 +623,7 @@ func (f *filesystem) checkFsTypePropertyError(ctx android.ModuleContext, t fsTyp } } -func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) android.OutputPath { +func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) android.Path { if proptools.Bool(f.properties.Use_avb) { ctx.PropertyErrorf("use_avb", "signing compresed cpio image using avbtool is not supported."+ "Consider adding this to bootimg module and signing the entire boot image.") @@ -654,7 +655,7 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir) f.copyFilesToProductOut(ctx, builder, rebasedDir) - output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath + output := android.PathForModuleOut(ctx, f.installFileName()) cmd := builder.Command(). BuiltTool("mkbootfs"). Text(rootDir.String()) // input directory diff --git a/filesystem/fsverity_metadata.go b/filesystem/fsverity_metadata.go index 199c84516..3119f2f28 100644 --- a/filesystem/fsverity_metadata.go +++ b/filesystem/fsverity_metadata.go @@ -33,7 +33,7 @@ type fsverityProperties struct { Libs []string `android:"path"` } -func (f *filesystem) writeManifestGeneratorListFile(ctx android.ModuleContext, outputPath android.OutputPath, matchedSpecs []android.PackagingSpec, rebasedDir android.OutputPath) { +func (f *filesystem) writeManifestGeneratorListFile(ctx android.ModuleContext, outputPath android.WritablePath, matchedSpecs []android.PackagingSpec, rebasedDir android.OutputPath) { var buf strings.Builder for _, spec := range matchedSpecs { buf.WriteString(rebasedDir.Join(ctx, spec.RelPathInPackage()).String()) @@ -113,12 +113,12 @@ func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, build f.appendToEntry(ctx, manifestPbPath) manifestGeneratorListPath := android.PathForModuleOut(ctx, "fsverity_manifest.list") - f.writeManifestGeneratorListFile(ctx, manifestGeneratorListPath.OutputPath, matchedSpecs, rebasedDir) + f.writeManifestGeneratorListFile(ctx, manifestGeneratorListPath, matchedSpecs, rebasedDir) sb.WriteRune('@') sb.WriteString(manifestGeneratorListPath.String()) sb.WriteRune('\n') cmd.Implicit(manifestGeneratorListPath) - f.appendToEntry(ctx, manifestGeneratorListPath.OutputPath) + f.appendToEntry(ctx, manifestGeneratorListPath) // STEP 2-2: generate BuildManifest.apk (unsigned) aapt2Path := ctx.Config().HostToolPath(ctx, "aapt2") 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'"). diff --git a/filesystem/raw_binary.go b/filesystem/raw_binary.go index ad36c2935..707fba06f 100644 --- a/filesystem/raw_binary.go +++ b/filesystem/raw_binary.go @@ -42,7 +42,7 @@ type rawBinary struct { properties rawBinaryProperties - output android.OutputPath + output android.Path installDir android.InstallPath } @@ -71,7 +71,7 @@ func (r *rawBinary) installFileName() string { func (r *rawBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) { inputFile := android.PathForModuleSrc(ctx, proptools.String(r.properties.Src)) - outputFile := android.PathForModuleOut(ctx, r.installFileName()).OutputPath + outputFile := android.PathForModuleOut(ctx, r.installFileName()) ctx.Build(pctx, android.BuildParams{ Rule: toRawBinary, @@ -83,11 +83,11 @@ func (r *rawBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) { }, }) - r.output = outputFile r.installDir = android.PathForModuleInstall(ctx, "etc") - ctx.InstallFile(r.installDir, r.installFileName(), r.output) + ctx.InstallFile(r.installDir, r.installFileName(), outputFile) - ctx.SetOutputFiles([]android.Path{r.output}, "") + ctx.SetOutputFiles([]android.Path{outputFile}, "") + r.output = outputFile } var _ android.AndroidMkEntriesProvider = (*rawBinary)(nil) diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go index ebb3ff951..6a4785933 100644 --- a/filesystem/vbmeta.go +++ b/filesystem/vbmeta.go @@ -44,7 +44,7 @@ type vbmeta struct { properties VbmetaProperties - output android.OutputPath + output android.Path installDir android.InstallPath } @@ -161,8 +161,6 @@ func (v *vbmeta) partitionName() string { const vbmetaMaxSize = 64 * 1024 func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { - v.output = android.PathForModuleOut(ctx, v.installFileName()).OutputPath - builder := android.NewRuleBuilder(pctx, ctx) cmd := builder.Command().BuiltTool("avbtool").Text("make_vbmeta_image") @@ -274,18 +272,19 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { cmd.Implicit(publicKey) } - cmd.FlagWithOutput("--output ", v.output) + output := android.PathForModuleOut(ctx, v.installFileName()) + cmd.FlagWithOutput("--output ", output) // libavb expects to be able to read the maximum vbmeta size, so we must provide a partition // which matches this or the read will fail. builder.Command().Text("truncate"). FlagWithArg("-s ", strconv.Itoa(vbmetaMaxSize)). - Output(v.output) + Output(output) builder.Build("vbmeta", fmt.Sprintf("vbmeta %s", ctx.ModuleName())) v.installDir = android.PathForModuleInstall(ctx, "etc") - ctx.InstallFile(v.installDir, v.installFileName(), v.output) + ctx.InstallFile(v.installDir, v.installFileName(), output) extractedPublicKey := android.PathForModuleOut(ctx, v.partitionName()+".avbpubkey") ctx.Build(pctx, android.BuildParams{ @@ -300,7 +299,8 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { PublicKey: extractedPublicKey, }) - ctx.SetOutputFiles([]android.Path{v.output}, "") + ctx.SetOutputFiles([]android.Path{output}, "") + v.output = output } // Returns the embedded shell command that prints the rollback index |