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

Commit 52af5b05 authored by Matthew Maurer's avatar Matthew Maurer
Browse files

Support Rust in Product

Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a product binary
Change-Id: I9c5aa5f3a1f323af9aa2aee804635045f1b91bd4
parent 460ee942
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import (

var (
	nativeBridgeSuffix  = ".native_bridge"
	productSuffix       = ".product"
	ProductSuffix       = ".product"
	VendorSuffix        = ".vendor"
	ramdiskSuffix       = ".ramdisk"
	VendorRamdiskSuffix = ".vendor_ramdisk"
+1 −1
Original line number Diff line number Diff line
@@ -1632,7 +1632,7 @@ func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string
			return ""
		}
		vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
		nameSuffix = productSuffix
		nameSuffix = ProductSuffix
	} else {
		vndkVersion = ctx.DeviceConfig().VndkVersion()
		nameSuffix = VendorSuffix
+11 −6
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ func (mod *Module) OdmAvailable() bool {
}

func (mod *Module) ProductAvailable() bool {
	return false
	return Bool(mod.VendorProperties.Product_available)
}

func (mod *Module) RamdiskAvailable() bool {
@@ -163,6 +163,11 @@ func (mod *Module) OnlyInVendorRamdisk() bool {
	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.
func (mod *Module) HasVendorVariant() bool {
	return Bool(mod.VendorProperties.Vendor_available) || Bool(mod.VendorProperties.Odm_available)
@@ -178,7 +183,7 @@ func (mod *Module) HasNonSystemVariants() 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
@@ -203,6 +208,9 @@ func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant stri
			m.Properties.HideFromMake = true
			m.HideFromMake()
		}
	} else if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
		m.Properties.ImageVariationPrefix = cc.ProductVariationPrefix
		m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
	}
}

@@ -210,10 +218,7 @@ 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.Product_available) {
		mctx.PropertyErrorf("product_available",
			"Rust modules do not yet support being available to the product image")
	} else if mctx.ProductSpecific() {
	if mctx.ProductSpecific() {
		mctx.PropertyErrorf("product_specific",
			"Rust modules do not yet support installing to the product image.")
	} else if Bool(mod.VendorProperties.Double_loadable) {
+5 −1
Original line number Diff line number Diff line
@@ -808,7 +808,11 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {

	// Differentiate static libraries that are vendor available
	if mod.UseVndk() {
		if mod.InProduct() && !mod.OnlyInProduct() {
			mod.Properties.SubName += cc.ProductSuffix
		} else {
			mod.Properties.SubName += cc.VendorSuffix
		}
	} else if mod.InVendorRamdisk() && !mod.OnlyInVendorRamdisk() {
		mod.Properties.SubName += cc.VendorRamdiskSuffix
	} else if mod.InRecovery() && !mod.OnlyInRecovery() {