rust: Change default variants

rust_library now produces only rlib and dylib variants.
rust_library_foreign now produces static and shared variants.

This change was made because both are common cases, but all four
together essentially never happens. This allows us to have fewer repeat
module definitions.

Bug: 143217452
Test: cd external/rust; mma
Change-Id: Iaf69e8da38f7c12710331c51464699cf7cbbb656
This commit is contained in:
Matthew Maurer
2020-06-23 14:28:53 -07:00
parent 128f53b3b4
commit 2ae0513a8e
7 changed files with 103 additions and 52 deletions

View File

@@ -29,13 +29,18 @@ func TestLibraryVariants(t *testing.T) {
name: "libfoo",
srcs: ["foo.rs"],
crate_name: "foo",
}`)
}
rust_ffi_host {
name: "libfoo.ffi",
srcs: ["foo.rs"],
crate_name: "foo"
}`)
// Test all variants are being built.
libfooRlib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_rlib").Output("libfoo.rlib")
libfooDylib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_dylib").Output("libfoo.dylib.so")
libfooStatic := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_static").Output("libfoo.a")
libfooShared := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_shared").Output("libfoo.so")
libfooStatic := ctx.ModuleForTests("libfoo.ffi", "linux_glibc_x86_64_static").Output("libfoo.ffi.a")
libfooShared := ctx.ModuleForTests("libfoo.ffi", "linux_glibc_x86_64_shared").Output("libfoo.ffi.so")
rlibCrateType := "rlib"
dylibCrateType := "dylib"
@@ -119,7 +124,7 @@ func TestValidateLibraryStem(t *testing.T) {
func TestSharedLibrary(t *testing.T) {
ctx := testRust(t, `
rust_library {
rust_ffi_shared {
name: "libfoo",
srcs: ["foo.rs"],
crate_name: "foo",