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
diff --git a/apex/apex.go b/apex/apex.go
index 42a7d73..b7ba5b6 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2146,7 +2146,7 @@
}
//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)
diff --git a/cc/androidmk.go b/cc/androidmk.go
index bde096b..786d2bc 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -16,6 +16,7 @@
import (
"android/soong/aconfig"
+
"github.com/google/blueprint/proptools"
"fmt"
@@ -51,6 +52,7 @@
InVendorRamdisk() bool
InRecovery() bool
NotInPlatform() bool
+ InVendorOrProduct() bool
}
type subAndroidMkProvider interface {
@@ -294,7 +296,7 @@
// 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 = ""
}
diff --git a/cc/cc.go b/cc/cc.go
index c6e21c2..d34daec 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -525,6 +525,7 @@
inRamdisk() bool
inVendorRamdisk() bool
inRecovery() bool
+ InVendorOrProduct() bool
selectedStl() string
baseModuleName() string
getVndkExtendsModuleName() string
@@ -1285,7 +1286,7 @@
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 @@
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 @@
}
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 @@
// 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 @@
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 @@
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 @@
// 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()
diff --git a/cc/compiler.go b/cc/compiler.go
index c9de1b0..d7c4d4f 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -385,7 +385,7 @@
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 @@
"-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__")
diff --git a/cc/image.go b/cc/image.go
index 9eec255..d02a2f3 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -128,6 +128,12 @@
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()
}
diff --git a/cc/installer.go b/cc/installer.go
index a0b6295..30f9612 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -87,7 +87,7 @@
} else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
}
- if installer.location == InstallInData && ctx.useVndk() {
+ if installer.location == InstallInData && ctx.InVendorOrProduct() {
if ctx.inProduct() {
dir = filepath.Join(dir, "product")
} else {
diff --git a/cc/library.go b/cc/library.go
index 592f70f..c4f1251 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -24,6 +24,7 @@
"sync"
"android/soong/android"
+
"github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools"
@@ -1777,7 +1778,7 @@
}
if Bool(library.Properties.Static_ndk_lib) && library.static() &&
- !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && ctx.Device() &&
+ !ctx.InVendorOrProduct() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && ctx.Device() &&
library.baseLinker.sanitize.isUnsanitizedVariant() &&
ctx.isForPlatform() && !ctx.isPreventInstall() {
installPath := getUnversionedLibraryInstallPath(ctx).Join(ctx, file.Base())
@@ -1897,7 +1898,7 @@
return nil
}
- if library.hasLLNDKStubs() && ctx.Module().(*Module).UseVndk() {
+ if library.hasLLNDKStubs() && ctx.Module().(*Module).InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()}
}
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 1183b29..aab6664 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -48,7 +48,7 @@
return
}
- if m.UseVndk() && apiLibrary.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && apiLibrary.hasLLNDKStubs() {
// Add LLNDK variant dependency
if inList("llndk", apiLibrary.properties.Variants) {
variantName := BuildApiVariantName(m.BaseModuleName(), "llndk", "")
@@ -193,7 +193,7 @@
}
}
- if m.UseVndk() && d.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && d.hasLLNDKStubs() {
// LLNDK variant
load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "llndk", ""))
} else if m.IsSdkVariant() {
@@ -312,7 +312,7 @@
}
}
- if d.hasLLNDKStubs() && m.UseVndk() {
+ if d.hasLLNDKStubs() && m.InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()}
}
diff --git a/cc/linkable.go b/cc/linkable.go
index a009c6c..6f22091 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -218,6 +218,7 @@
ProductSpecific() bool
InProduct() bool
SdkAndPlatformVariantVisibleToMake() bool
+ InVendorOrProduct() bool
// SubName returns the modules SubName, used for image and NDK/SDK variations.
SubName() string
diff --git a/cc/test.go b/cc/test.go
index 347d7c9..3a1a3af 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -430,8 +430,7 @@
}
})
- useVendor := ctx.inVendor() || ctx.useVndk()
- testInstallBase := getTestInstallBase(useVendor)
+ testInstallBase := getTestInstallBase(ctx.InVendorOrProduct())
configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device())
test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
diff --git a/cc/testing.go b/cc/testing.go
index b1583f1..bac41e7 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -571,6 +571,7 @@
android.MockFS{
"defaults/cc/common/libc.map.txt": nil,
"defaults/cc/common/libdl.map.txt": nil,
+ "defaults/cc/common/libft2.map.txt": nil,
"defaults/cc/common/libm.map.txt": nil,
"defaults/cc/common/ndk_libc++_shared": nil,
"defaults/cc/common/crtbegin_so.c": nil,
diff --git a/cc/vndk.go b/cc/vndk.go
index b2c6e0d..0e0dba9 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -418,11 +418,11 @@
lib, isLib := m.linker.(*libraryDecorator)
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
- if m.UseVndk() && isLib && lib.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() {
m.VendorProperties.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private)
}
- if m.UseVndk() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
m.VendorProperties.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private)
}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 1cc1574..77ba277 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -170,7 +170,7 @@
cflags = append(cflags, strings.ReplaceAll(ccToolchain.Cflags(), "${config.", "${cc_config."))
cflags = append(cflags, strings.ReplaceAll(ccToolchain.ToolchainCflags(), "${config.", "${cc_config."))
- if ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
cflags = append(cflags, "-D__ANDROID_VNDK__")
if ctx.RustModule().InVendor() {
cflags = append(cflags, "-D__ANDROID_VENDOR__")
diff --git a/rust/compiler.go b/rust/compiler.go
index a8c5473..c1bdbeb 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -332,7 +332,7 @@
}
func (compiler *baseCompiler) cfgFlags(ctx ModuleContext, flags Flags) Flags {
- if ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vndk")
if ctx.RustModule().InVendor() {
compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vendor")
@@ -520,7 +520,7 @@
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
}
- if compiler.location == InstallInData && ctx.RustModule().UseVndk() {
+ if compiler.location == InstallInData && ctx.RustModule().InVendorOrProduct() {
if ctx.RustModule().InProduct() {
dir = filepath.Join(dir, "product")
} else if ctx.RustModule().InVendor() {
diff --git a/rust/image.go b/rust/image.go
index 7adf234..530c56e 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -192,6 +192,11 @@
return mod.Properties.ImageVariation == cc.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)
if variant == android.VendorRamdiskVariation {
diff --git a/rust/test.go b/rust/test.go
index 6619af6..2583893 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -117,7 +117,7 @@
func (test *testDecorator) install(ctx ModuleContext) {
testInstallBase := "/data/local/tests/unrestricted"
- if ctx.RustModule().InVendor() || ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
testInstallBase = "/data/local/tests/vendor"
}