Merge changes I9682b978,I35465715,I9c5aa5f3,I1c76e620

* changes:
  Support Rust in Ramdisk
  Support Rust in native-bridge
  Support Rust in Product
  Support Rust in Recovery
This commit is contained in:
Matthew Maurer
2021-08-19 02:55:46 +00:00
committed by Gerrit Code Review
5 changed files with 63 additions and 33 deletions

View File

@@ -24,12 +24,12 @@ import (
) )
var ( var (
nativeBridgeSuffix = ".native_bridge" NativeBridgeSuffix = ".native_bridge"
productSuffix = ".product" ProductSuffix = ".product"
VendorSuffix = ".vendor" VendorSuffix = ".vendor"
ramdiskSuffix = ".ramdisk" RamdiskSuffix = ".ramdisk"
VendorRamdiskSuffix = ".vendor_ramdisk" VendorRamdiskSuffix = ".vendor_ramdisk"
recoverySuffix = ".recovery" RecoverySuffix = ".recovery"
sdkSuffix = ".sdk" sdkSuffix = ".sdk"
) )
@@ -182,7 +182,7 @@ func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string
if ctx.Target().NativeBridge == android.NativeBridgeEnabled { if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
var result []string var result []string
for _, override := range overrides { for _, override := range overrides {
result = append(result, override+nativeBridgeSuffix) result = append(result, override+NativeBridgeSuffix)
} }
return result return result
} }

View File

@@ -1632,7 +1632,7 @@ func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string
return "" return ""
} }
vndkVersion = ctx.DeviceConfig().ProductVndkVersion() vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
nameSuffix = productSuffix nameSuffix = ProductSuffix
} else { } else {
vndkVersion = ctx.DeviceConfig().VndkVersion() vndkVersion = ctx.DeviceConfig().VndkVersion()
nameSuffix = VendorSuffix nameSuffix = VendorSuffix
@@ -1652,7 +1652,7 @@ func (c *Module) setSubnameProperty(actx android.ModuleContext) {
c.Properties.SubName = "" c.Properties.SubName = ""
if c.Target().NativeBridge == android.NativeBridgeEnabled { if c.Target().NativeBridge == android.NativeBridgeEnabled {
c.Properties.SubName += nativeBridgeSuffix c.Properties.SubName += NativeBridgeSuffix
} }
llndk := c.IsLlndk() llndk := c.IsLlndk()
@@ -1668,11 +1668,11 @@ func (c *Module) setSubnameProperty(actx android.ModuleContext) {
// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp. // 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() { } else if c.InRamdisk() && !c.OnlyInRamdisk() {
c.Properties.SubName += ramdiskSuffix c.Properties.SubName += RamdiskSuffix
} else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() { } else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() {
c.Properties.SubName += VendorRamdiskSuffix c.Properties.SubName += VendorRamdiskSuffix
} else if c.InRecovery() && !c.OnlyInRecovery() { } else if c.InRecovery() && !c.OnlyInRecovery() {
c.Properties.SubName += recoverySuffix c.Properties.SubName += RecoverySuffix
} else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) { } else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) {
c.Properties.SubName += sdkSuffix c.Properties.SubName += sdkSuffix
if c.SplitPerApiLevel() { if c.SplitPerApiLevel() {
@@ -3029,13 +3029,13 @@ func MakeLibName(ctx android.ModuleContext, c LinkableInterface, ccDep LinkableI
// core module, so update the dependency name here accordingly. // core module, so update the dependency name here accordingly.
return libName + ccDep.SubName() return libName + ccDep.SubName()
} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() { } else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
return libName + ramdiskSuffix return libName + RamdiskSuffix
} else if ccDep.InVendorRamdisk() && !ccDep.OnlyInVendorRamdisk() { } else if ccDep.InVendorRamdisk() && !ccDep.OnlyInVendorRamdisk() {
return libName + VendorRamdiskSuffix return libName + VendorRamdiskSuffix
} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() { } else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
return libName + recoverySuffix return libName + RecoverySuffix
} else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled { } else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled {
return libName + nativeBridgeSuffix return libName + NativeBridgeSuffix
} else { } else {
return libName return libName
} }

View File

@@ -61,7 +61,7 @@ func (recoverySnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
} }
func (recoverySnapshotImage) moduleNameSuffix() string { func (recoverySnapshotImage) moduleNameSuffix() string {
return recoverySuffix return RecoverySuffix
} }
// Override existing vendor and recovery snapshot for cc module specific extra functions // Override existing vendor and recovery snapshot for cc module specific extra functions

View File

@@ -34,11 +34,11 @@ func (mod *Module) OdmAvailable() bool {
} }
func (mod *Module) ProductAvailable() bool { func (mod *Module) ProductAvailable() bool {
return false return Bool(mod.VendorProperties.Product_available)
} }
func (mod *Module) RamdiskAvailable() bool { func (mod *Module) RamdiskAvailable() bool {
return false return Bool(mod.Properties.Ramdisk_available)
} }
func (mod *Module) VendorRamdiskAvailable() bool { func (mod *Module) VendorRamdiskAvailable() bool {
@@ -50,7 +50,7 @@ func (mod *Module) AndroidModuleBase() *android.ModuleBase {
} }
func (mod *Module) RecoveryAvailable() bool { func (mod *Module) RecoveryAvailable() bool {
return false return Bool(mod.Properties.Recovery_available)
} }
func (mod *Module) ExtraVariants() []string { func (mod *Module) ExtraVariants() []string {
@@ -62,9 +62,7 @@ func (mod *Module) AppendExtraVariant(extraVariant string) {
} }
func (mod *Module) SetRamdiskVariantNeeded(b bool) { func (mod *Module) SetRamdiskVariantNeeded(b bool) {
if b { mod.Properties.RamdiskVariantNeeded = b
panic("Setting ramdisk variant needed for Rust module is unsupported: " + mod.BaseModuleName())
}
} }
func (mod *Module) SetVendorRamdiskVariantNeeded(b bool) { func (mod *Module) SetVendorRamdiskVariantNeeded(b bool) {
@@ -72,9 +70,7 @@ func (mod *Module) SetVendorRamdiskVariantNeeded(b bool) {
} }
func (mod *Module) SetRecoveryVariantNeeded(b bool) { func (mod *Module) SetRecoveryVariantNeeded(b bool) {
if b { mod.Properties.RecoveryVariantNeeded = b
panic("Setting recovery variant needed for Rust module is unsupported: " + mod.BaseModuleName())
}
} }
func (mod *Module) SetCoreVariantNeeded(b bool) { func (mod *Module) SetCoreVariantNeeded(b bool) {
@@ -99,7 +95,7 @@ func (mod *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
} }
func (mod *Module) RamdiskVariantNeeded(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 { func (mod *Module) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@@ -107,7 +103,7 @@ func (mod *Module) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool
} }
func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool { func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool {
return mod.InRecovery() return mod.Properties.RecoveryVariantNeeded
} }
func (mod *Module) ExtraImageVariations(android.BaseModuleContext) []string { func (mod *Module) ExtraImageVariations(android.BaseModuleContext) []string {
@@ -144,8 +140,7 @@ func (ctx *moduleContext) ProductSpecific() bool {
} }
func (mod *Module) InRecovery() bool { func (mod *Module) InRecovery() bool {
// TODO(b/165791368) return mod.ModuleBase.InRecovery() || mod.ModuleBase.InstallInRecovery()
return false
} }
func (mod *Module) InVendorRamdisk() bool { func (mod *Module) InVendorRamdisk() bool {
@@ -166,6 +161,11 @@ func (mod *Module) OnlyInVendorRamdisk() bool {
return false return false
} }
func (mod *Module) OnlyInProduct() bool {
//TODO(b/165791368)
return false
}
// Returns true when this module is configured to have core and vendor variants. // Returns true when this module is configured to have core and vendor variants.
func (mod *Module) HasVendorVariant() bool { func (mod *Module) HasVendorVariant() bool {
return Bool(mod.VendorProperties.Vendor_available) || Bool(mod.VendorProperties.Odm_available) return Bool(mod.VendorProperties.Vendor_available) || Bool(mod.VendorProperties.Odm_available)
@@ -181,7 +181,7 @@ func (mod *Module) HasNonSystemVariants() bool {
} }
func (mod *Module) InProduct() bool { func (mod *Module) InProduct() bool {
return false return mod.Properties.ImageVariationPrefix == cc.ProductVariationPrefix
} }
// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor // Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
@@ -193,6 +193,8 @@ func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant stri
m := module.(*Module) m := module.(*Module)
if variant == android.VendorRamdiskVariation { if variant == android.VendorRamdiskVariation {
m.MakeAsPlatform() m.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
} else if strings.HasPrefix(variant, cc.VendorVariationPrefix) { } else if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
m.Properties.ImageVariationPrefix = cc.VendorVariationPrefix m.Properties.ImageVariationPrefix = cc.VendorVariationPrefix
m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix) m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
@@ -204,6 +206,9 @@ func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant stri
m.Properties.HideFromMake = true m.Properties.HideFromMake = true
m.HideFromMake() m.HideFromMake()
} }
} else if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
m.Properties.ImageVariationPrefix = cc.ProductVariationPrefix
m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
} }
} }
@@ -211,10 +216,7 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
// Rust does not support installing to the product image yet. // Rust does not support installing to the product image yet.
vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific() vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
if Bool(mod.VendorProperties.Product_available) { if mctx.ProductSpecific() {
mctx.PropertyErrorf("product_available",
"Rust modules do not yet support being available to the product image")
} else if mctx.ProductSpecific() {
mctx.PropertyErrorf("product_specific", mctx.PropertyErrorf("product_specific",
"Rust modules do not yet support installing to the product image.") "Rust modules do not yet support installing to the product image.")
} else if Bool(mod.VendorProperties.Double_loadable) { } else if Bool(mod.VendorProperties.Double_loadable) {

View File

@@ -84,6 +84,8 @@ type BaseProperties struct {
// Set by imageMutator // Set by imageMutator
CoreVariantNeeded bool `blueprint:"mutated"` CoreVariantNeeded bool `blueprint:"mutated"`
VendorRamdiskVariantNeeded bool `blueprint:"mutated"` VendorRamdiskVariantNeeded bool `blueprint:"mutated"`
RamdiskVariantNeeded bool `blueprint:"mutated"`
RecoveryVariantNeeded bool `blueprint:"mutated"`
ExtraVariants []string `blueprint:"mutated"` ExtraVariants []string `blueprint:"mutated"`
// Allows this module to use non-APEX version of libraries. Useful // Allows this module to use non-APEX version of libraries. Useful
@@ -94,11 +96,18 @@ type BaseProperties struct {
SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotSharedLibs []string `blueprint:"mutated"`
SnapshotStaticLibs []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. // Make this module available when building for vendor ramdisk.
// On device without a dedicated recovery partition, the module is only // On device without a dedicated recovery partition, the module is only
// available after switching root into // available after switching root into
// /first_stage_ramdisk. To expose the module before switching root, install // /first_stage_ramdisk. To expose the module before switching root, install
// the recovery variant instead (TODO(b/165791368) recovery not yet supported) // the recovery variant instead
Vendor_ramdisk_available *bool Vendor_ramdisk_available *bool
// Normally Soong uses the directory structure to decide which modules // Normally Soong uses the directory structure to decide which modules
@@ -115,6 +124,9 @@ type BaseProperties struct {
// framework module from the recovery snapshot. // framework module from the recovery snapshot.
Exclude_from_recovery_snapshot *bool Exclude_from_recovery_snapshot *bool
// Make this module available when building for recovery
Recovery_available *bool
// Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX). // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX).
Min_sdk_version *string Min_sdk_version *string
@@ -762,6 +774,10 @@ func (ctx *baseModuleContext) toolchain() config.Toolchain {
} }
func (mod *Module) nativeCoverage() bool { func (mod *Module) nativeCoverage() bool {
// Bug: http://b/137883967 - native-bridge modules do not currently work with coverage
if mod.Target().NativeBridge == android.NativeBridgeEnabled {
return false
}
return mod.compiler != nil && mod.compiler.nativeCoverage() return mod.compiler != nil && mod.compiler.nativeCoverage()
} }
@@ -804,9 +820,21 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// Differentiate static libraries that are vendor available // Differentiate static libraries that are vendor available
if mod.UseVndk() { if mod.UseVndk() {
mod.Properties.SubName += cc.VendorSuffix if mod.InProduct() && !mod.OnlyInProduct() {
mod.Properties.SubName += cc.ProductSuffix
} else {
mod.Properties.SubName += cc.VendorSuffix
}
} else if mod.InRamdisk() && !mod.OnlyInRamdisk() {
mod.Properties.SubName += cc.RamdiskSuffix
} else if mod.InVendorRamdisk() && !mod.OnlyInVendorRamdisk() { } else if mod.InVendorRamdisk() && !mod.OnlyInVendorRamdisk() {
mod.Properties.SubName += cc.VendorRamdiskSuffix mod.Properties.SubName += cc.VendorRamdiskSuffix
} else if mod.InRecovery() && !mod.OnlyInRecovery() {
mod.Properties.SubName += cc.RecoverySuffix
}
if mod.Target().NativeBridge == android.NativeBridgeEnabled {
mod.Properties.SubName += cc.NativeBridgeSuffix
} }
if !toolchain.Supported() { if !toolchain.Supported() {