cc/rust: Alias ffi rlib variant for static_libs
Alias the rlib variant to "link: static". This allows declaring
rust_ffi_rlib modules in static_libs. This effectively removes any
distinction between rust_ffi_static and rust_ffi_rlib. Removing the
functionality for building Rust staticlib modules will be cleaned up in
a follow-on CL.
This should have the effect of changing the default linkage for all rust
modules in static_libs from linking individual staticlibs to building a
single staticlib that includes all rust_ffi rlib dependencies.
This removes the static_rlibs property, as we're now handling
the choice dynamically. This also makes rlibs only propagate through
cc_library_static modules if the rlib is included in
whole_static_lib. This both mirrors the expected behavior of
cc libraries and helps control which version of a crate ends up in the
final link (e.g. libdoh_ffi vs libdoh_ffi_for_test).
Bug: 254469782
Test: m
Test: m blueprint_tests
Change-Id: I2925f67f6dc9329dae3dcccafb8560900ac8a6fc
diff --git a/rust/rust_test.go b/rust/rust_test.go
index 8b96df8..0d005d0 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -447,23 +447,30 @@
export_include_dirs: ["foo_includes"]
}
+ rust_ffi_rlib {
+ name: "libbuzz",
+ crate_name: "buzz",
+ srcs: ["src/lib.rs"],
+ export_include_dirs: ["buzz_includes"]
+ }
+
cc_library_shared {
name: "libcc_shared",
srcs:["foo.c"],
- static_rlibs: ["libbar"],
+ static_libs: ["libbar"],
}
cc_library_static {
name: "libcc_static",
srcs:["foo.c"],
- static_rlibs: ["libfoo"],
+ static_libs: ["libbuzz"],
+ whole_static_libs: ["libfoo"],
}
cc_binary {
name: "ccBin",
srcs:["foo.c"],
- static_rlibs: ["libbar"],
- static_libs: ["libcc_static"],
+ static_libs: ["libcc_static", "libbar"],
}
`)
@@ -514,10 +521,13 @@
"-Ibar_includes", ccbin_cc.Args)
}
- // Make sure that direct dependencies and indirect dependencies are
+ // Make sure that direct dependencies and indirect whole static dependencies are
// propagating correctly to the generated rlib.
if !strings.Contains(ccbin_rustc.Args["libFlags"], "--extern foo=") {
- t.Errorf("Missing indirect dependency libfoo when writing generated Rust staticlib: %#v", ccbin_rustc.Args["libFlags"])
+ t.Errorf("Missing indirect whole_static_lib dependency libfoo when writing generated Rust staticlib: %#v", ccbin_rustc.Args["libFlags"])
+ }
+ if strings.Contains(ccbin_rustc.Args["libFlags"], "--extern buzz=") {
+ t.Errorf("Indirect static_lib dependency libbuzz found when writing generated Rust staticlib: %#v", ccbin_rustc.Args["libFlags"])
}
if !strings.Contains(ccbin_rustc.Args["libFlags"], "--extern bar=") {
t.Errorf("Missing direct dependency libbar when writing generated Rust staticlib: %#v", ccbin_rustc.Args["libFlags"])