Merge "Split usage of UseVndk" into main

This commit is contained in:
Kiyoung Kim
2024-01-10 01:15:45 +00:00
committed by Gerrit Code Review
16 changed files with 45 additions and 25 deletions

View File

@@ -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. //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 return false
} }
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs) af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)

View File

@@ -16,6 +16,7 @@ package cc
import ( import (
"android/soong/aconfig" "android/soong/aconfig"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
"fmt" "fmt"
@@ -51,6 +52,7 @@ type AndroidMkContext interface {
InVendorRamdisk() bool InVendorRamdisk() bool
InRecovery() bool InRecovery() bool
NotInPlatform() bool NotInPlatform() bool
InVendorOrProduct() bool
} }
type subAndroidMkProvider interface { 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 // they can be exceptionally used directly when APEXes are not available (e.g. during the
// very early stage in the boot process). // very early stage in the boot process).
if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() && 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() { if library.buildStubs() && library.isLatestStubVersion() {
entries.SubName = "" entries.SubName = ""
} }

View File

@@ -525,6 +525,7 @@ type ModuleContextIntf interface {
inRamdisk() bool inRamdisk() bool
inVendorRamdisk() bool inVendorRamdisk() bool
inRecovery() bool inRecovery() bool
InVendorOrProduct() bool
selectedStl() string selectedStl() string
baseModuleName() string baseModuleName() string
getVndkExtendsModuleName() string getVndkExtendsModuleName() string
@@ -1285,7 +1286,7 @@ func (c *Module) UseVndk() bool {
func (c *Module) canUseSdk() bool { func (c *Module) canUseSdk() bool {
return c.Os() == android.Android && c.Target().NativeBridge == android.NativeBridgeDisabled && 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 { func (c *Module) UseSdk() bool {
@@ -1667,6 +1668,10 @@ func (ctx *moduleContextImpl) useVndk() bool {
return ctx.mod.UseVndk() return ctx.mod.UseVndk()
} }
func (ctx *moduleContextImpl) InVendorOrProduct() bool {
return ctx.mod.InVendorOrProduct()
}
func (ctx *moduleContextImpl) isNdk(config android.Config) bool { func (ctx *moduleContextImpl) isNdk(config android.Config) bool {
return ctx.mod.IsNdk(config) return ctx.mod.IsNdk(config)
} }
@@ -1896,7 +1901,7 @@ func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string
} }
llndk := c.IsLlndk() 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 // .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 // 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. // 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 // is explicitly referenced via .bootstrap suffix or the module is marked with
// 'bootstrap: true'). // 'bootstrap: true').
if c.HasStubsVariants() && c.NotInPlatform() && !c.InRamdisk() && 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.IsStubs() && !c.InVendorRamdisk() {
c.Properties.HideFromMake = false // unhide c.Properties.HideFromMake = false // unhide
// Note: this is still non-installable // 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())) panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName()))
} }
useVndk := false inVendorOrProduct := false
bootstrap := false bootstrap := false
if linkable, ok := ctx.Module().(LinkableInterface); !ok { if linkable, ok := ctx.Module().(LinkableInterface); !ok {
panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName())) panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName()))
} else { } else {
useVndk = linkable.UseVndk() inVendorOrProduct = linkable.InVendorOrProduct()
bootstrap = linkable.Bootstrap() bootstrap = linkable.Bootstrap()
} }
@@ -3447,7 +3452,7 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
useStubs := false useStubs := false
if lib := moduleLibraryInterface(dep); lib.buildStubs() && useVndk { // LLNDK if lib := moduleLibraryInterface(dep); lib.buildStubs() && inVendorOrProduct { // LLNDK
if !apexInfo.IsForPlatform() { if !apexInfo.IsForPlatform() {
// For platform libraries, use current version of LLNDK // For platform libraries, use current version of LLNDK
// If this is for use_vendor apex we will apply the same rules // 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 // The vendor module is a no-vendor-variant VNDK library. Depend on the
// core module instead. // core module instead.
return libName 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 // 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. // core module, so update the dependency name here accordingly.
return libName + ccDep.SubName() return libName + ccDep.SubName()

View File

@@ -385,7 +385,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+modulePath) 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, flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
"${config.CommonGlobalIncludes}", "${config.CommonGlobalIncludes}",
tc.IncludeFlags()) tc.IncludeFlags())
@@ -402,7 +402,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
"-isystem "+getCurrentIncludePath(ctx).Join(ctx, config.NDKTriple(tc)).String()) "-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__") flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__")
if ctx.inVendor() { if ctx.inVendor() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__") flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__")

View File

@@ -128,6 +128,12 @@ func (c *Module) InVendor() bool {
return c.Properties.ImageVariation == VendorVariation 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 { func (c *Module) InRamdisk() bool {
return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk() return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
} }

View File

@@ -87,7 +87,7 @@ func (installer *baseInstaller) installDir(ctx ModuleContext) android.InstallPat
} else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) { } else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
dir = filepath.Join(dir, ctx.Arch().ArchType.String()) dir = filepath.Join(dir, ctx.Arch().ArchType.String())
} }
if installer.location == InstallInData && ctx.useVndk() { if installer.location == InstallInData && ctx.InVendorOrProduct() {
if ctx.inProduct() { if ctx.inProduct() {
dir = filepath.Join(dir, "product") dir = filepath.Join(dir, "product")
} else { } else {

View File

@@ -24,6 +24,7 @@ import (
"sync" "sync"
"android/soong/android" "android/soong/android"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/pathtools" "github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
@@ -1777,7 +1778,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
} }
if Bool(library.Properties.Static_ndk_lib) && library.static() && 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() && library.baseLinker.sanitize.isUnsanitizedVariant() &&
ctx.isForPlatform() && !ctx.isPreventInstall() { ctx.isForPlatform() && !ctx.isPreventInstall() {
installPath := getUnversionedLibraryInstallPath(ctx).Join(ctx, file.Base()) installPath := getUnversionedLibraryInstallPath(ctx).Join(ctx, file.Base())
@@ -1897,7 +1898,7 @@ func (library *libraryDecorator) stubsVersions(ctx android.BaseMutatorContext) [
return nil return nil
} }
if library.hasLLNDKStubs() && ctx.Module().(*Module).UseVndk() { if library.hasLLNDKStubs() && ctx.Module().(*Module).InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant. // LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()} return []string{android.FutureApiLevel.String()}
} }

View File

@@ -48,7 +48,7 @@ func updateImportedLibraryDependency(ctx android.BottomUpMutatorContext) {
return return
} }
if m.UseVndk() && apiLibrary.hasLLNDKStubs() { if m.InVendorOrProduct() && apiLibrary.hasLLNDKStubs() {
// Add LLNDK variant dependency // Add LLNDK variant dependency
if inList("llndk", apiLibrary.properties.Variants) { if inList("llndk", apiLibrary.properties.Variants) {
variantName := BuildApiVariantName(m.BaseModuleName(), "llndk", "") variantName := BuildApiVariantName(m.BaseModuleName(), "llndk", "")
@@ -193,7 +193,7 @@ func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps
} }
} }
if m.UseVndk() && d.hasLLNDKStubs() { if m.InVendorOrProduct() && d.hasLLNDKStubs() {
// LLNDK variant // LLNDK variant
load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "llndk", "")) load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "llndk", ""))
} else if m.IsSdkVariant() { } else if m.IsSdkVariant() {
@@ -312,7 +312,7 @@ func (d *apiLibraryDecorator) stubsVersions(ctx android.BaseMutatorContext) []st
} }
} }
if d.hasLLNDKStubs() && m.UseVndk() { if d.hasLLNDKStubs() && m.InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant. // LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()} return []string{android.FutureApiLevel.String()}
} }

View File

@@ -218,6 +218,7 @@ type LinkableInterface interface {
ProductSpecific() bool ProductSpecific() bool
InProduct() bool InProduct() bool
SdkAndPlatformVariantVisibleToMake() bool SdkAndPlatformVariantVisibleToMake() bool
InVendorOrProduct() bool
// SubName returns the modules SubName, used for image and NDK/SDK variations. // SubName returns the modules SubName, used for image and NDK/SDK variations.
SubName() string SubName() string

View File

@@ -430,8 +430,7 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
} }
}) })
useVendor := ctx.inVendor() || ctx.useVndk() testInstallBase := getTestInstallBase(ctx.InVendorOrProduct())
testInstallBase := getTestInstallBase(useVendor)
configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device()) configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device())
test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{ test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{

View File

@@ -571,6 +571,7 @@ var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
android.MockFS{ android.MockFS{
"defaults/cc/common/libc.map.txt": nil, "defaults/cc/common/libc.map.txt": nil,
"defaults/cc/common/libdl.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/libm.map.txt": nil,
"defaults/cc/common/ndk_libc++_shared": nil, "defaults/cc/common/ndk_libc++_shared": nil,
"defaults/cc/common/crtbegin_so.c": nil, "defaults/cc/common/crtbegin_so.c": nil,

View File

@@ -418,11 +418,11 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
lib, isLib := m.linker.(*libraryDecorator) lib, isLib := m.linker.(*libraryDecorator)
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker) prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
if m.UseVndk() && isLib && lib.hasLLNDKStubs() { if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() {
m.VendorProperties.IsLLNDK = true m.VendorProperties.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private) 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.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private) m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private)
} }

View File

@@ -170,7 +170,7 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
cflags = append(cflags, strings.ReplaceAll(ccToolchain.Cflags(), "${config.", "${cc_config.")) cflags = append(cflags, strings.ReplaceAll(ccToolchain.Cflags(), "${config.", "${cc_config."))
cflags = append(cflags, strings.ReplaceAll(ccToolchain.ToolchainCflags(), "${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__") cflags = append(cflags, "-D__ANDROID_VNDK__")
if ctx.RustModule().InVendor() { if ctx.RustModule().InVendor() {
cflags = append(cflags, "-D__ANDROID_VENDOR__") cflags = append(cflags, "-D__ANDROID_VENDOR__")

View File

@@ -332,7 +332,7 @@ func (compiler *baseCompiler) featureFlags(ctx ModuleContext, flags Flags) Flags
} }
func (compiler *baseCompiler) cfgFlags(ctx ModuleContext, flags Flags) Flags { 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") compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vndk")
if ctx.RustModule().InVendor() { if ctx.RustModule().InVendor() {
compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vendor") compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vendor")
@@ -520,7 +520,7 @@ func (compiler *baseCompiler) installDir(ctx ModuleContext) android.InstallPath
dir = filepath.Join(dir, ctx.Arch().ArchType.String()) 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() { if ctx.RustModule().InProduct() {
dir = filepath.Join(dir, "product") dir = filepath.Join(dir, "product")
} else if ctx.RustModule().InVendor() { } else if ctx.RustModule().InVendor() {

View File

@@ -192,6 +192,11 @@ func (mod *Module) InVendor() bool {
return mod.Properties.ImageVariation == cc.VendorVariation 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) { func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module) m := module.(*Module)
if variant == android.VendorRamdiskVariation { if variant == android.VendorRamdiskVariation {

View File

@@ -117,7 +117,7 @@ func (test *testDecorator) compilerProps() []interface{} {
func (test *testDecorator) install(ctx ModuleContext) { func (test *testDecorator) install(ctx ModuleContext) {
testInstallBase := "/data/local/tests/unrestricted" testInstallBase := "/data/local/tests/unrestricted"
if ctx.RustModule().InVendor() || ctx.RustModule().UseVndk() { if ctx.RustModule().InVendorOrProduct() {
testInstallBase = "/data/local/tests/vendor" testInstallBase = "/data/local/tests/vendor"
} }