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/image_test.go b/rust/image_test.go
index 71e271c..d84eb10 100644
--- a/rust/image_test.go
+++ b/rust/image_test.go
@@ -22,18 +22,20 @@
"android/soong/cc"
)
-// Test that cc modules can link against vendor_available rust_ffi_rlib/rust_ffi_static libraries.
+// Test that cc modules can depend on vendor_available rust_ffi_rlib/rust_ffi_static libraries.
func TestVendorLinkage(t *testing.T) {
ctx := testRust(t, `
cc_binary {
name: "fizz_vendor_available",
- static_libs: ["libfoo_vendor_static"],
- static_rlibs: ["libfoo_vendor"],
+ static_libs: [
+ "libfoo_vendor",
+ "libfoo_vendor_static"
+ ],
vendor_available: true,
}
cc_binary {
name: "fizz_soc_specific",
- static_rlibs: ["libfoo_vendor"],
+ static_libs: ["libfoo_vendor"],
soc_specific: true,
}
rust_ffi_rlib {
@@ -52,8 +54,8 @@
vendorBinary := ctx.ModuleForTests("fizz_vendor_available", "android_vendor_arm64_armv8-a").Module().(*cc.Module)
- if !android.InList("libfoo_vendor_static.vendor", vendorBinary.Properties.AndroidMkStaticLibs) {
- t.Errorf("vendorBinary should have a dependency on libfoo_vendor_static.vendor: %#v", vendorBinary.Properties.AndroidMkStaticLibs)
+ if android.InList("libfoo_vendor_static.vendor", vendorBinary.Properties.AndroidMkStaticLibs) {
+ t.Errorf("vendorBinary should not have a staticlib dependency on libfoo_vendor_static.vendor: %#v", vendorBinary.Properties.AndroidMkStaticLibs)
}
}
@@ -110,8 +112,10 @@
ctx := testRust(t, `
cc_library_shared {
name: "libcc_vendor_ramdisk",
- static_rlibs: ["libfoo_vendor_ramdisk"],
- static_libs: ["libfoo_static_vendor_ramdisk"],
+ static_libs: [
+ "libfoo_vendor_ramdisk",
+ "libfoo_static_vendor_ramdisk"
+ ],
system_shared_libs: [],
vendor_ramdisk_available: true,
}
@@ -131,8 +135,8 @@
vendorRamdiskLibrary := ctx.ModuleForTests("libcc_vendor_ramdisk", "android_vendor_ramdisk_arm64_armv8-a_shared").Module().(*cc.Module)
- if !android.InList("libfoo_static_vendor_ramdisk.vendor_ramdisk", vendorRamdiskLibrary.Properties.AndroidMkStaticLibs) {
- t.Errorf("libcc_vendor_ramdisk should have a dependency on libfoo_static_vendor_ramdisk")
+ if android.InList("libfoo_static_vendor_ramdisk.vendor_ramdisk", vendorRamdiskLibrary.Properties.AndroidMkStaticLibs) {
+ t.Errorf("libcc_vendor_ramdisk should not have a dependency on the libfoo_static_vendor_ramdisk static library")
}
}