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

Commit c6868383 authored by Matthew Maurer's avatar Matthew Maurer
Browse files

Support Rust in Ramdisk

Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a ramdisk binary
Change-Id: I9682b978936624133e5a62e94caace0e8958fd0f
parent a61e31f6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ var (
	NativeBridgeSuffix  = ".native_bridge"
	ProductSuffix       = ".product"
	VendorSuffix        = ".vendor"
	ramdiskSuffix       = ".ramdisk"
	RamdiskSuffix       = ".ramdisk"
	VendorRamdiskSuffix = ".vendor_ramdisk"
	RecoverySuffix      = ".recovery"
	sdkSuffix           = ".sdk"
+2 −2
Original line number Diff line number Diff line
@@ -1668,7 +1668,7 @@ func (c *Module) setSubnameProperty(actx android.ModuleContext) {
		// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
		c.Properties.SubName += VendorSuffix
	} else if c.InRamdisk() && !c.OnlyInRamdisk() {
		c.Properties.SubName += ramdiskSuffix
		c.Properties.SubName += RamdiskSuffix
	} else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() {
		c.Properties.SubName += VendorRamdiskSuffix
	} else if c.InRecovery() && !c.OnlyInRecovery() {
@@ -3029,7 +3029,7 @@ func MakeLibName(ctx android.ModuleContext, c LinkableInterface, ccDep LinkableI
		// core module, so update the dependency name here accordingly.
		return libName + ccDep.SubName()
	} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
		return libName + ramdiskSuffix
		return libName + RamdiskSuffix
	} else if ccDep.InVendorRamdisk() && !ccDep.OnlyInVendorRamdisk() {
		return libName + VendorRamdiskSuffix
	} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
+3 −5
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ func (mod *Module) ProductAvailable() bool {
}

func (mod *Module) RamdiskAvailable() bool {
	return false
	return Bool(mod.Properties.Ramdisk_available)
}

func (mod *Module) VendorRamdiskAvailable() bool {
@@ -62,9 +62,7 @@ func (mod *Module) AppendExtraVariant(extraVariant string) {
}

func (mod *Module) SetRamdiskVariantNeeded(b bool) {
	if b {
		panic("Setting ramdisk variant needed for Rust module is unsupported: " + mod.BaseModuleName())
	}
	mod.Properties.RamdiskVariantNeeded = b
}

func (mod *Module) SetVendorRamdiskVariantNeeded(b bool) {
@@ -97,7 +95,7 @@ func (mod *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
}

func (mod *Module) RamdiskVariantNeeded(android.BaseModuleContext) bool {
	return mod.InRamdisk()
	return mod.Properties.RamdiskVariantNeeded
}

func (mod *Module) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+10 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ type BaseProperties struct {
	// Set by imageMutator
	CoreVariantNeeded          bool     `blueprint:"mutated"`
	VendorRamdiskVariantNeeded bool     `blueprint:"mutated"`
	RamdiskVariantNeeded       bool     `blueprint:"mutated"`
	RecoveryVariantNeeded      bool     `blueprint:"mutated"`
	ExtraVariants              []string `blueprint:"mutated"`

@@ -95,6 +96,13 @@ type BaseProperties struct {
	SnapshotSharedLibs []string `blueprint:"mutated"`
	SnapshotStaticLibs []string `blueprint:"mutated"`

	// Make this module available when building for ramdisk.
	// On device without a dedicated recovery partition, the module is only
	// available after switching root into
	// /first_stage_ramdisk. To expose the module before switching root, install
	// the recovery variant instead.
	Ramdisk_available *bool

	// Make this module available when building for vendor ramdisk.
	// On device without a dedicated recovery partition, the module is only
	// available after switching root into
@@ -817,6 +825,8 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
		} else {
			mod.Properties.SubName += cc.VendorSuffix
		}
	} else if mod.InRamdisk() && !mod.OnlyInRamdisk() {
		mod.Properties.SubName += cc.RamdiskSuffix
	} else if mod.InVendorRamdisk() && !mod.OnlyInVendorRamdisk() {
		mod.Properties.SubName += cc.VendorRamdiskSuffix
	} else if mod.InRecovery() && !mod.OnlyInRecovery() {