rust: Mutate prebuilt modules dylib/rlib
This change makes it possible to use a single module to provide both
dylib and rlib varieties of a library. This allows the use of libstd and
libtest from a rustlibs property, allowing linkage type to change
for different variants.
Bug: 159718669
Test: cd external crates; mma; m crosvm.experimental
Change-Id: I477c4d2faec63703fdc6dd42ba020747d6a50714
diff --git a/rust/testing.go b/rust/testing.go
index 00cd807..3d583e1 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -21,14 +21,26 @@
func GatherRequiredDepsForTest() string {
bp := `
- rust_prebuilt_dylib {
+ rust_prebuilt_library {
name: "libstd_x86_64-unknown-linux-gnu",
- srcs: [""],
+ crate_name: "std",
+ rlib: {
+ srcs: ["libstd.rlib"],
+ },
+ dylib: {
+ srcs: ["libstd.so"],
+ },
host_supported: true,
}
- rust_prebuilt_dylib {
+ rust_prebuilt_library {
name: "libtest_x86_64-unknown-linux-gnu",
- srcs: [""],
+ crate_name: "test",
+ rlib: {
+ srcs: ["libtest.rlib"],
+ },
+ dylib: {
+ srcs: ["libtest.so"],
+ },
host_supported: true,
}
@@ -41,34 +53,21 @@
nocrt: true,
system_shared_libs: [],
}
- rust_library_dylib {
+ rust_library {
name: "libstd",
crate_name: "std",
srcs: ["foo.rs"],
no_stdlibs: true,
host_supported: true,
+ native_coverage: false,
}
- rust_library_rlib {
- name: "libstd.static",
- crate_name: "std",
- srcs: ["foo.rs"],
- no_stdlibs: true,
- host_supported: true,
- }
- rust_library_dylib {
+ rust_library {
name: "libtest",
crate_name: "test",
srcs: ["foo.rs"],
no_stdlibs: true,
host_supported: true,
-
- }
- rust_library_rlib {
- name: "libtest.static",
- crate_name: "test",
- srcs: ["foo.rs"],
- no_stdlibs: true,
- host_supported: true,
+ native_coverage: false,
}
` + cc.GatherRequiredDepsForTest(android.NoOsType)
@@ -95,7 +94,9 @@
ctx.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory)
ctx.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory)
ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
+ ctx.RegisterModuleType("rust_prebuilt_library", PrebuiltLibraryFactory)
ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
+ ctx.RegisterModuleType("rust_prebuilt_rlib", PrebuiltRlibFactory)
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
// rust mutators
ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()