diff options
Diffstat (limited to 'apex/builder.go')
-rw-r--r-- | apex/builder.go | 87 |
1 files changed, 21 insertions, 66 deletions
diff --git a/apex/builder.go b/apex/builder.go index 20b4dbeeb..d0acc8d6c 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -43,7 +43,6 @@ func init() { pctx.Import("android/soong/java") pctx.HostBinToolVariable("apexer", "apexer") pctx.HostBinToolVariable("apexer_with_DCLA_preprocessing", "apexer_with_DCLA_preprocessing") - pctx.HostBinToolVariable("apexer_with_trim_preprocessing", "apexer_with_trim_preprocessing") // ART minimal builds (using the master-art manifest) do not have the "frameworks/base" // projects, and hence cannot build 'aapt2'. Use the SDK prebuilt instead. @@ -173,34 +172,6 @@ var ( }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest", "is_DCLA") - TrimmedApexRule = pctx.StaticRule("TrimmedApexRule", blueprint.RuleParams{ - Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` + - `(. ${out}.copy_commands) && ` + - `APEXER_TOOL_PATH=${tool_path} ` + - `${apexer_with_trim_preprocessing} ` + - `--apexer ${apexer} ` + - `--canned_fs_config ${canned_fs_config} ` + - `--manifest ${manifest} ` + - `--libs_to_trim ${libs_to_trim} ` + - `${image_dir} ` + - `${out} ` + - `-- ` + - `--include_build_info ` + - `--force ` + - `--payload_type image ` + - `--key ${key} ` + - `--file_contexts ${file_contexts} ` + - `${opt_flags} `, - CommandDeps: []string{"${apexer_with_trim_preprocessing}", "${apexer}", "${avbtool}", "${e2fsdroid}", - "${merge_zips}", "${mke2fs}", "${resize2fs}", "${sefcontext_compile}", "${make_f2fs}", - "${sload_f2fs}", "${make_erofs}", "${soong_zip}", "${zipalign}", "${aapt2}", - "prebuilts/sdk/current/public/android.jar"}, - Rspfile: "${out}.copy_commands", - RspfileContent: "${copy_commands}", - Description: "APEX ${image_dir} => ${out}", - }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", - "opt_flags", "manifest", "libs_to_trim") - apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule", blueprint.RuleParams{ Command: `${aapt2} convert --output-format proto $in -o $out`, @@ -225,7 +196,7 @@ var ( Command: `diff --unchanged-group-format='' \` + `--changed-group-format='%<' \` + `${image_content_file} ${allowed_files_file} || (` + - `echo -e "New unexpected files were added to ${apex_module_name}." ` + + `echo "New unexpected files were added to ${apex_module_name}." ` + ` "To fix the build run following command:" && ` + `echo "system/apex/tools/update_allowed_list.sh ${allowed_files_file} ${image_content_file}" && ` + `exit 1); touch ${out}`, @@ -417,7 +388,7 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, // file for this APEX which is either from /systme/sepolicy/apex/<apexname>-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 @@ -426,8 +397,10 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output } else { if m, t := android.SrcIsModuleWithTag(*a.properties.File_contexts); m != "" { isFileContextsModule = true - otherModule := android.GetModuleFromPathDep(ctx, m, t) - fileContextsDir = ctx.OtherModuleDir(otherModule) + otherModule := android.GetModuleProxyFromPathDep(ctx, m, t) + if otherModule != nil { + fileContextsDir = ctx.OtherModuleDir(*otherModule) + } } fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts) } @@ -470,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(). @@ -486,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 { @@ -536,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 { @@ -831,24 +804,6 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) { "opt_flags": strings.Join(optFlags, " "), }, }) - } else if ctx.Config().ApexTrimEnabled() && len(a.libs_to_trim(ctx)) > 0 { - ctx.Build(pctx, android.BuildParams{ - Rule: TrimmedApexRule, - Implicits: implicitInputs, - Output: unsignedOutputFile, - Description: "apex", - Args: map[string]string{ - "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, - "image_dir": imageDir.String(), - "copy_commands": strings.Join(copyCommands, " && "), - "manifest": a.manifestPbOut.String(), - "file_contexts": fileContexts.String(), - "canned_fs_config": cannedFsConfig.String(), - "key": a.privateKeyFile.String(), - "opt_flags": strings.Join(optFlags, " "), - "libs_to_trim": strings.Join(a.libs_to_trim(ctx), ","), - }, - }) } else { ctx.Build(pctx, android.BuildParams{ Rule: apexRule, @@ -967,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, @@ -1180,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 @@ -1244,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, @@ -1264,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, @@ -1274,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, @@ -1288,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, |