From 4e9f5923c0e7cf0d7f845b90c7da65c24e44bcee Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Wed, 13 Nov 2024 16:09:23 -0800 Subject: 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 --- apex/builder.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'apex/builder.go') diff --git a/apex/builder.go b/apex/builder.go index b04a9d729..4585cbbe3 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -388,7 +388,7 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, // file for this APEX which is either from /systme/sepolicy/apex/-file_contexts or from // the file_contexts property of this APEX. This is to make sure that the manifest file is correctly // labeled as system_file or vendor_apex_metadata_file. -func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.OutputPath { +func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Path { var fileContexts android.Path var fileContextsDir string isFileContextsModule := false @@ -443,13 +443,13 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output } rule.Build("file_contexts."+a.Name(), "Generate file_contexts") - return output.OutputPath + return output } // buildInstalledFilesFile creates a build rule for the installed-files.txt file where the list of // files included in this APEX is shown. The text file is dist'ed so that people can see what's // included in the APEX without actually downloading and extracting it. -func (a *apexBundle) buildInstalledFilesFile(ctx android.ModuleContext, builtApex android.Path, imageDir android.Path) android.OutputPath { +func (a *apexBundle) buildInstalledFilesFile(ctx android.ModuleContext, builtApex android.Path, imageDir android.Path) android.Path { output := android.PathForModuleOut(ctx, "installed-files.txt") rule := android.NewRuleBuilder(pctx, ctx) rule.Command(). @@ -459,12 +459,12 @@ func (a *apexBundle) buildInstalledFilesFile(ctx android.ModuleContext, builtApe Text(" | sort -nr > "). Output(output) rule.Build("installed-files."+a.Name(), "Installed files") - return output.OutputPath + return output } // buildBundleConfig creates a build rule for the bundle config file that will control the bundle // creation process. -func (a *apexBundle) buildBundleConfig(ctx android.ModuleContext) android.OutputPath { +func (a *apexBundle) buildBundleConfig(ctx android.ModuleContext) android.Path { output := android.PathForModuleOut(ctx, "bundle_config.json") type ApkConfig struct { @@ -509,7 +509,7 @@ func (a *apexBundle) buildBundleConfig(ctx android.ModuleContext) android.Output android.WriteFileRule(ctx, output, string(j)) - return output.OutputPath + return output } func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android.Path) android.Path { @@ -922,17 +922,17 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) { args["outCommaList"] = signedOutputFile.String() } var validations android.Paths - validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath)) + validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile, imageDir)) // TODO(b/279688635) deapexer supports [ext4] if !a.testApex && suffix == imageApexSuffix && ext4 == a.payloadFsType { - validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath)) + validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile)) } if !a.testApex && len(a.properties.Unwanted_transitive_deps) > 0 { validations = append(validations, - runApexElfCheckerUnwanted(ctx, unsignedOutputFile.OutputPath, a.properties.Unwanted_transitive_deps)) + runApexElfCheckerUnwanted(ctx, unsignedOutputFile, a.properties.Unwanted_transitive_deps)) } if !a.testApex && android.InList(a.payloadFsType, []fsType{ext4, erofs}) { - validations = append(validations, runApexHostVerifier(ctx, a, unsignedOutputFile.OutputPath)) + validations = append(validations, runApexHostVerifier(ctx, a, unsignedOutputFile)) } ctx.Build(pctx, android.BuildParams{ Rule: rule, @@ -1135,7 +1135,7 @@ func (a *apexBundle) buildLintReports(ctx android.ModuleContext) { a.lintReports = java.BuildModuleLintReportZips(ctx, depSets, validations) } -func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.OutputPath { +func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.Path { var readOnlyPaths = []string{"apex_manifest.json", "apex_manifest.pb"} var executablePaths []string // this also includes dirs var appSetDirs []string @@ -1199,10 +1199,10 @@ func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.Outp cmd.Text(")").FlagWithOutput("> ", cannedFsConfig) builder.Build("generateFsConfig", fmt.Sprintf("Generating canned fs config for %s", a.BaseModuleName())) - return cannedFsConfig.OutputPath + return cannedFsConfig } -func runApexLinkerconfigValidation(ctx android.ModuleContext, apexFile android.OutputPath, imageDir android.OutputPath) android.Path { +func runApexLinkerconfigValidation(ctx android.ModuleContext, apexFile android.Path, imageDir android.Path) android.Path { timestamp := android.PathForModuleOut(ctx, "apex_linkerconfig_validation.timestamp") ctx.Build(pctx, android.BuildParams{ Rule: apexLinkerconfigValidationRule, @@ -1219,7 +1219,7 @@ func runApexLinkerconfigValidation(ctx android.ModuleContext, apexFile android.O // // $ deapexer list -Z {apex_file} > {file_contexts} // $ apex_sepolicy_tests -f {file_contexts} -func runApexSepolicyTests(ctx android.ModuleContext, apexFile android.OutputPath) android.Path { +func runApexSepolicyTests(ctx android.ModuleContext, apexFile android.Path) android.Path { timestamp := android.PathForModuleOut(ctx, "sepolicy_tests.timestamp") ctx.Build(pctx, android.BuildParams{ Rule: apexSepolicyTestsRule, @@ -1229,7 +1229,7 @@ func runApexSepolicyTests(ctx android.ModuleContext, apexFile android.OutputPath return timestamp } -func runApexElfCheckerUnwanted(ctx android.ModuleContext, apexFile android.OutputPath, unwanted []string) android.Path { +func runApexElfCheckerUnwanted(ctx android.ModuleContext, apexFile android.Path, unwanted []string) android.Path { timestamp := android.PathForModuleOut(ctx, "apex_elf_unwanted.timestamp") ctx.Build(pctx, android.BuildParams{ Rule: apexElfCheckerUnwantedRule, @@ -1243,7 +1243,7 @@ func runApexElfCheckerUnwanted(ctx android.ModuleContext, apexFile android.Outpu return timestamp } -func runApexHostVerifier(ctx android.ModuleContext, a *apexBundle, apexFile android.OutputPath) android.Path { +func runApexHostVerifier(ctx android.ModuleContext, a *apexBundle, apexFile android.Path) android.Path { timestamp := android.PathForModuleOut(ctx, "host_apex_verifier.timestamp") ctx.Build(pctx, android.BuildParams{ Rule: apexHostVerifierRule, -- cgit v1.2.3-59-g8ed1b