rust:Add Rust support for made-to-order staticlibs
If a cc_library_static has a whole_static dependency against a
rust_ffi_static module, we need to ensure that rust_* dependents of the
cc_library_static don't just throw away the rlibs the cc_library_static
module is intending to include whole (and does so by propagating them
down to dependents to be included in the generated Rust staticlib).
This reuses the plumbing we have in cc to generate a Rust staticlib
from the propagated dependencies.
Bug: 395915782
Test: m rust
Change-Id: I413c8d2476e0b2a1c623581fdbfb5734a62ae455
diff --git a/rust/library.go b/rust/library.go
index 14d908c..bc7baf6 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -737,12 +737,15 @@
if library.rlib() {
library.flagExporter.exportStaticLibs(deps.staticLibObjects...)
}
-
// Since we have FFI rlibs, we need to collect their includes as well
if library.static() || library.shared() || library.rlib() || library.stubs() {
- android.SetProvider(ctx, cc.FlagExporterInfoProvider, cc.FlagExporterInfo{
+ ccExporter := cc.FlagExporterInfo{
IncludeDirs: android.FirstUniquePaths(library.includeDirs),
- })
+ }
+ if library.rlib() {
+ ccExporter.RustRlibDeps = append(ccExporter.RustRlibDeps, deps.reexportedCcRlibDeps...)
+ }
+ android.SetProvider(ctx, cc.FlagExporterInfoProvider, ccExporter)
}
if library.shared() || library.stubs() {