summaryrefslogtreecommitdiff
path: root/java/bootclasspath_fragment.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-12-20 16:32:37 -0800
committer Colin Cross <ccross@android.com> 2025-02-07 16:00:56 -0800
commitd8d8b85c5666b3ded986f1b5c64df31dea5076ee (patch)
treef088754b04d70b6a28f3c727b58c370c989cfadc /java/bootclasspath_fragment.go
parent22558312b9c07ddda22fcd00d6a84aa0f73f4d10 (diff)
Move prebuilt mutators earlier
Move the prebuilt mutators from postdeps to predeps mutators. This ensures that the decisions on whether the source or prebuilt will be used can be made earlier, which simplifies the apex and dexpreopt code, allowing it to directly depend on the correct module. This requires some mutators that previously ran before the prebuilt mutator and now run after the prebuilt mutator be aware of prebuilts. In particular, the cc.linkageTransitionMutator and rust.libraryTransitionMutator now have to manually disable prebuilts when they don't produce a static or shared variant that the source module produces, and some mutators have to ignore PrebuiltDepTag dependencies when propagating transitions. The apexTransitionMutator also needs to temporarily use an interface on the dependency tag to correctly resolve some dependencies that exist before the apex variation is created onto the correct variation. This will shortly be replaced with depending on the apex itself instead, and then walking the dependencies of the apex to find the necessary module. Bug: 372543712 Test: go test ./... Change-Id: If125ea981be87673bae3bd0a7e3b2c16c337e8f7
Diffstat (limited to 'java/bootclasspath_fragment.go')
-rw-r--r--java/bootclasspath_fragment.go24
1 files changed, 13 insertions, 11 deletions
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
}