summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2021-07-15 15:44:10 -0400
committer Ivan Lozano <ivanlozano@google.com> 2021-07-15 15:45:31 -0400
commit3ee74c82526666849180d874051856ea84cde42d (patch)
tree7b39de09244c6f9f4f0babb2164728984ec03170
parent9e3e9c905bda7e997a6e7a82414dd1584b9fc57b (diff)
rust: Remove libtest from stdlibs list
libtest does not need to be linked for every module type, so remove it from the stdlibs list. Instead, link it only when building benchmarks or tests. Bug: 193782599 Test: cd external/rust/crates/; mma Test: Rust tests still run correctly. Change-Id: I536be8754da0987e09340744d9ebf668b8e734d0
-rw-r--r--rust/benchmark.go1
-rw-r--r--rust/config/global.go1
-rw-r--r--rust/test.go8
-rw-r--r--rust/testing.go2
-rw-r--r--rust/vendor_snapshot_test.go23
5 files changed, 11 insertions, 24 deletions
diff --git a/rust/benchmark.go b/rust/benchmark.go
index b89f5cd9b..0e842435d 100644
--- a/rust/benchmark.go
+++ b/rust/benchmark.go
@@ -101,6 +101,7 @@ func (benchmark *benchmarkDecorator) compilerFlags(ctx ModuleContext, flags Flag
func (benchmark *benchmarkDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps = benchmark.binaryDecorator.compilerDeps(ctx, deps)
+ deps.Rustlibs = append(deps.Rustlibs, "libtest")
deps.Rustlibs = append(deps.Rustlibs, "libcriterion")
return deps
diff --git a/rust/config/global.go b/rust/config/global.go
index 43b49d18b..1b56237b3 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -29,7 +29,6 @@ var (
DefaultEdition = "2018"
Stdlibs = []string{
"libstd",
- "libtest",
}
// Mapping between Soong internal arch types and std::env constants.
diff --git a/rust/test.go b/rust/test.go
index 6caa7b168..e95b47cff 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -169,3 +169,11 @@ func RustTestHostFactory() android.Module {
func (test *testDecorator) stdLinkage(ctx *depsContext) RustLinkage {
return RlibLinkage
}
+
+func (test *testDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
+ deps = test.binaryDecorator.compilerDeps(ctx, deps)
+
+ deps.Rustlibs = append(deps.Rustlibs, "libtest")
+
+ return deps
+}
diff --git a/rust/testing.go b/rust/testing.go
index 72f87e136..94cdd9dcd 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -170,12 +170,10 @@ func GatherRequiredDepsForTest() string {
name: "libtest",
crate_name: "test",
srcs: ["foo.rs"],
- no_stdlibs: true,
host_supported: true,
vendor_available: true,
vendor_ramdisk_available: true,
native_coverage: false,
- sysroot: true,
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
min_sdk_version: "29",
}
diff --git a/rust/vendor_snapshot_test.go b/rust/vendor_snapshot_test.go
index 815f80ec7..60ddb653f 100644
--- a/rust/vendor_snapshot_test.go
+++ b/rust/vendor_snapshot_test.go
@@ -569,7 +569,6 @@ func TestVendorSnapshotUse(t *testing.T) {
],
rlibs: [
"libstd",
- "libtest",
"librust_vendor_available",
],
binaries: [
@@ -597,7 +596,6 @@ func TestVendorSnapshotUse(t *testing.T) {
],
rlibs: [
"libstd",
- "libtest",
"librust_vendor_available",
],
binaries: [
@@ -665,22 +663,6 @@ func TestVendorSnapshotUse(t *testing.T) {
}
vendor_snapshot_rlib {
- name: "libtest",
- version: "30",
- target_arch: "arm64",
- vendor: true,
- sysroot: true,
- arch: {
- arm64: {
- src: "libtest.rlib",
- },
- arm: {
- src: "libtest.rlib",
- },
- },
- }
-
- vendor_snapshot_rlib {
name: "librust_vendor_available",
version: "30",
target_arch: "arm64",
@@ -917,7 +899,6 @@ func TestVendorSnapshotUse(t *testing.T) {
"vendor/lib64.so": nil,
"vendor/liblog.so": nil,
"vendor/libstd.rlib": nil,
- "vendor/libtest.rlib": nil,
"vendor/librust_vendor_available.rlib": nil,
"vendor/crtbegin_so.o": nil,
"vendor/crtend_so.o": nil,
@@ -962,7 +943,7 @@ func TestVendorSnapshotUse(t *testing.T) {
}
libclientAndroidMkRlibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkRlibs
- if g, w := libclientAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64", "libtest.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) {
+ if g, w := libclientAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) {
t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g)
}
@@ -977,7 +958,7 @@ func TestVendorSnapshotUse(t *testing.T) {
}
libclientRustAndroidMkRlibs := ctx.ModuleForTests("libclient_rust", rlibVariant).Module().(*Module).Properties.AndroidMkRlibs
- if g, w := libclientRustAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64", "libtest.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) {
+ if g, w := libclientRustAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) {
t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g)
}