Rust cdylib/statliclib support for vendor snapshot.

Adds support for platform vendor_available Rust FFI libraries and
binaries to be included in the vendor snapshot.

Because rlib and dylibs are not yet in snapshots, libstd cannot be
included in a vendor snapshot. As a result, vendor-specific Rust code
can't be guaranteed to work with the platform-provided vendor_available
modules built with a newer toolchain. For now, a check is added
indicating vendor-specific Rust code is unsupported.

This changes the linkage for vendor variants of these modules to default
to rlib linkage since dylibs cannot be included in the snapshot yet.

Bug: 184042776
Test: m nothing # new Soong tests pass
Change-Id: I502eaa4bb962eb87ff868fcf49b435f0d2f982e6
This commit is contained in:
Ivan Lozano
2021-05-20 13:39:16 -04:00
parent d67a6b0a88
commit 1921e8003d
9 changed files with 487 additions and 36 deletions

View File

@@ -37,21 +37,28 @@ var prepareForRustTest = android.GroupFixturePreparers(
genrule.PrepareForTestWithGenRuleBuildComponents,
PrepareForIntegrationTestWithRust,
PrepareForTestWithRustIncludeVndk,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.DeviceVndkVersion = StringPtr("current")
variables.ProductVndkVersion = StringPtr("current")
variables.Platform_vndk_version = StringPtr("29")
}),
)
var rustMockedFiles = android.MockFS{
"foo.rs": nil,
"foo.c": nil,
"src/bar.rs": nil,
"src/any.h": nil,
"proto.proto": nil,
"proto/buf.proto": nil,
"buf.proto": nil,
"foo.proto": nil,
"liby.so": nil,
"libz.so": nil,
"data.txt": nil,
"foo.rs": nil,
"foo.c": nil,
"src/bar.rs": nil,
"src/any.h": nil,
"c_includes/c_header.h": nil,
"rust_includes/rust_headers.h": nil,
"proto.proto": nil,
"proto/buf.proto": nil,
"buf.proto": nil,
"foo.proto": nil,
"liby.so": nil,
"libz.so": nil,
"data.txt": nil,
}
// testRust returns a TestContext in which a basic environment has been setup.
@@ -67,10 +74,16 @@ func testRust(t *testing.T, bp string) *android.TestContext {
}
func testRustVndk(t *testing.T, bp string) *android.TestContext {
return testRustVndkFs(t, bp, rustMockedFiles)
}
const vendorVariant = "android_vendor.29_arm64_armv8-a_shared"
func testRustVndkFs(t *testing.T, bp string, fs android.MockFS) *android.TestContext {
skipTestIfOsNotSupported(t)
result := android.GroupFixturePreparers(
prepareForRustTest,
rustMockedFiles.AddToFixture(),
fs.AddToFixture(),
android.FixtureModifyProductVariables(
func(variables android.FixtureProductVariables) {
variables.DeviceVndkVersion = StringPtr("current")
@@ -80,6 +93,7 @@ func testRustVndk(t *testing.T, bp string) *android.TestContext {
),
).RunTestWithBp(t, bp)
return result.TestContext
}
// testRustCov returns a TestContext in which a basic environment has been
@@ -115,10 +129,14 @@ func testRustError(t *testing.T, pattern string, bp string) {
// testRustVndkError is similar to testRustError, but can be used to test VNDK-related errors.
func testRustVndkError(t *testing.T, pattern string, bp string) {
testRustVndkFsError(t, pattern, bp, rustMockedFiles)
}
func testRustVndkFsError(t *testing.T, pattern string, bp string, fs android.MockFS) {
skipTestIfOsNotSupported(t)
android.GroupFixturePreparers(
prepareForRustTest,
rustMockedFiles.AddToFixture(),
fs.AddToFixture(),
android.FixtureModifyProductVariables(
func(variables android.FixtureProductVariables) {
variables.DeviceVndkVersion = StringPtr("current")