apex: validate vintf fragments in vendor APEX

In Make, vintf fragments are checked with assemble_vintf. Since vendor
APEXes can have vintf fragments, perform the same check with vintf
fragments in APEX.

Bug: 299034304
Test: m test.bad2.com.android.hardware.wifi
  (should fail if its module type is `apex`)
Change-Id: I2f9ed50066b9b499b3562bfa51214c1e375d5747
This commit is contained in:
Jooyung Han 2023-09-08 15:25:59 +09:00
parent 4bc102672a
commit e615441832

View file

@ -76,6 +76,7 @@ func init() {
pctx.HostBinToolVariable("debugfs_static", "debugfs_static")
pctx.SourcePathVariable("genNdkUsedbyApexPath", "build/soong/scripts/gen_ndk_usedby_apex.sh")
pctx.HostBinToolVariable("conv_linker_config", "conv_linker_config")
pctx.HostBinToolVariable("assemble_vintf", "assemble_vintf")
}
var (
@ -229,6 +230,12 @@ var (
CommandDeps: []string{"${conv_linker_config}"},
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}`,
CommandDeps: []string{"${assemble_vintf}"},
Description: "run apex_vintf_validation",
}, "image_dir")
)
// buildManifest creates buile rules to modify the input apex_manifest.json to add information
@ -851,6 +858,9 @@ 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))
@ -1118,6 +1128,19 @@ 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}