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

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

Merge "rust: Add rust_ffi_static vendor ramdisk Support"

parents bb483cbc e6d3098c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@ import (
var (
	nativeBridgeSuffix  = ".native_bridge"
	productSuffix       = ".product"
	vendorSuffix        = ".vendor"
	VendorSuffix        = ".vendor"
	ramdiskSuffix       = ".ramdisk"
	vendorRamdiskSuffix = ".vendor_ramdisk"
	VendorRamdiskSuffix = ".vendor_ramdisk"
	recoverySuffix      = ".recovery"
	sdkSuffix           = ".sdk"
)
+4 −4
Original line number Diff line number Diff line
@@ -1544,7 +1544,7 @@ func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string
		nameSuffix = productSuffix
	} else {
		vndkVersion = ctx.DeviceConfig().VndkVersion()
		nameSuffix = vendorSuffix
		nameSuffix = VendorSuffix
	}
	if vndkVersion == "current" {
		vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
@@ -1591,11 +1591,11 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
	} else if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
		// .vendor suffix is added for backward compatibility with VNDK snapshot whose names with
		// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
		c.Properties.SubName += vendorSuffix
		c.Properties.SubName += VendorSuffix
	} else if c.InRamdisk() && !c.OnlyInRamdisk() {
		c.Properties.SubName += ramdiskSuffix
	} else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() {
		c.Properties.SubName += vendorRamdiskSuffix
		c.Properties.SubName += VendorRamdiskSuffix
	} else if c.InRecovery() && !c.OnlyInRecovery() {
		c.Properties.SubName += recoverySuffix
	} else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) {
@@ -2927,7 +2927,7 @@ func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface,
	} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
		return libName + ramdiskSuffix
	} else if ccDep.InVendorRamdisk() && !ccDep.OnlyInVendorRamdisk() {
		return libName + vendorRamdiskSuffix
		return libName + VendorRamdiskSuffix
	} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
		return libName + recoverySuffix
	} else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled {
+1 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ func (vendorSnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
}

func (vendorSnapshotImage) moduleNameSuffix() string {
	return vendorSuffix
	return VendorSuffix
}

func (recoverySnapshotImage) init(ctx android.RegistrationContext) {
+12 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
			name: "libatomic",
			defaults: ["linux_bionic_supported"],
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_bridge_supported: true,
@@ -52,6 +53,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
		toolchain_library {
			name: "libcompiler_rt-extras",
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			src: "",
@@ -60,6 +62,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
		toolchain_library {
			name: "libclang_rt.builtins-arm-android",
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_bridge_supported: true,
@@ -69,6 +72,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
		toolchain_library {
			name: "libclang_rt.builtins-aarch64-android",
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_bridge_supported: true,
@@ -93,6 +97,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
		toolchain_library {
			name: "libclang_rt.builtins-i686-android",
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_bridge_supported: true,
@@ -103,6 +108,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
			name: "libclang_rt.builtins-x86_64-android",
			defaults: ["linux_bionic_supported"],
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_bridge_supported: true,
@@ -113,6 +119,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
			name: "libunwind",
			defaults: ["linux_bionic_supported"],
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_bridge_supported: true,
@@ -238,6 +245,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
		cc_library {
			name: "libprofile-extras",
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_coverage: false,
@@ -248,6 +256,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
		cc_library {
			name: "libprofile-clang-extras",
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			native_coverage: false,
@@ -319,6 +328,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
			system_shared_libs: [],
			stl: "none",
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			host_supported: true,
@@ -356,6 +366,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
			stl: "none",
			host_supported: false,
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			recovery_available: true,
			min_sdk_version: "29",
@@ -380,6 +391,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
			defaults: ["linux_bionic_supported"],
			recovery_available: true,
			vendor_available: true,
			vendor_ramdisk_available: true,
			product_available: true,
			native_bridge_supported: true,
			stl: "none",
+22 −4
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import (
var _ android.ImageInterface = (*Module)(nil)

func (mod *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
	return false
	return mod.Properties.VendorRamdiskVariantNeeded
}

func (mod *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
@@ -52,6 +52,10 @@ func (mod *Module) InRecovery() bool {
	return false
}

func (mod *Module) InVendorRamdisk() bool {
	return mod.ModuleBase.InVendorRamdisk() || mod.ModuleBase.InstallInVendorRamdisk()
}

func (mod *Module) OnlyInRamdisk() bool {
	// TODO(b/165791368)
	return false
@@ -86,7 +90,9 @@ func (c *Module) InProduct() bool {

func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
	m := module.(*Module)
	if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
	if variant == android.VendorRamdiskVariation {
		m.MakeAsPlatform()
	} else if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
		m.Properties.ImageVariationPrefix = cc.VendorVariationPrefix
		m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)

@@ -117,6 +123,8 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
	}

	coreVariantNeeded := true
	vendorRamdiskVariantNeeded := false

	var vendorVariants []string

	if mod.HasVendorVariant() {
@@ -138,15 +146,23 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
			// We can't check shared() here because image mutator is called before the library mutator, so we need to
			// check buildShared()
			if lib.buildShared() {
				mctx.PropertyErrorf(prop, "can only be set for rust_ffi_static modules.")
				mctx.PropertyErrorf(prop, "cannot be set for rust_ffi or rust_ffi_shared modules.")
			} else {
				vendorVariants = append(vendorVariants, platformVndkVersion)
			}
		}
	}

	if Bool(mod.Properties.Vendor_ramdisk_available) {
		if lib, ok := mod.compiler.(libraryInterface); !ok || (ok && lib.buildShared()) {
			mctx.PropertyErrorf("vendor_ramdisk_available", "cannot be set for rust_ffi or rust_ffi_shared modules.")
		} else {
			vendorRamdiskVariantNeeded = true
		}
	}

	if vendorSpecific {
		if lib, ok := mod.compiler.(libraryInterface); !ok || (ok && !lib.static()) {
		if lib, ok := mod.compiler.(libraryInterface); !ok || (ok && (lib.buildShared() || lib.buildDylib() || lib.buildRlib())) {
			mctx.ModuleErrorf("Rust vendor specific modules are currently only supported for rust_ffi_static modules.")
		} else {
			coreVariantNeeded = false
@@ -155,6 +171,8 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
	}

	mod.Properties.CoreVariantNeeded = coreVariantNeeded
	mod.Properties.VendorRamdiskVariantNeeded = vendorRamdiskVariantNeeded

	for _, variant := range android.FirstUniqueStrings(vendorVariants) {
		mod.Properties.ExtraVariants = append(mod.Properties.ExtraVariants, cc.VendorVariationPrefix+variant)
	}
Loading