Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2b1d2e4 authored by Ivan Lozano's avatar Ivan Lozano Committed by Gerrit Code Review
Browse files

Merge "rust: Remove rust_ffi_rlibs, keep rust_ffi_static" into main

parents aea639d6 61848425
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -638,7 +638,7 @@ func CollectAllSharedDependencies(ctx android.ModuleContext) (android.RuleBuilde
	ctx.WalkDeps(func(child, parent android.Module) bool {

		// If this is a Rust module which is not rust_ffi_shared, we still want to bundle any transitive
		// shared dependencies (even for rust_ffi_rlib or rust_ffi_static)
		// shared dependencies (even for rust_ffi_static)
		if rustmod, ok := child.(LinkableInterface); ok && rustmod.RustLibraryInterface() && !rustmod.Shared() {
			if recursed[ctx.OtherModuleName(child)] {
				return false
+1 −1
Original line number Diff line number Diff line
@@ -145,6 +145,6 @@ func TestCCFuzzDepBundling(t *testing.T) {
		t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", fuzz_static_libtest.FuzzSharedLibraries().String())
	}
	if !strings.Contains(fuzz_staticffi_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") {
		t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_rlib ('libcc_transitive_dep'): %#v", fuzz_staticffi_libtest.FuzzSharedLibraries().String())
		t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", fuzz_staticffi_libtest.FuzzSharedLibraries().String())
	}
}
+8 −22
Original line number Diff line number Diff line
@@ -22,14 +22,13 @@ import (
	"android/soong/cc"
)

// Test that cc modules can depend on vendor_available rust_ffi_rlib/rust_ffi_static libraries.
// Test that cc modules can depend on vendor_available rust_ffi_static libraries.
func TestVendorLinkage(t *testing.T) {
	ctx := testRust(t, `
			cc_binary {
				name: "fizz_vendor_available",
				static_libs: [
					"libfoo_vendor",
					"libfoo_vendor_static"
				],
				vendor_available: true,
			}
@@ -38,14 +37,8 @@ func TestVendorLinkage(t *testing.T) {
				static_libs: ["libfoo_vendor"],
				soc_specific: true,
			}
			rust_ffi_rlib {
				name: "libfoo_vendor",
				crate_name: "foo",
				srcs: ["foo.rs"],
				vendor_available: true,
			}
			rust_ffi_static {
				name: "libfoo_vendor_static",
				name: "libfoo_vendor",
				crate_name: "foo",
				srcs: ["foo.rs"],
				vendor_available: true,
@@ -54,8 +47,8 @@ func TestVendorLinkage(t *testing.T) {

	vendorBinary := ctx.ModuleForTests("fizz_vendor_available", "android_vendor_arm64_armv8-a").Module().(*cc.Module)

	if android.InList("libfoo_vendor_static.vendor", vendorBinary.Properties.AndroidMkStaticLibs) {
		t.Errorf("vendorBinary should not have a staticlib dependency on libfoo_vendor_static.vendor: %#v", vendorBinary.Properties.AndroidMkStaticLibs)
	if android.InList("libfoo_vendor.vendor", vendorBinary.Properties.AndroidMkStaticLibs) {
		t.Errorf("vendorBinary should not have a staticlib dependency on libfoo_vendor.vendor: %#v", vendorBinary.Properties.AndroidMkStaticLibs)
	}
}

@@ -107,26 +100,19 @@ func TestImageCfgFlag(t *testing.T) {

}

// Test that cc modules can link against vendor_ramdisk_available rust_ffi_rlib and rust_ffi_static libraries.
// Test that cc modules can link against vendor_ramdisk_available rust_ffi_static libraries.
func TestVendorRamdiskLinkage(t *testing.T) {
	ctx := testRust(t, `
			cc_library_shared {
				name: "libcc_vendor_ramdisk",
				static_libs: [
					"libfoo_vendor_ramdisk",
					"libfoo_static_vendor_ramdisk"
				],
				system_shared_libs: [],
				vendor_ramdisk_available: true,
			}
			rust_ffi_rlib {
				name: "libfoo_vendor_ramdisk",
				crate_name: "foo",
				srcs: ["foo.rs"],
				vendor_ramdisk_available: true,
			}
			rust_ffi_static {
				name: "libfoo_static_vendor_ramdisk",
				name: "libfoo_vendor_ramdisk",
				crate_name: "foo",
				srcs: ["foo.rs"],
				vendor_ramdisk_available: true,
@@ -135,8 +121,8 @@ func TestVendorRamdiskLinkage(t *testing.T) {

	vendorRamdiskLibrary := ctx.ModuleForTests("libcc_vendor_ramdisk", "android_vendor_ramdisk_arm64_armv8-a_shared").Module().(*cc.Module)

	if android.InList("libfoo_static_vendor_ramdisk.vendor_ramdisk", vendorRamdiskLibrary.Properties.AndroidMkStaticLibs) {
		t.Errorf("libcc_vendor_ramdisk should not have a dependency on the libfoo_static_vendor_ramdisk static library")
	if android.InList("libfoo_vendor_ramdisk.vendor_ramdisk", vendorRamdiskLibrary.Properties.AndroidMkStaticLibs) {
		t.Errorf("libcc_vendor_ramdisk should not have a dependency on the libfoo_vendor_ramdisk static library")
	}
}

+2 −8
Original line number Diff line number Diff line
@@ -40,13 +40,8 @@ func init() {
	android.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory)
	android.RegisterModuleType("rust_ffi", RustFFIFactory)
	android.RegisterModuleType("rust_ffi_shared", RustFFISharedFactory)
	android.RegisterModuleType("rust_ffi_rlib", RustLibraryRlibFactory)
	android.RegisterModuleType("rust_ffi_host", RustFFIHostFactory)
	android.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory)
	android.RegisterModuleType("rust_ffi_host_rlib", RustLibraryRlibHostFactory)

	// TODO: Remove when all instances of rust_ffi_static have been switched to rust_ffi_rlib
	// Alias rust_ffi_static to the rust_ffi_rlib factory
	android.RegisterModuleType("rust_ffi_static", RustLibraryRlibFactory)
	android.RegisterModuleType("rust_ffi_host_static", RustLibraryRlibHostFactory)
}
@@ -291,8 +286,7 @@ func RustLibraryFactory() android.Module {
	return module.Init()
}

// rust_ffi produces all FFI variants (rust_ffi_shared, rust_ffi_static, and
// rust_ffi_rlib).
// rust_ffi produces all FFI variants (rust_ffi_shared, rust_ffi_static).
func RustFFIFactory() android.Module {
	module, library := NewRustLibrary(android.HostAndDeviceSupported)
	library.BuildOnlyFFI()
@@ -330,7 +324,7 @@ func RustLibraryHostFactory() android.Module {
}

// rust_ffi_host produces all FFI variants for the host
// (rust_ffi_rlib_host, rust_ffi_static_host, and rust_ffi_shared_host).
// (rust_ffi_static_host and rust_ffi_shared_host).
func RustFFIHostFactory() android.Module {
	module, library := NewRustLibrary(android.HostSupported)
	library.BuildOnlyFFI()
+6 −6
Original line number Diff line number Diff line
@@ -202,9 +202,9 @@ func TestStaticLibraryLinkage(t *testing.T) {

func TestNativeDependencyOfRlib(t *testing.T) {
	ctx := testRust(t, `
		rust_ffi_rlib {
			name: "libffi_rlib",
			crate_name: "ffi_rlib",
		rust_ffi_static {
			name: "libffi_static",
			crate_name: "ffi_static",
			rlibs: ["librust_rlib"],
			srcs: ["foo.rs"],
		}
@@ -227,7 +227,7 @@ func TestNativeDependencyOfRlib(t *testing.T) {

	rustRlibRlibStd := ctx.ModuleForTests("librust_rlib", "android_arm64_armv8-a_rlib_rlib-std")
	rustRlibDylibStd := ctx.ModuleForTests("librust_rlib", "android_arm64_armv8-a_rlib_dylib-std")
	ffiRlib := ctx.ModuleForTests("libffi_rlib", "android_arm64_armv8-a_rlib_rlib-std")
	ffiRlib := ctx.ModuleForTests("libffi_static", "android_arm64_armv8-a_rlib_rlib-std")

	modules := []android.TestingModule{
		rustRlibRlibStd,
@@ -412,10 +412,10 @@ func TestLibstdLinkage(t *testing.T) {
		t.Errorf("Device rust_ffi_shared does not link libstd as an dylib")
	}
	if !android.InList("libstd", libbarFFIRlib.Properties.AndroidMkRlibs) {
		t.Errorf("Device rust_ffi_rlib does not link libstd as an rlib")
		t.Errorf("Device rust_ffi_static does not link libstd as an rlib")
	}
	if !android.InList("libfoo.rlib-std", libbarFFIRlib.Properties.AndroidMkRlibs) {
		t.Errorf("Device rust_ffi_rlib does not link dependent rustlib rlib-std variant")
		t.Errorf("Device rust_ffi_static does not link dependent rustlib rlib-std variant")
	}
	if !android.InList("libstd", libbarRlibStd.Properties.AndroidMkRlibs) {
		t.Errorf("rust_ffi with prefer_rlib does not link libstd as an rlib")
Loading