summaryrefslogtreecommitdiff
path: root/rust
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 /rust
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 'rust')
-rw-r--r--rust/library.go12
-rw-r--r--rust/prebuilt.go2
2 files changed, 14 insertions, 0 deletions
diff --git a/rust/library.go b/rust/library.go
index 94f5730ea..0ebd7d3b1 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -945,6 +945,9 @@ func (libraryTransitionMutator) Split(ctx android.BaseModuleContext) []string {
}
func (libraryTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+ if ctx.DepTag() == android.PrebuiltDepTag {
+ return sourceVariation
+ }
return ""
}
@@ -1012,6 +1015,12 @@ func (libraryTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, varia
},
sourceDepTag, ctx.ModuleName())
}
+
+ if prebuilt, ok := m.compiler.(*prebuiltLibraryDecorator); ok {
+ if Bool(prebuilt.Properties.Force_use_prebuilt) && len(prebuilt.prebuiltSrcs()) > 0 {
+ m.Prebuilt().SetUsePrebuilt(true)
+ }
+ }
}
type libstdTransitionMutator struct{}
@@ -1029,6 +1038,9 @@ func (libstdTransitionMutator) Split(ctx android.BaseModuleContext) []string {
}
func (libstdTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+ if ctx.DepTag() == android.PrebuiltDepTag {
+ return sourceVariation
+ }
return ""
}
diff --git a/rust/prebuilt.go b/rust/prebuilt.go
index e35e510da..41f94238c 100644
--- a/rust/prebuilt.go
+++ b/rust/prebuilt.go
@@ -30,6 +30,8 @@ type PrebuiltProperties struct {
Srcs []string `android:"path,arch_variant"`
// directories containing associated rlib dependencies
Link_dirs []string `android:"path,arch_variant"`
+
+ Force_use_prebuilt *bool `android:"arch_variant"`
}
type prebuiltLibraryDecorator struct {