Support Rust in Ramdisk
Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a ramdisk binary
Change-Id: I9682b978936624133e5a62e94caace0e8958fd0f
diff --git a/rust/image.go b/rust/image.go
index 0061cb3..5d7c027 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -38,7 +38,7 @@
}
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) 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) RamdiskVariantNeeded(android.BaseModuleContext) bool {
- return mod.InRamdisk()
+ return mod.Properties.RamdiskVariantNeeded
}
func (mod *Module) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
diff --git a/rust/rust.go b/rust/rust.go
index 70721fb..ba395ec 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -84,6 +84,7 @@
// 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 @@
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 @@
} 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() {