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

Commit aa39480d authored by Kiyoung Kim's avatar Kiyoung Kim
Browse files

Split usage of UseVndk

UseVndk is a function to check if the module can use VNDK libraries, but
this function was also used to check if the module is installed in the
treblelized partition (vendor or product). As of VNDK deprecation,
UseVndk funtion will return false even when the module is installed in
vendor / product partition, so we need a separated function to check
this. This change introduces a new function 'InVendorOrProduct' which
replaces UseVndk based on its usage.

Bug: 316829758
Test: m nothing --no-skip-soong-tests passed
Change-Id: Ic61fcd16c4554c355f6005894a4519b044b27fe5
parent 208444ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2146,7 +2146,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
			}

			//TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
			if ch.UseVndk() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
			if ch.InVendorOrProduct() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
				return false
			}
			af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package cc

import (
	"android/soong/aconfig"

	"github.com/google/blueprint/proptools"

	"fmt"
@@ -51,6 +52,7 @@ type AndroidMkContext interface {
	InVendorRamdisk() bool
	InRecovery() bool
	NotInPlatform() bool
	InVendorOrProduct() bool
}

type subAndroidMkProvider interface {
@@ -294,7 +296,7 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
	// they can be exceptionally used directly when APEXes are not available (e.g. during the
	// very early stage in the boot process).
	if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() &&
		!ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() {
		!ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.InVendorOrProduct() && !ctx.static() {
		if library.buildStubs() && library.isLatestStubVersion() {
			entries.SubName = ""
		}
+12 −7
Original line number Diff line number Diff line
@@ -525,6 +525,7 @@ type ModuleContextIntf interface {
	inRamdisk() bool
	inVendorRamdisk() bool
	inRecovery() bool
	InVendorOrProduct() bool
	selectedStl() string
	baseModuleName() string
	getVndkExtendsModuleName() string
@@ -1285,7 +1286,7 @@ func (c *Module) UseVndk() bool {

func (c *Module) canUseSdk() bool {
	return c.Os() == android.Android && c.Target().NativeBridge == android.NativeBridgeDisabled &&
		!c.UseVndk() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
		!c.InVendorOrProduct() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
}

func (c *Module) UseSdk() bool {
@@ -1667,6 +1668,10 @@ func (ctx *moduleContextImpl) useVndk() bool {
	return ctx.mod.UseVndk()
}

func (ctx *moduleContextImpl) InVendorOrProduct() bool {
	return ctx.mod.InVendorOrProduct()
}

func (ctx *moduleContextImpl) isNdk(config android.Config) bool {
	return ctx.mod.IsNdk(config)
}
@@ -1896,7 +1901,7 @@ func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string
	}

	llndk := c.IsLlndk()
	if llndk || (c.UseVndk() && c.HasNonSystemVariants()) {
	if llndk || (c.InVendorOrProduct() && c.HasNonSystemVariants()) {
		// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
		// added for product variant only when we have vendor and product variants with core
		// variant. The suffix is not added for vendor-only or product-only module.
@@ -2192,7 +2197,7 @@ func (c *Module) maybeUnhideFromMake() {
	// is explicitly referenced via .bootstrap suffix or the module is marked with
	// 'bootstrap: true').
	if c.HasStubsVariants() && c.NotInPlatform() && !c.InRamdisk() &&
		!c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
		!c.InRecovery() && !c.InVendorOrProduct() && !c.static() && !c.isCoverageVariant() &&
		c.IsStubs() && !c.InVendorRamdisk() {
		c.Properties.HideFromMake = false // unhide
		// Note: this is still non-installable
@@ -3434,12 +3439,12 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
		panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName()))
	}

	useVndk := false
	inVendorOrProduct := false
	bootstrap := false
	if linkable, ok := ctx.Module().(LinkableInterface); !ok {
		panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName()))
	} else {
		useVndk = linkable.UseVndk()
		inVendorOrProduct = linkable.InVendorOrProduct()
		bootstrap = linkable.Bootstrap()
	}

@@ -3447,7 +3452,7 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {

	useStubs := false

	if lib := moduleLibraryInterface(dep); lib.buildStubs() && useVndk { // LLNDK
	if lib := moduleLibraryInterface(dep); lib.buildStubs() && inVendorOrProduct { // LLNDK
		if !apexInfo.IsForPlatform() {
			// For platform libraries, use current version of LLNDK
			// If this is for use_vendor apex we will apply the same rules
@@ -3599,7 +3604,7 @@ func MakeLibName(ctx android.ModuleContext, c LinkableInterface, ccDep LinkableI
		// The vendor module is a no-vendor-variant VNDK library.  Depend on the
		// core module instead.
		return libName
	} else if ccDep.UseVndk() && nonSystemVariantsExist {
	} else if ccDep.InVendorOrProduct() && nonSystemVariantsExist {
		// The vendor and product modules in Make will have been renamed to not conflict with the
		// core module, so update the dependency name here accordingly.
		return libName + ccDep.SubName()
+2 −2
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
		flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+modulePath)
	}

	if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
	if !(ctx.useSdk() || ctx.InVendorOrProduct()) || ctx.Host() {
		flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
			"${config.CommonGlobalIncludes}",
			tc.IncludeFlags())
@@ -402,7 +402,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
			"-isystem "+getCurrentIncludePath(ctx).Join(ctx, config.NDKTriple(tc)).String())
	}

	if ctx.useVndk() {
	if ctx.InVendorOrProduct() {
		flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__")
		if ctx.inVendor() {
			flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__")
+6 −0
Original line number Diff line number Diff line
@@ -128,6 +128,12 @@ func (c *Module) InVendor() bool {
	return c.Properties.ImageVariation == VendorVariation
}

// Returns true if the module is "vendor" or "product" variant. This replaces previous UseVndk usages
// which were misused to check if the module variant is vendor or product.
func (c *Module) InVendorOrProduct() bool {
	return c.InVendor() || c.InProduct()
}

func (c *Module) InRamdisk() bool {
	return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
}
Loading