summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/bootclasspath.go116
-rw-r--r--java/bootclasspath_fragment.go24
-rw-r--r--java/dexpreopt_bootjars.go105
-rw-r--r--java/platform_bootclasspath.go62
-rw-r--r--java/testing.go1
5 files changed, 127 insertions, 181 deletions
diff --git a/java/bootclasspath.go b/java/bootclasspath.go
index 3413cf350..856f43919 100644
--- a/java/bootclasspath.go
+++ b/java/bootclasspath.go
@@ -23,36 +23,9 @@ import (
// Contains code that is common to both platform_bootclasspath and bootclasspath_fragment.
-func init() {
- registerBootclasspathBuildComponents(android.InitRegistrationContext)
-}
-
-func registerBootclasspathBuildComponents(ctx android.RegistrationContext) {
- ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("bootclasspath_deps", bootclasspathDepsMutator)
- })
-}
-
-// BootclasspathDepsMutator is the interface that a module must implement if it wants to add
-// dependencies onto APEX specific variants of bootclasspath fragments or bootclasspath contents.
-type BootclasspathDepsMutator interface {
- // BootclasspathDepsMutator implementations should add dependencies using
- // addDependencyOntoApexModulePair and addDependencyOntoApexVariants.
- BootclasspathDepsMutator(ctx android.BottomUpMutatorContext)
-}
-
-// bootclasspathDepsMutator is called during the final deps phase after all APEX variants have
-// been created so can add dependencies onto specific APEX variants of modules.
-func bootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
- m := ctx.Module()
- if p, ok := m.(BootclasspathDepsMutator); ok {
- p.BootclasspathDepsMutator(ctx)
- }
-}
-
// addDependencyOntoApexVariants adds dependencies onto the appropriate apex specific variants of
// the module as specified in the ApexVariantReference list.
-func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyName string, refs []ApexVariantReference, tag blueprint.DependencyTag) {
+func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyName string, refs []ApexVariantReference, tagType bootclasspathDependencyTagType) {
for i, ref := range refs {
apex := proptools.StringDefault(ref.Apex, "platform")
@@ -62,7 +35,7 @@ func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyN
}
name := proptools.String(ref.Module)
- addDependencyOntoApexModulePair(ctx, apex, name, tag)
+ addDependencyOntoApexModulePair(ctx, apex, name, tagType)
}
}
@@ -75,64 +48,26 @@ func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyN
// module when both source and prebuilt modules are available.
//
// Use gatherApexModulePairDepsWithTag to retrieve the dependencies.
-func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tag blueprint.DependencyTag) {
- var variations []blueprint.Variation
+func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tagType bootclasspathDependencyTagType) {
+ tag := bootclasspathDependencyTag{
+ typ: tagType,
+ }
if !android.IsConfiguredJarForPlatform(apex) {
- // Pick the correct apex variant.
- variations = []blueprint.Variation{
- {Mutator: "apex", Variation: apex},
- }
+ tag.apex = apex
}
target := ctx.Module().Target()
- variations = append(variations, target.Variations()...)
- addedDep := false
- if ctx.OtherModuleDependencyVariantExists(variations, name) {
- ctx.AddFarVariationDependencies(variations, tag, name)
- addedDep = true
- }
-
- // Add a dependency on the prebuilt module if it exists.
- prebuiltName := android.PrebuiltNameFromSource(name)
- if ctx.OtherModuleDependencyVariantExists(variations, prebuiltName) {
- ctx.AddVariationDependencies(variations, tag, prebuiltName)
- addedDep = true
- }
-
- // If no appropriate variant existing for this, so no dependency could be added, then it is an
- // error, unless missing dependencies are allowed. The simplest way to handle that is to add a
- // dependency that will not be satisfied and the default behavior will handle it.
- if !addedDep {
- // Add dependency on the unprefixed (i.e. source or renamed prebuilt) module which we know does
- // not exist. The resulting error message will contain useful information about the available
- // variants.
- reportMissingVariationDependency(ctx, variations, name)
-
- // Add dependency on the missing prefixed prebuilt variant too if a module with that name exists
- // so that information about its available variants will be reported too.
- if ctx.OtherModuleExists(prebuiltName) {
- reportMissingVariationDependency(ctx, variations, prebuiltName)
- }
- }
-}
-
-// reportMissingVariationDependency intentionally adds a dependency on a missing variation in order
-// to generate an appropriate error message with information about the available variations.
-func reportMissingVariationDependency(ctx android.BottomUpMutatorContext, variations []blueprint.Variation, name string) {
- ctx.AddFarVariationDependencies(variations, nil, name)
+ ctx.AddFarVariationDependencies(target.Variations(), tag, name)
}
// gatherApexModulePairDepsWithTag returns the list of dependencies with the supplied tag that was
// added by addDependencyOntoApexModulePair.
-func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tag blueprint.DependencyTag) []android.Module {
+func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tagType bootclasspathDependencyTagType) []android.Module {
var modules []android.Module
- isActiveModulePred := func(module android.Module) bool {
- return isActiveModule(ctx, module)
- }
- ctx.VisitDirectDepsIf(isActiveModulePred, func(module android.Module) {
+ ctx.VisitDirectDeps(func(module android.Module) {
t := ctx.OtherModuleDependencyTag(module)
- if t == tag {
+ if bcpTag, ok := t.(bootclasspathDependencyTag); ok && bcpTag.typ == tagType {
modules = append(modules, module)
}
})
@@ -165,7 +100,7 @@ type BootclasspathFragmentsDepsProperties struct {
// addDependenciesOntoFragments adds dependencies to the fragments specified in this properties
// structure.
func (p *BootclasspathFragmentsDepsProperties) addDependenciesOntoFragments(ctx android.BottomUpMutatorContext) {
- addDependencyOntoApexVariants(ctx, "fragments", p.Fragments, bootclasspathFragmentDepTag)
+ addDependencyOntoApexVariants(ctx, "fragments", p.Fragments, fragment)
}
// bootclasspathDependencyTag defines dependencies from/to bootclasspath_fragment,
@@ -174,23 +109,36 @@ func (p *BootclasspathFragmentsDepsProperties) addDependenciesOntoFragments(ctx
type bootclasspathDependencyTag struct {
blueprint.BaseDependencyTag
- name string
+ typ bootclasspathDependencyTagType
+
+ apex string
}
+type bootclasspathDependencyTagType int
+
+const (
+ // The tag used for dependencies onto bootclasspath_fragments.
+ fragment bootclasspathDependencyTagType = iota
+ // The tag used for dependencies onto platform_bootclasspath.
+ platform
+ dexpreoptBootJar
+ artBootJar
+ platformBootJar
+ apexBootJar
+)
+
func (t bootclasspathDependencyTag) ExcludeFromVisibilityEnforcement() {
}
+func (t bootclasspathDependencyTag) ApexTransition() string {
+ return t.apex
+}
+
// Dependencies that use the bootclasspathDependencyTag instances are only added after all the
// visibility checking has been done so this has no functional effect. However, it does make it
// clear that visibility is not being enforced on these tags.
var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathDependencyTag{}
-// The tag used for dependencies onto bootclasspath_fragments.
-var bootclasspathFragmentDepTag = bootclasspathDependencyTag{name: "fragment"}
-
-// The tag used for dependencies onto platform_bootclasspath.
-var platformBootclasspathDepTag = bootclasspathDependencyTag{name: "platform"}
-
// BootclasspathNestedAPIProperties defines properties related to the API provided by parts of the
// bootclasspath that are nested within the main BootclasspathAPIProperties.
type BootclasspathNestedAPIProperties struct {
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index f6d6cad4a..d5296e2c7 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -412,9 +412,8 @@ func (b *BootclasspathFragmentModule) OutgoingDepIsInSameApex(tag blueprint.Depe
}
// Dependency to the bootclasspath fragment of another apex
// e.g. concsrypt-bootclasspath-fragment --> art-bootclasspath-fragment
- if tag == bootclasspathFragmentDepTag {
+ if bcpTag, ok := tag.(bootclasspathDependencyTag); ok && bcpTag.typ == fragment {
return false
-
}
panic(fmt.Errorf("boot_image module %q should not have a dependency tag %s", b, android.PrettyPrintTag(tag)))
}
@@ -458,22 +457,18 @@ func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorCon
}
}
- if !dexpreopt.IsDex2oatNeeded(ctx) {
- return
+ if dexpreopt.IsDex2oatNeeded(ctx) {
+ // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
+ // path is retrieved from the dependency by GetGlobalSoongConfig(ctx).
+ dexpreopt.RegisterToolDeps(ctx)
}
- // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
- // path is retrieved from the dependency by GetGlobalSoongConfig(ctx).
- dexpreopt.RegisterToolDeps(ctx)
-
// Add a dependency to `all_apex_contributions` to determine if prebuilts are active.
// If prebuilts are active, `contents` validation on the source bootclasspath fragment should be disabled.
if _, isPrebuiltModule := ctx.Module().(*PrebuiltBootclasspathFragmentModule); !isPrebuiltModule {
ctx.AddDependency(b, android.AcDepTag, "all_apex_contributions")
}
-}
-func (b *BootclasspathFragmentModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
// Add dependencies on all the fragments.
b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx)
}
@@ -498,7 +493,7 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
}
})
- fragments := gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag)
+ fragments := gatherApexModulePairDepsWithTag(ctx, fragment)
// Perform hidden API processing.
hiddenAPIOutput := b.generateHiddenAPIBuildActions(ctx, contents, fragments)
@@ -1142,6 +1137,13 @@ func prebuiltBootclasspathFragmentFactory() android.Module {
android.InitPrebuiltModule(m, &[]string{"placeholder"})
android.InitApexModule(m)
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon)
+ android.InitDefaultableModule(m)
+
+ m.SetDefaultableHook(func(mctx android.DefaultableHookContext) {
+ if mctx.Config().AlwaysUsePrebuiltSdks() {
+ m.prebuilt.ForcePrefer()
+ }
+ })
return m
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 093cc876b..83b1f4df6 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -225,7 +225,6 @@ var artApexNames = []string{
}
var (
- dexpreoptBootJarDepTag = bootclasspathDependencyTag{name: "dexpreopt-boot-jar"}
dexBootJarsFragmentsKey = android.NewOnceKey("dexBootJarsFragments")
apexContributionsMetadataDepTag = dependencyTag{name: "all_apex_contributions"}
)
@@ -467,9 +466,6 @@ func dexpreoptBootJarsFactory() android.SingletonModule {
func RegisterDexpreoptBootJarsComponents(ctx android.RegistrationContext) {
ctx.RegisterParallelSingletonModuleType("dex_bootjars", dexpreoptBootJarsFactory)
ctx.RegisterModuleType("art_boot_images", artBootImagesFactory)
- ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("dex_bootjars_deps", DexpreoptBootJarsMutator)
- })
}
func SkipDexpreoptBootJars(ctx android.PathContext) bool {
@@ -505,12 +501,6 @@ type dexpreoptBootJars struct {
func (dbj *dexpreoptBootJars) DepsMutator(ctx android.BottomUpMutatorContext) {
// Create a dependency on all_apex_contributions to determine the selected mainline module
ctx.AddDependency(ctx.Module(), apexContributionsMetadataDepTag, "all_apex_contributions")
-}
-
-func DexpreoptBootJarsMutator(ctx android.BottomUpMutatorContext) {
- if _, ok := ctx.Module().(*dexpreoptBootJars); !ok {
- return
- }
if dexpreopt.IsDex2oatNeeded(ctx) {
// Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
@@ -524,7 +514,7 @@ func DexpreoptBootJarsMutator(ctx android.BottomUpMutatorContext) {
continue
}
// For accessing the boot jars.
- addDependenciesOntoBootImageModules(ctx, config.modules, dexpreoptBootJarDepTag)
+ addDependenciesOntoBootImageModules(ctx, config.modules, dexpreoptBootJar)
// Create a dependency on the apex selected using RELEASE_APEX_CONTRIBUTIONS_*
// TODO: b/308174306 - Remove the direct depedendency edge to the java_library (source/prebuilt) once all mainline modules
// have been flagged using RELEASE_APEX_CONTRIBUTIONS_*
@@ -537,11 +527,11 @@ func DexpreoptBootJarsMutator(ctx android.BottomUpMutatorContext) {
if ctx.OtherModuleExists("platform-bootclasspath") {
// For accessing all bootclasspath fragments.
- addDependencyOntoApexModulePair(ctx, "platform", "platform-bootclasspath", platformBootclasspathDepTag)
+ addDependencyOntoApexModulePair(ctx, "platform", "platform-bootclasspath", platform)
} else if ctx.OtherModuleExists("art-bootclasspath-fragment") {
// For accessing the ART bootclasspath fragment on a thin manifest (e.g., master-art) where
// platform-bootclasspath doesn't exist.
- addDependencyOntoApexModulePair(ctx, "com.android.art", "art-bootclasspath-fragment", bootclasspathFragmentDepTag)
+ addDependencyOntoApexModulePair(ctx, "com.android.art", "art-bootclasspath-fragment", fragment)
}
}
@@ -559,16 +549,14 @@ func addDependenciesOntoSelectedBootImageApexes(ctx android.BottomUpMutatorConte
// We need to add a dep on only the apex listed in `contents` of the selected apex_contributions module
// This is not available in a structured format in `apex_contributions`, so this hack adds a dep on all `contents`
// (some modules like art.module.public.api do not have an apex variation since it is a pure stub module that does not get installed)
- apexVariationOfSelected := append(ctx.Target().Variations(), blueprint.Variation{Mutator: "apex", Variation: apex})
- if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, selected) {
- ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, selected)
- } else if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, android.RemoveOptionalPrebuiltPrefix(selected)) {
- // The prebuilt might have been renamed by prebuilt_rename mutator if the source module does not exist.
- // Remove the prebuilt_ prefix.
- ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, android.RemoveOptionalPrebuiltPrefix(selected))
- } else {
- // Couldn't find a dependency, do it again to report an error.
- ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, selected)
+ tag := bootclasspathDependencyTag{
+ typ: dexpreoptBootJar,
+ }
+ if !android.IsConfiguredJarForPlatform(apex) {
+ tag.apex = apex
+ }
+ if ctx.OtherModuleDependencyVariantExists(ctx.Target().Variations(), android.RemoveOptionalPrebuiltPrefix(selected)) {
+ ctx.AddFarVariationDependencies(ctx.Target().Variations(), tag, android.RemoveOptionalPrebuiltPrefix(selected))
}
}
}
@@ -582,15 +570,17 @@ func gatherBootclasspathFragments(ctx android.ModuleContext) map[string]android.
return false
}
tag := ctx.OtherModuleDependencyTag(child)
- if tag == platformBootclasspathDepTag {
- return true
- }
- if tag == bootclasspathFragmentDepTag {
- apexInfo, _ := android.OtherModuleProvider(ctx, child, android.ApexInfoProvider)
- for _, apex := range apexInfo.InApexVariants {
- fragments[apex] = child
+ if bcpTag, ok := tag.(bootclasspathDependencyTag); ok {
+ if bcpTag.typ == platform {
+ return true
+ }
+ if bcpTag.typ == fragment {
+ apexInfo, _ := android.OtherModuleProvider(ctx, child, android.ApexInfoProvider)
+ for _, apex := range apexInfo.InApexVariants {
+ fragments[apex] = child
+ }
+ return false
}
- return false
}
return false
})
@@ -717,7 +707,7 @@ func getModulesForImage(ctx android.ModuleContext, imageConfig *bootImageConfig)
modules := make([]apexJarModulePair, 0, imageConfig.modules.Len())
for i := 0; i < imageConfig.modules.Len(); i++ {
found := false
- for _, module := range gatherApexModulePairDepsWithTag(ctx, dexpreoptBootJarDepTag) {
+ for _, module := range gatherApexModulePairDepsWithTag(ctx, dexpreoptBootJar) {
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
if name == imageConfig.modules.Jar(i) {
modules = append(modules, apexJarModulePair{
@@ -804,7 +794,11 @@ func getDexJarForApex(ctx android.ModuleContext, pair apexJarModulePair, apexNam
bootclasspathFragmentInfo, _ := android.OtherModuleProvider(ctx, fragment, BootclasspathFragmentApexContentInfoProvider)
jar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(pair.jarModule)
if err != nil {
- ctx.ModuleErrorf("%s", err)
+ if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{pair.jarModule.String()})
+ } else {
+ ctx.ModuleErrorf("%s", err)
+ }
}
return jar
}
@@ -963,9 +957,12 @@ func getProfilePathForApex(ctx android.ModuleContext, apexName string, apexNameT
func getApexNameToApexExportsInfoMap(ctx android.ModuleContext) apexNameToApexExportsInfoMap {
apexNameToApexExportsInfoMap := apexNameToApexExportsInfoMap{}
- ctx.VisitDirectDepsWithTag(dexpreoptBootJarDepTag, func(am android.Module) {
- if info, exists := android.OtherModuleProvider(ctx, am, android.ApexExportsInfoProvider); exists {
- apexNameToApexExportsInfoMap[info.ApexName] = info
+ ctx.VisitDirectDeps(func(am android.Module) {
+ tag := ctx.OtherModuleDependencyTag(am)
+ if bcpTag, ok := tag.(bootclasspathDependencyTag); ok && bcpTag.typ == dexpreoptBootJar {
+ if info, exists := android.OtherModuleProvider(ctx, am, android.ApexExportsInfoProvider); exists {
+ apexNameToApexExportsInfoMap[info.ApexName] = info
+ }
}
})
return apexNameToApexExportsInfoMap
@@ -1448,24 +1445,30 @@ func artBootImagesFactory() android.Module {
func (dbj *artBootImages) DepsMutator(ctx android.BottomUpMutatorContext) {
// Create a dependency on `dex_bootjars` to access the intermediate locations of host art boot image.
- ctx.AddVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), dexpreoptBootJarDepTag, "dex_bootjars")
+ tag := bootclasspathDependencyTag{
+ typ: dexpreoptBootJar,
+ }
+ ctx.AddVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), tag, "dex_bootjars")
}
func (d *artBootImages) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- ctx.VisitDirectDepsWithTag(dexpreoptBootJarDepTag, func(m android.Module) {
- hostInstallsInfo, ok := android.OtherModuleProvider(ctx, m, artBootImageHostInfoProvider)
- if !ok {
- ctx.ModuleErrorf("Could not find information about the host variant of ART boot image")
- }
- installs := d.installFile(ctx, hostInstallsInfo.installs)
- if len(installs) > 0 {
- d.outputFile = android.OptionalPathForPath(installs[0])
- // Create a phony target that can ART run-tests can depend on.
- ctx.Phony(d.Name(), installs...)
- } else {
- // this might be true e.g. when building with `WITH_DEXPREOPT=false`
- // create an empty file so that the `art_boot_images` is known to the packaging system.
- d.outputFile = android.OptionalPathForPath(android.PathForModuleOut(ctx, "undefined_art_boot_images"))
+ ctx.VisitDirectDeps(func(m android.Module) {
+ tag := ctx.OtherModuleDependencyTag(m)
+ if bcpTag, ok := tag.(bootclasspathDependencyTag); ok && bcpTag.typ == dexpreoptBootJar {
+ hostInstallsInfo, ok := android.OtherModuleProvider(ctx, m, artBootImageHostInfoProvider)
+ if !ok {
+ ctx.ModuleErrorf("Could not find information about the host variant of ART boot image")
+ }
+ installs := d.installFile(ctx, hostInstallsInfo.installs)
+ if len(installs) > 0 {
+ d.outputFile = android.OptionalPathForPath(installs[0])
+ // Create a phony target that can ART run-tests can depend on.
+ ctx.Phony(d.Name(), installs...)
+ } else {
+ // this might be true e.g. when building with `WITH_DEXPREOPT=false`
+ // create an empty file so that the `art_boot_images` is known to the packaging system.
+ d.outputFile = android.OptionalPathForPath(android.PathForModuleOut(ctx, "undefined_art_boot_images"))
+ }
}
})
}
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index 86062d489..3b05b16e3 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -31,12 +31,6 @@ func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContex
// The tags used for the dependencies between the platform bootclasspath and any configured boot
// jars.
-var (
- platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"}
- platformBootclasspathBootJarDepTag = bootclasspathDependencyTag{name: "platform-boot-jar"}
- platformBootclasspathApexBootJarDepTag = bootclasspathDependencyTag{name: "apex-boot-jar"}
-)
-
type platformBootclasspathImplLibDepTagType struct {
blueprint.BaseDependencyTag
}
@@ -100,26 +94,12 @@ func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorCon
b.hiddenAPIDepsMutator(ctx)
- if !dexpreopt.IsDex2oatNeeded(ctx) {
- return
+ if dexpreopt.IsDex2oatNeeded(ctx) {
+ // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
+ // path is retrieved from the dependency by GetGlobalSoongConfig(ctx).
+ dexpreopt.RegisterToolDeps(ctx)
}
- // Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
- // path is retrieved from the dependency by GetGlobalSoongConfig(ctx).
- dexpreopt.RegisterToolDeps(ctx)
-}
-
-func (b *platformBootclasspathModule) hiddenAPIDepsMutator(ctx android.BottomUpMutatorContext) {
- if ctx.Config().DisableHiddenApiChecks() {
- return
- }
-
- // Add dependencies onto the stub lib modules.
- apiLevelToStubLibModules := hiddenAPIComputeMonolithicStubLibModules(ctx.Config())
- hiddenAPIAddStubLibDependencies(ctx, apiLevelToStubLibModules)
-}
-
-func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
// Add dependencies on all the ART jars.
global := dexpreopt.GetGlobalConfig(ctx)
addDependenciesOntoSelectedBootImageApexes(ctx, "com.android.art")
@@ -127,13 +107,13 @@ func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.Botto
var bootImageModuleNames []string
// TODO: b/308174306 - Remove the mechanism of depending on the java_sdk_library(_import) directly
- addDependenciesOntoBootImageModules(ctx, global.ArtApexJars, platformBootclasspathArtBootJarDepTag)
+ addDependenciesOntoBootImageModules(ctx, global.ArtApexJars, artBootJar)
bootImageModuleNames = append(bootImageModuleNames, global.ArtApexJars.CopyOfJars()...)
// Add dependencies on all the non-updatable jars, which are on the platform or in non-updatable
// APEXes.
platformJars := b.platformJars(ctx)
- addDependenciesOntoBootImageModules(ctx, platformJars, platformBootclasspathBootJarDepTag)
+ addDependenciesOntoBootImageModules(ctx, platformJars, platformBootJar)
bootImageModuleNames = append(bootImageModuleNames, platformJars.CopyOfJars()...)
// Add dependencies on all the updatable jars, except the ART jars.
@@ -144,7 +124,7 @@ func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.Botto
}
addDependenciesOntoSelectedBootImageApexes(ctx, android.FirstUniqueStrings(apexes)...)
// TODO: b/308174306 - Remove the mechanism of depending on the java_sdk_library(_import) directly
- addDependenciesOntoBootImageModules(ctx, apexJars, platformBootclasspathApexBootJarDepTag)
+ addDependenciesOntoBootImageModules(ctx, apexJars, apexBootJar)
bootImageModuleNames = append(bootImageModuleNames, apexJars.CopyOfJars()...)
// Add dependencies on all the fragments.
@@ -158,20 +138,30 @@ func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.Botto
}
}
-func addDependenciesOntoBootImageModules(ctx android.BottomUpMutatorContext, modules android.ConfiguredJarList, tag bootclasspathDependencyTag) {
+func (b *platformBootclasspathModule) hiddenAPIDepsMutator(ctx android.BottomUpMutatorContext) {
+ if ctx.Config().DisableHiddenApiChecks() {
+ return
+ }
+
+ // Add dependencies onto the stub lib modules.
+ apiLevelToStubLibModules := hiddenAPIComputeMonolithicStubLibModules(ctx.Config())
+ hiddenAPIAddStubLibDependencies(ctx, apiLevelToStubLibModules)
+}
+
+func addDependenciesOntoBootImageModules(ctx android.BottomUpMutatorContext, modules android.ConfiguredJarList, tagType bootclasspathDependencyTagType) {
for i := 0; i < modules.Len(); i++ {
apex := modules.Apex(i)
name := modules.Jar(i)
- addDependencyOntoApexModulePair(ctx, apex, name, tag)
+ addDependencyOntoApexModulePair(ctx, apex, name, tagType)
}
}
func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Gather all the dependencies from the art, platform, and apex boot jars.
- artModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathArtBootJarDepTag)
- platformModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathBootJarDepTag)
- apexModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathApexBootJarDepTag)
+ artModules := gatherApexModulePairDepsWithTag(ctx, artBootJar)
+ platformModules := gatherApexModulePairDepsWithTag(ctx, platformBootJar)
+ apexModules := gatherApexModulePairDepsWithTag(ctx, apexBootJar)
// Concatenate them all, in order as they would appear on the bootclasspath.
var allModules []android.Module
@@ -199,7 +189,7 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
TransformResourcesToJar(ctx, srcjar, jarArgs, transitiveSrcFiles)
// Gather all the fragments dependencies.
- b.fragments = gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag)
+ b.fragments = gatherApexModulePairDepsWithTag(ctx, fragment)
// Check the configuration of the boot modules.
// ART modules are checked by the art-bootclasspath-fragment.
@@ -283,7 +273,11 @@ func (b *platformBootclasspathModule) checkApexModules(ctx android.ModuleContext
// modules is complete.
if !ctx.Config().AlwaysUsePrebuiltSdks() {
// error: this jar is part of the platform
- ctx.ModuleErrorf("module %q from platform is not allowed in the apex boot jars list", name)
+ if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{"module_" + name + "_from_platform_is_not_allowed_in_the_apex_boot_jars_list"})
+ } else {
+ ctx.ModuleErrorf("module %q from platform is not allowed in the apex boot jars list", name)
+ }
}
} else {
// TODO(b/177892522): Treat this as an error.
diff --git a/java/testing.go b/java/testing.go
index 0ea4e6408..378e2dd4f 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -378,7 +378,6 @@ func registerRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
RegisterAppBuildComponents(ctx)
RegisterAppImportBuildComponents(ctx)
RegisterAppSetBuildComponents(ctx)
- registerBootclasspathBuildComponents(ctx)
registerBootclasspathFragmentBuildComponents(ctx)
RegisterDexpreoptBootJarsComponents(ctx)
RegisterDocsBuildComponents(ctx)