summaryrefslogtreecommitdiff
path: root/rust/library.go
diff options
context:
space:
mode:
Diffstat (limited to 'rust/library.go')
-rw-r--r--rust/library.go32
1 files changed, 23 insertions, 9 deletions
diff --git a/rust/library.go b/rust/library.go
index 9005f0c54..4ac52b428 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -159,14 +159,6 @@ func (library *libraryDecorator) static() bool {
return library.MutatedProperties.VariantIsStatic
}
-func (library *libraryDecorator) stdLinkage(ctx *depsContext) RustLinkage {
- // libraries should only request the RlibLinkage when building a static FFI or when variant is StaticStd
- if library.static() || library.MutatedProperties.VariantIsStaticStd {
- return RlibLinkage
- }
- return DefaultLinkage
-}
-
func (library *libraryDecorator) source() bool {
return library.MutatedProperties.VariantIsSource
}
@@ -228,7 +220,9 @@ func (library *libraryDecorator) setSource() {
}
func (library *libraryDecorator) autoDep(ctx BaseModuleContext) autoDep {
- if library.rlib() || library.static() {
+ if library.preferRlib() {
+ return rlibAutoDep
+ } else if library.rlib() || library.static() {
return rlibAutoDep
} else if library.dylib() || library.shared() {
return dylibAutoDep
@@ -237,6 +231,15 @@ func (library *libraryDecorator) autoDep(ctx BaseModuleContext) autoDep {
}
}
+func (library *libraryDecorator) stdLinkage(ctx *depsContext) RustLinkage {
+ if library.static() || library.MutatedProperties.VariantIsStaticStd {
+ return RlibLinkage
+ } else if library.baseCompiler.preferRlib() {
+ return RlibLinkage
+ }
+ return DefaultLinkage
+}
+
var _ compiler = (*libraryDecorator)(nil)
var _ libraryInterface = (*libraryDecorator)(nil)
var _ exportedFlagsProducer = (*libraryDecorator)(nil)
@@ -602,6 +605,11 @@ func LibraryMutator(mctx android.BottomUpMutatorContext) {
v.(*Module).compiler.(libraryInterface).setRlib()
case dylibVariation:
v.(*Module).compiler.(libraryInterface).setDylib()
+ if v.(*Module).ModuleBase.ImageVariation().Variation != android.CoreVariation {
+ // TODO(b/165791368)
+ // Disable dylib non-core variations until we support these.
+ v.(*Module).Disable()
+ }
case "source":
v.(*Module).compiler.(libraryInterface).setSource()
// The source variant does not produce any library.
@@ -638,6 +646,12 @@ func LibstdMutator(mctx android.BottomUpMutatorContext) {
dylib := modules[1].(*Module)
rlib.compiler.(libraryInterface).setRlibStd()
dylib.compiler.(libraryInterface).setDylibStd()
+ if dylib.ModuleBase.ImageVariation().Variation != android.CoreVariation {
+ // TODO(b/165791368)
+ // Disable rlibs that link against dylib-std on non-core variations until non-core dylib
+ // variants are properly supported.
+ dylib.Disable()
+ }
rlib.Properties.SubName += RlibStdlibSuffix
dylib.Properties.SubName += DylibStdlibSuffix
}