Merge "Use assemble_vintf output for vintf fragments in APEX" into main am: 64a2cc1a9a am: 0d542860f1 am: 00677dad5b

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2760325

Change-Id: Icd39a80a138b8d7a2f1e79ffbe41b0e866b2da05
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-09-22 13:42:00 +00:00 committed by Automerger Merge Worker
commit 2aa33b884c

View file

@ -17,6 +17,7 @@ package apex
import (
"encoding/json"
"fmt"
"path"
"path/filepath"
"runtime"
"sort"
@ -231,11 +232,11 @@ var (
Description: "run apex_linkerconfig_validation",
}, "image_dir")
apexVintfFragmentsValidationRule = pctx.StaticRule("apexVintfFragmentsValidationRule", blueprint.RuleParams{
Command: `/bin/bash -c '(shopt -s nullglob; for f in ${image_dir}/etc/vintf/*.xml; do VINTF_IGNORE_TARGET_FCM_VERSION=true ${assemble_vintf} -i "$$f" > /dev/null; done)' && touch ${out}`,
assembleVintfRule = pctx.StaticRule("assembleVintfRule", blueprint.RuleParams{
Command: `rm -f $out && VINTF_IGNORE_TARGET_FCM_VERSION=true ${assemble_vintf} -i $in -o $out`,
CommandDeps: []string{"${assemble_vintf}"},
Description: "run apex_vintf_validation",
}, "image_dir")
Description: "run assemble_vintf",
})
)
// buildManifest creates buile rules to modify the input apex_manifest.json to add information
@ -458,6 +459,22 @@ func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android
})
}
func isVintfFragment(fi apexFile) bool {
isVintfFragment, _ := path.Match("etc/vintf/*.xml", fi.path())
return isVintfFragment
}
func runAssembleVintf(ctx android.ModuleContext, vintfFragment android.Path) android.Path {
processed := android.PathForModuleOut(ctx, "vintf", vintfFragment.Base())
ctx.Build(pctx, android.BuildParams{
Rule: assembleVintfRule,
Input: vintfFragment,
Output: processed,
Description: "run assemble_vintf for VINTF in APEX",
})
return processed
}
// buildApex creates build rules to build an APEX using apexer.
func (a *apexBundle) buildApex(ctx android.ModuleContext) {
suffix := imageApexSuffix
@ -495,7 +512,15 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
copyCommands = append(copyCommands, "ln -sfn "+pathOnDevice+" "+destPath)
} else {
// Copy the file into APEX
copyCommands = append(copyCommands, "cp -f "+fi.builtFile.String()+" "+destPath)
if !a.testApex && isVintfFragment(fi) {
// copy the output of assemble_vintf instead of the original
vintfFragment := runAssembleVintf(ctx, fi.builtFile)
copyCommands = append(copyCommands, "cp -f "+vintfFragment.String()+" "+destPath)
implicitInputs = append(implicitInputs, vintfFragment)
} else {
copyCommands = append(copyCommands, "cp -f "+fi.builtFile.String()+" "+destPath)
implicitInputs = append(implicitInputs, fi.builtFile)
}
var installedPath android.InstallPath
if fi.class == appSet {
@ -513,7 +538,6 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
installedPath = ctx.InstallFile(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile)
}
}
implicitInputs = append(implicitInputs, fi.builtFile)
// Create additional symlinks pointing the file inside the APEX (if any). Note that
// this is independent from the symlink optimization.
@ -858,9 +882,6 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
}
var validations android.Paths
validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath))
if !a.testApex && a.SocSpecific() {
validations = append(validations, runApexVintfFragmentsValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath))
}
// TODO(b/279688635) deapexer supports [ext4]
if suffix == imageApexSuffix && ext4 == a.payloadFsType {
validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath))
@ -1128,19 +1149,6 @@ func runApexLinkerconfigValidation(ctx android.ModuleContext, apexFile android.O
return timestamp
}
func runApexVintfFragmentsValidation(ctx android.ModuleContext, apexFile android.OutputPath, imageDir android.OutputPath) android.Path {
timestamp := android.PathForModuleOut(ctx, "apex_vintf_fragments_validation.timestamp")
ctx.Build(pctx, android.BuildParams{
Rule: apexVintfFragmentsValidationRule,
Input: apexFile,
Output: timestamp,
Args: map[string]string{
"image_dir": imageDir.String(),
},
})
return timestamp
}
// Runs apex_sepolicy_tests
//
// $ deapexer list -Z {apex_file} > {file_contexts}