Support Rust in Ramdisk

Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a ramdisk binary
Change-Id: I9682b978936624133e5a62e94caace0e8958fd0f
This commit is contained in:
Matthew Maurer 2021-07-13 14:12:37 -07:00
parent a61e31f66a
commit c6868383f4
4 changed files with 16 additions and 8 deletions

View file

@ -27,7 +27,7 @@ var (
NativeBridgeSuffix = ".native_bridge"
ProductSuffix = ".product"
VendorSuffix = ".vendor"
ramdiskSuffix = ".ramdisk"
RamdiskSuffix = ".ramdisk"
VendorRamdiskSuffix = ".vendor_ramdisk"
RecoverySuffix = ".recovery"
sdkSuffix = ".sdk"

View file

@ -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() {

View file

@ -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 {

View file

@ -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() {