From d8d8b85c5666b3ded986f1b5c64df31dea5076ee Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 20 Dec 2024 16:32:37 -0800 Subject: 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 --- apex/apex.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apex/apex.go') diff --git a/apex/apex.go b/apex/apex.go index fa796e534..bbcc4cc58 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1193,6 +1193,13 @@ func markPlatformAvailability(mctx android.BottomUpMutatorContext) { } } +type apexTransitionTag interface { + // ApexTransition is a temporary interface used to tag dependencies with the apex variation they should use + // when the dependency is added before the apex transition mutator has run. These will be replaced with + // dependencies on the apex instead, which will then be used to find the necessary module inside the apex. + ApexTransition() string +} + type apexTransitionMutator struct{} func (a *apexTransitionMutator) Split(ctx android.BaseModuleContext) []string { @@ -1207,6 +1214,9 @@ func (a *apexTransitionMutator) Split(ctx android.BaseModuleContext) []string { } func (a *apexTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string { + if tag, ok := ctx.DepTag().(apexTransitionTag); ok { + return tag.ApexTransition() + } return sourceVariation } -- cgit v1.2.3-59-g8ed1b