summaryrefslogtreecommitdiff
path: root/rust/library_test.go
diff options
context:
space:
mode:
authorIvan Lozano <ivanlozano@google.com>2020-12-08 14:43:00 -0500
committerIvan Lozano <ivanlozano@google.com>2020-12-09 09:55:12 -0500
commitea08613dd35bf8ae9f41e61e6c80a8fe255ce155 (patch)
tree5abd2eea941cf451a44a9926aa4d7f92848d9201 /rust/library_test.go
parent110d13bef3bd302a22facf16677a9ee893a0486c (diff)
Move prefer_rlib from binary to base compiler.
Moves the prefer_rlib property out from being exclusively a binary property to one thats part of the base compiler properties. This provides a little more control over the libstd linkage in our libraries. Specifically, this enables a usecase where rust_ffi_shared needs to link against libstd statically rather than dynamically. Bug: 175121262 Test: New Soong tests pass. Change-Id: If68014c684a75ba70e9d7dacbb01c7d360dc25a1
Diffstat (limited to 'rust/library_test.go')
-rw-r--r--rust/library_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/rust/library_test.go b/rust/library_test.go
index fec3992aa..54cd2a5b3 100644
--- a/rust/library_test.go
+++ b/rust/library_test.go
@@ -251,6 +251,13 @@ func TestLibstdLinkage(t *testing.T) {
srcs: ["foo.rs"],
crate_name: "bar",
rustlibs: ["libfoo"],
+ }
+ rust_ffi {
+ name: "libbar.prefer_rlib",
+ srcs: ["foo.rs"],
+ crate_name: "bar",
+ rustlibs: ["libfoo"],
+ prefer_rlib: true,
}`)
libfooDylib := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").Module().(*Module)
@@ -260,6 +267,9 @@ func TestLibstdLinkage(t *testing.T) {
libbarShared := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_shared").Module().(*Module)
libbarStatic := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_static").Module().(*Module)
+ // prefer_rlib works the same for both rust_library and rust_ffi, so a single check is sufficient here.
+ libbarRlibStd := ctx.ModuleForTests("libbar.prefer_rlib", "android_arm64_armv8-a_shared").Module().(*Module)
+
if !android.InList("libstd", libfooRlibStatic.Properties.AndroidMkRlibs) {
t.Errorf("rlib-std variant for device rust_library_rlib does not link libstd as an rlib")
}
@@ -279,4 +289,8 @@ func TestLibstdLinkage(t *testing.T) {
if !android.InList("libfoo.rlib-std", libbarStatic.Properties.AndroidMkRlibs) {
t.Errorf("Device rust_ffi_static does not link dependent rustlib rlib-std variant")
}
+ if !android.InList("libstd", libbarRlibStd.Properties.AndroidMkRlibs) {
+ t.Errorf("rust_ffi with prefer_rlib does not link libstd as an rlib")
+ }
+
}