diff options
Diffstat (limited to 'rust/image.go')
| -rw-r--r-- | rust/image.go | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/rust/image.go b/rust/image.go index 50bf02a4a..26929b1ac 100644 --- a/rust/image.go +++ b/rust/image.go @@ -77,6 +77,14 @@ func (mod *Module) SetCoreVariantNeeded(b bool) { mod.Properties.CoreVariantNeeded = b } +func (mod *Module) SetProductVariantNeeded(b bool) { + mod.Properties.ProductVariantNeeded = b +} + +func (mod *Module) SetVendorVariantNeeded(b bool) { + mod.Properties.VendorVariantNeeded = b +} + func (mod *Module) SnapshotVersion(mctx android.BaseModuleContext) string { if snapshot, ok := mod.compiler.(cc.SnapshotInterface); ok { return snapshot.Version() @@ -86,6 +94,14 @@ func (mod *Module) SnapshotVersion(mctx android.BaseModuleContext) string { } } +func (mod *Module) VendorVariantNeeded(ctx android.BaseModuleContext) bool { + return mod.Properties.VendorVariantNeeded +} + +func (mod *Module) ProductVariantNeeded(ctx android.BaseModuleContext) bool { + return mod.Properties.ProductVariantNeeded +} + func (mod *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { return mod.Properties.VendorRamdiskVariantNeeded } @@ -117,20 +133,16 @@ func (mod *Module) IsSnapshotPrebuilt() bool { return false } -func (ctx *moduleContext) SocSpecific() bool { +func (mod *Module) InstallInVendor() bool { // Additionally check if this module is inVendor() that means it is a "vendor" variant of a // module. As well as SoC specific modules, vendor variants must be installed to /vendor // unless they have "odm_available: true". - return ctx.ModuleContext.SocSpecific() || (ctx.RustModule().InVendor() && !ctx.RustModule().VendorVariantToOdm()) + return mod.InVendor() && !mod.VendorVariantToOdm() } -func (ctx *moduleContext) DeviceSpecific() bool { +func (mod *Module) InstallInOdm() bool { // Some vendor variants want to be installed to /odm by setting "odm_available: true". - return ctx.ModuleContext.DeviceSpecific() || (ctx.RustModule().InVendor() && ctx.RustModule().VendorVariantToOdm()) -} - -func (ctx *moduleContext) SystemExtSpecific() bool { - return ctx.ModuleContext.SystemExtSpecific() + return mod.InVendor() && mod.VendorVariantToOdm() } // Returns true when this module creates a vendor variant and wants to install the vendor variant @@ -188,41 +200,38 @@ func (mod *Module) HasNonSystemVariants() bool { } func (mod *Module) InProduct() bool { - return mod.Properties.ImageVariationPrefix == cc.ProductVariationPrefix + return mod.Properties.ImageVariation == android.ProductVariation } // Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor func (mod *Module) InVendor() bool { - return mod.Properties.ImageVariationPrefix == cc.VendorVariationPrefix + return mod.Properties.ImageVariation == android.VendorVariation +} + +// Returns true if the module is "vendor" or "product" variant. +func (mod *Module) InVendorOrProduct() bool { + return mod.InVendor() || mod.InProduct() } -func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) { - m := module.(*Module) +func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) { if variant == android.VendorRamdiskVariation { - m.MakeAsPlatform() + mod.MakeAsPlatform() } else if variant == android.RecoveryVariation { - m.MakeAsPlatform() - } else if strings.HasPrefix(variant, cc.VendorVariationPrefix) { - m.Properties.ImageVariationPrefix = cc.VendorVariationPrefix - m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix) - - // Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION. - // Hide other vendor variants to avoid collision. - vndkVersion := ctx.DeviceConfig().VndkVersion() - if vndkVersion != "current" && vndkVersion != "" && vndkVersion != m.Properties.VndkVersion { - m.Properties.HideFromMake = true - m.HideFromMake() + mod.MakeAsPlatform() + } else if strings.HasPrefix(variant, android.VendorVariation) { + mod.Properties.ImageVariation = android.VendorVariation + if strings.HasPrefix(variant, cc.VendorVariationPrefix) { + mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix) + } + } else if strings.HasPrefix(variant, android.ProductVariation) { + mod.Properties.ImageVariation = android.ProductVariation + if strings.HasPrefix(variant, cc.ProductVariationPrefix) { + mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix) } - } else if strings.HasPrefix(variant, cc.ProductVariationPrefix) { - m.Properties.ImageVariationPrefix = cc.ProductVariationPrefix - m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix) } } func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) { - // Rust does not support installing to the product image yet. - vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific() - if Bool(mod.VendorProperties.Double_loadable) { mctx.PropertyErrorf("double_loadable", "Rust modules do not yet support double loading") @@ -232,16 +241,6 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) { mctx.PropertyErrorf("vendor_ramdisk_available", "cannot be set for rust_ffi or rust_ffi_shared modules.") } } - if vendorSpecific { - if lib, ok := mod.compiler.(libraryInterface); ok && lib.buildDylib() { - mctx.PropertyErrorf("vendor", "Vendor-only dylibs are not yet supported, use rust_library_rlib.") - } - } - if mctx.ProductSpecific() { - if lib, ok := mod.compiler.(libraryInterface); ok && lib.buildDylib() { - mctx.PropertyErrorf("product", "Product-only dylibs are not yet supported, use rust_library_rlib.") - } - } cc.MutateImage(mctx, mod) |