Align boot jar exclusion with apex_contributions
During trunk stable development, it is possible that a new boot jar is added to the source apex, but not available in prebuilt apex yet. Thefore we need to conditionally check the `contents` of the respective bootclasspath_fragment modules. https://r.android.com/2822393 did this using isActiveModule. This function relies on soong config namespaces to "hide" the source bootclasspath_fragment module when <module>.source_build is false. Soong config namespaces for mainline source vs prebuilt selection is no longer in use, so this CL replaces `isActiveModule`. The CL cleaves the implementation 1. For source builds, the check will run in the context of the bootclasspath_fragment module. `disableSourceApexVariant` will be used to skip the check if prebuilts are selected. 2. For prebuilt builds, the prebuilt bootclasspath_fragment module sets a provider, and the top-level apex will do the check. (2) is necessary to handle the edge case of multiple versioned mainline prebuilts and possible skew in apex boot jars across them. In case of prebuilt builds, the unselected mainline prebuilts will have HideFromMake called on them, so the check will only run on the apex that is actually used during the build. Bug: 328578801 Test: go test ./apex Change-Id: I6eec603397eea926f3a481b79ca938245064d809 Merged-In: I6eec603397eea926f3a481b79ca938245064d809
This commit is contained in:
@@ -835,7 +835,21 @@ func (p *prebuiltCommon) providePrebuiltInfo(ctx android.ModuleContext) {
|
||||
android.SetProvider(ctx, android.PrebuiltInfoProvider, info)
|
||||
}
|
||||
|
||||
// Uses an object provided by its deps to validate that the contents of bcpf have been added to the global
|
||||
// PRODUCT_APEX_BOOT_JARS
|
||||
// This validation will only run on the apex which is active for this product/release_config
|
||||
func validateApexClasspathFragments(ctx android.ModuleContext) {
|
||||
ctx.VisitDirectDeps(func(m android.Module) {
|
||||
if info, exists := android.OtherModuleProvider(ctx, m, java.ClasspathFragmentValidationInfoProvider); exists {
|
||||
ctx.ModuleErrorf("%s in contents of %s must also be declared in PRODUCT_APEX_BOOT_JARS", info.UnknownJars, info.ClasspathFragmentModuleName)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// Validate contents of classpath fragments
|
||||
validateApexClasspathFragments(ctx)
|
||||
|
||||
p.apexKeysPath = writeApexKeys(ctx, p)
|
||||
// TODO(jungjw): Check the key validity.
|
||||
p.inputApex = android.OptionalPathForModuleSrc(ctx, p.prebuiltCommonProperties.Selected_apex).Path()
|
||||
@@ -1059,6 +1073,9 @@ func (a *ApexSet) ApexInfoMutator(mctx android.TopDownMutatorContext) {
|
||||
}
|
||||
|
||||
func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// Validate contents of classpath fragments
|
||||
validateApexClasspathFragments(ctx)
|
||||
|
||||
a.apexKeysPath = writeApexKeys(ctx, a)
|
||||
a.installFilename = a.InstallFilename()
|
||||
if !strings.HasSuffix(a.installFilename, imageApexSuffix) && !strings.HasSuffix(a.installFilename, imageCapexSuffix) {
|
||||
|
Reference in New Issue
Block a user