diff options
Diffstat (limited to 'rust/rust.go')
-rw-r--r-- | rust/rust.go | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/rust/rust.go b/rust/rust.go index 6fc682f25..0c48154bb 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -595,7 +595,7 @@ func (mod *Module) CcLibraryInterface() bool { if mod.compiler != nil { // use build{Static,Shared}() instead of {static,shared}() here because this might be called before // VariantIs{Static,Shared} is set. - if lib, ok := mod.compiler.(libraryInterface); ok && (lib.buildShared() || lib.buildStatic()) { + if lib, ok := mod.compiler.(libraryInterface); ok && (lib.buildShared() || lib.buildStatic() || lib.buildRlib()) { return true } } @@ -681,15 +681,6 @@ func (mod *Module) BuildRlibVariant() bool { panic(fmt.Errorf("BuildRlibVariant called on non-library module: %q", mod.BaseModuleName())) } -func (mod *Module) IsRustFFI() bool { - if mod.compiler != nil { - if library, ok := mod.compiler.(libraryInterface); ok { - return library.isFFILibrary() - } - } - return false -} - func (mod *Module) BuildSharedVariant() bool { if mod.compiler != nil { if library, ok := mod.compiler.(libraryInterface); ok { @@ -1237,6 +1228,8 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { ctx.VisitDirectDeps(func(dep android.Module) { depName := ctx.OtherModuleName(dep) depTag := ctx.OtherModuleDependencyTag(dep) + modStdLinkage := mod.compiler.stdLinkage(ctx.Device()) + if _, exists := skipModuleList[depName]; exists { return } @@ -1265,6 +1258,14 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depPaths.transitiveImplementationDeps = append(depPaths.transitiveImplementationDeps, info.ImplementationDeps) } + if !rustDep.compiler.noStdlibs() { + rustDepStdLinkage := rustDep.compiler.stdLinkage(ctx.Device()) + if rustDepStdLinkage != modStdLinkage { + ctx.ModuleErrorf("Rust dependency %q has the wrong StdLinkage; expected %#v, got %#v", depName, modStdLinkage, rustDepStdLinkage) + return + } + } + case depTag == rlibDepTag: rlib, ok := rustDep.compiler.(libraryInterface) if !ok || !rlib.rlib() { @@ -1285,6 +1286,14 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depPaths.transitiveImplementationDeps = append(depPaths.transitiveImplementationDeps, info.ImplementationDeps) } + if !rustDep.compiler.noStdlibs() { + rustDepStdLinkage := rustDep.compiler.stdLinkage(ctx.Device()) + if rustDepStdLinkage != modStdLinkage { + ctx.ModuleErrorf("Rust dependency %q has the wrong StdLinkage; expected %#v, got %#v", depName, modStdLinkage, rustDepStdLinkage) + return + } + } + case depTag == procMacroDepTag: directProcMacroDeps = append(directProcMacroDeps, rustDep) mod.Properties.AndroidMkProcMacroLibs = append(mod.Properties.AndroidMkProcMacroLibs, makeLibName) @@ -1603,7 +1612,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) { } stdLinkage := "dylib-std" - if mod.compiler.stdLinkage(ctx) == RlibLinkage { + if mod.compiler.stdLinkage(ctx.Device()) == RlibLinkage { stdLinkage = "rlib-std" } @@ -1670,7 +1679,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) { // stdlibs if deps.Stdlibs != nil { - if mod.compiler.stdLinkage(ctx) == RlibLinkage { + if mod.compiler.stdLinkage(ctx.Device()) == RlibLinkage { for _, lib := range deps.Stdlibs { actx.AddVariationDependencies(append(commonDepVariations, []blueprint.Variation{{Mutator: "rust_libraries", Variation: "rlib"}}...), rlibDepTag, lib) |