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
This commit is contained in:
Ivan Lozano
2024-05-17 14:13:41 -04:00
parent 9c067f62d0
commit fd47b1ab6a
15 changed files with 255 additions and 233 deletions

View File

@@ -65,6 +65,11 @@ func TestCompilationOutputFiles(t *testing.T) {
crate_name: "rust_ffi",
srcs: ["lib.rs"],
}
rust_ffi_static {
name: "librust_ffi_static",
crate_name: "rust_ffi",
srcs: ["lib.rs"],
}
`)
testcases := []struct {
testName string
@@ -118,14 +123,14 @@ func TestCompilationOutputFiles(t *testing.T) {
},
},
{
testName: "rust_ffi static",
moduleName: "librust_ffi",
variant: "android_arm64_armv8-a_static",
testName: "rust_ffi_static rlib",
moduleName: "librust_ffi_static",
variant: "android_arm64_armv8-a_rlib_rlib-std",
expectedFiles: []string{
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_static/librust_ffi.a",
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_static/librust_ffi.a.clippy",
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_static/meta_lic",
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_static/rustdoc.timestamp",
"out/soong/.intermediates/librust_ffi_static/android_arm64_armv8-a_rlib_rlib-std/librust_ffi_static.rlib",
"out/soong/.intermediates/librust_ffi_static/android_arm64_armv8-a_rlib_rlib-std/librust_ffi_static.rlib.clippy",
"out/soong/.intermediates/librust_ffi_static/android_arm64_armv8-a_rlib_rlib-std/meta_lic",
"out/soong/.intermediates/librust_ffi_static/android_arm64_armv8-a_rlib_rlib-std/rustdoc.timestamp",
},
},
{
@@ -148,6 +153,7 @@ func TestCompilationOutputFiles(t *testing.T) {
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_shared/unstripped/librust_ffi.so",
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_shared/unstripped/librust_ffi.so.toc",
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_shared/meta_lic",
"out/soong/.intermediates/librust_ffi/android_arm64_armv8-a_shared/rustdoc.timestamp",
"out/soong/target/product/test_device/system/lib64/librust_ffi.so",
},
},