summaryrefslogtreecommitdiff
path: root/rust/binary_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'rust/binary_test.go')
-rw-r--r--rust/binary_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/rust/binary_test.go b/rust/binary_test.go
index 394abfcdd..f31a7fcda 100644
--- a/rust/binary_test.go
+++ b/rust/binary_test.go
@@ -30,6 +30,13 @@ func TestBinaryLinkage(t *testing.T) {
rustlibs: ["libfoo"],
host_supported: true,
}
+ rust_binary {
+ name: "rlib_linked",
+ srcs: ["foo.rs"],
+ rustlibs: ["libfoo"],
+ host_supported: true,
+ prefer_rlib: true,
+ }
rust_library {
name: "libfoo",
srcs: ["foo.rs"],
@@ -49,6 +56,34 @@ func TestBinaryLinkage(t *testing.T) {
}
}
+// Test that prefer_rlib links in libstd statically as well as rustlibs.
+func TestBinaryPreferRlib(t *testing.T) {
+ ctx := testRust(t, `
+ rust_binary {
+ name: "rlib_linked",
+ srcs: ["foo.rs"],
+ rustlibs: ["libfoo"],
+ host_supported: true,
+ prefer_rlib: true,
+ }
+ rust_library {
+ name: "libfoo",
+ srcs: ["foo.rs"],
+ crate_name: "foo",
+ host_supported: true,
+ }`)
+
+ mod := ctx.ModuleForTests("rlib_linked", "android_arm64_armv8-a").Module().(*Module)
+
+ if !android.InList("libfoo.rlib-std", mod.Properties.AndroidMkRlibs) {
+ t.Errorf("rustlibs dependency libfoo should be an rlib dep when prefer_rlib is defined")
+ }
+
+ if !android.InList("libstd", mod.Properties.AndroidMkRlibs) {
+ t.Errorf("libstd dependency should be an rlib dep when prefer_rlib is defined")
+ }
+}
+
// Test that the path returned by HostToolPath is correct
func TestHostToolPath(t *testing.T) {
ctx := testRust(t, `