Merge "Generate product variants by default" into main

This commit is contained in:
Justin Yun
2023-10-04 06:29:31 +00:00
committed by Gerrit Code Review
11 changed files with 32 additions and 235 deletions

View File

@@ -1895,8 +1895,7 @@ func getNameSuffixWithVndkVersion(ctx android.ModuleContext, c LinkableInterface
// do not add a name suffix because it is a base module.
return ""
}
vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
nameSuffix = ProductSuffix
return ProductSuffix
} else {
vndkVersion = ctx.DeviceConfig().VndkVersion()
nameSuffix = VendorSuffix

View File

@@ -41,7 +41,6 @@ var prepareForCcTest = android.GroupFixturePreparers(
PrepareForTestWithCcIncludeVndk,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.DeviceVndkVersion = StringPtr("current")
variables.ProductVndkVersion = StringPtr("current")
variables.Platform_vndk_version = StringPtr("29")
}),
)
@@ -104,33 +103,6 @@ func testCc(t *testing.T, bp string) *android.TestContext {
return result.TestContext
}
// testCcNoVndk runs tests using the prepareForCcTest
//
// See testCc for an explanation as to how to stop using this deprecated method.
//
// deprecated
func testCcNoVndk(t *testing.T, bp string) *android.TestContext {
t.Helper()
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
return testCcWithConfig(t, config)
}
// testCcNoProductVndk runs tests using the prepareForCcTest
//
// See testCc for an explanation as to how to stop using this deprecated method.
//
// deprecated
func testCcNoProductVndk(t *testing.T, bp string) *android.TestContext {
t.Helper()
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
return testCcWithConfig(t, config)
}
// testCcErrorWithConfig runs tests using the prepareForCcTest
//
// See testCc for an explanation as to how to stop using this deprecated method.
@@ -167,7 +139,6 @@ func testCcErrorProductVndk(t *testing.T, pattern string, bp string) {
t.Helper()
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
testCcErrorWithConfig(t, pattern, config)
return
@@ -523,7 +494,6 @@ func TestVndk(t *testing.T) {
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
ctx := testCcWithConfig(t, config)
@@ -889,63 +859,6 @@ func TestTestLibraryTestSuites(t *testing.T) {
}
}
func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
t.Parallel()
ctx := testCcNoVndk(t, `
cc_library {
name: "libvndk",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
},
nocrt: true,
}
cc_library {
name: "libvndk-private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
nocrt: true,
}
cc_library {
name: "libllndk",
llndk: {
symbol_file: "libllndk.map.txt",
export_llndk_headers: ["libllndk_headers"],
}
}
cc_library_headers {
name: "libllndk_headers",
llndk: {
symbol_file: "libllndk.map.txt",
},
export_include_dirs: ["include"],
}
`)
checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
"LLNDK: libc.so",
"LLNDK: libdl.so",
"LLNDK: libft2.so",
"LLNDK: libllndk.so",
"LLNDK: libm.so",
"VNDK-SP: libc++.so",
"VNDK-core: libvndk-private.so",
"VNDK-core: libvndk.so",
"VNDK-private: libft2.so",
"VNDK-private: libvndk-private.so",
"VNDK-product: libc++.so",
"VNDK-product: libvndk-private.so",
"VNDK-product: libvndk.so",
})
}
func TestVndkModuleError(t *testing.T) {
t.Parallel()
// Check the error message for vendor_available and product_available properties.
@@ -1111,6 +1024,7 @@ func TestVndkDepError(t *testing.T) {
cc_library {
name: "libnonvndk",
vendor_available: true,
product_available: true,
nocrt: true,
}
`)
@@ -1132,6 +1046,7 @@ func TestVndkDepError(t *testing.T) {
cc_library {
name: "libnonvndk",
vendor_available: true,
product_available: true,
nocrt: true,
}
`)
@@ -1153,6 +1068,7 @@ func TestVndkDepError(t *testing.T) {
cc_library {
name: "libnonvndk",
vendor_available: true,
product_available: true,
nocrt: true,
}
`)
@@ -1175,6 +1091,7 @@ func TestVndkDepError(t *testing.T) {
cc_library {
name: "libnonvndk",
vendor_available: true,
product_available: true,
nocrt: true,
}
`)
@@ -1390,6 +1307,7 @@ func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) {
cc_library {
name: "libanothervndksp",
vendor_available: true,
product_available: true,
}
`)
}
@@ -1467,7 +1385,6 @@ func TestVndkExt(t *testing.T) {
`
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
ctx := testCcWithConfig(t, config)
@@ -1482,70 +1399,6 @@ func TestVndkExt(t *testing.T) {
assertString(t, mod_product.outputFile.Path().Base(), "libvndk2-suffix.so")
}
func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {
t.Parallel()
// This test checks the VNDK-Ext properties when BOARD_VNDK_VERSION is not set.
ctx := testCcNoVndk(t, `
cc_library {
name: "libvndk",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
},
nocrt: true,
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
nocrt: true,
}
`)
// Ensures that the core variant of "libvndk_ext" can be found.
mod := ctx.ModuleForTests("libvndk_ext", coreVariant).Module().(*Module)
if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" {
t.Errorf("\"libvndk_ext\" must extend from \"libvndk\" but get %q", extends)
}
}
func TestVndkExtWithoutProductVndkVersion(t *testing.T) {
t.Parallel()
// This test checks the VNDK-Ext properties when PRODUCT_PRODUCT_VNDK_VERSION is not set.
ctx := testCcNoProductVndk(t, `
cc_library {
name: "libvndk",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
},
nocrt: true,
}
cc_library {
name: "libvndk_ext_product",
product_specific: true,
vndk: {
enabled: true,
extends: "libvndk",
},
nocrt: true,
}
`)
// Ensures that the core variant of "libvndk_ext_product" can be found.
mod := ctx.ModuleForTests("libvndk_ext_product", coreVariant).Module().(*Module)
if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" {
t.Errorf("\"libvndk_ext_product\" must extend from \"libvndk\" but get %q", extends)
}
}
func TestVndkExtError(t *testing.T) {
t.Parallel()
// This test ensures an error is emitted in ill-formed vndk-ext definition.
@@ -1920,7 +1773,6 @@ func TestProductVndkExtDependency(t *testing.T) {
`
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
testCcWithConfig(t, config)
@@ -3034,24 +2886,6 @@ func TestExcludeRuntimeLibs(t *testing.T) {
checkRuntimeLibs(t, nil, module)
}
func TestRuntimeLibsNoVndk(t *testing.T) {
t.Parallel()
ctx := testCcNoVndk(t, runtimeLibAndroidBp)
// If DeviceVndkVersion is not defined, then runtime_libs are copied as-is.
variant := "android_arm64_armv8-a_shared"
module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"liball_available"}, module)
module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"liball_available", "libvendor1", "libproduct_vendor"}, module)
module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"liball_available", "libproduct1", "libproduct_vendor"}, module)
}
func checkStaticLibs(t *testing.T, expected []string, module *Module) {
t.Helper()
actual := module.Properties.AndroidMkStaticLibs

View File

@@ -84,7 +84,7 @@ func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext
return true
}
if ctx.DeviceConfig().ProductVndkVersion() != "" && ctx.ProductSpecific() {
if ctx.ProductSpecific() {
return false
}
@@ -134,15 +134,8 @@ func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleCont
}
}
if ctx.DeviceConfig().ProductVndkVersion() == "" {
return variants
}
if Bool(g.Product_available) || ctx.ProductSpecific() {
variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
if vndkVersion := ctx.DeviceConfig().ProductVndkVersion(); vndkVersion != "current" {
variants = append(variants, ProductVariationPrefix+vndkVersion)
}
}
return variants

View File

@@ -427,7 +427,6 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
boardVndkVersion := mctx.DeviceConfig().VndkVersion()
productVndkVersion := mctx.DeviceConfig().ProductVndkVersion()
recoverySnapshotVersion := mctx.DeviceConfig().RecoverySnapshotVersion()
usingRecoverySnapshot := recoverySnapshotVersion != "current" &&
recoverySnapshotVersion != ""
@@ -444,9 +443,6 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
if boardVndkVersion == "current" {
boardVndkVersion = platformVndkVersion
}
if productVndkVersion == "current" {
productVndkVersion = platformVndkVersion
}
if m.NeedsLlndkVariants() {
// This is an LLNDK library. The implementation of the library will be on /system,
@@ -462,9 +458,6 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
if needVndkVersionVendorVariantForLlndk {
vendorVariants = append(vendorVariants, boardVndkVersion)
}
if productVndkVersion != "" {
productVariants = append(productVariants, productVndkVersion)
}
} else if m.NeedsVendorPublicLibraryVariants() {
// A vendor public library has the implementation on /vendor, with stub variants
// for system and product.
@@ -473,9 +466,6 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
if platformVndkVersion != "" {
productVariants = append(productVariants, platformVndkVersion)
}
if productVndkVersion != "" {
productVariants = append(productVariants, productVndkVersion)
}
} else if boardVndkVersion == "" {
// If the device isn't compiling against the VNDK, we always
// use the core mode.
@@ -507,10 +497,6 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
// product_available modules are available to /product.
if m.HasProductVariant() {
productVariants = append(productVariants, platformVndkVersion)
// VNDK is always PLATFORM_VNDK_VERSION
if !m.IsVndk() {
productVariants = append(productVariants, productVndkVersion)
}
}
} else if vendorSpecific && m.SdkVersion() == "" {
// This will be available in /vendor (or /odm) only
@@ -538,17 +524,10 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
coreVariantNeeded = true
}
if boardVndkVersion != "" && productVndkVersion != "" {
if coreVariantNeeded && productSpecific && m.SdkVersion() == "" {
// The module has "product_specific: true" that does not create core variant.
coreVariantNeeded = false
productVariants = append(productVariants, productVndkVersion)
}
} else {
// Unless PRODUCT_PRODUCT_VNDK_VERSION is set, product partition has no
// restriction to use system libs.
// No product variants defined in this case.
productVariants = []string{}
if coreVariantNeeded && productSpecific && m.SdkVersion() == "" {
// The module has "product_specific: true" that does not create core variant.
coreVariantNeeded = false
productVariants = append(productVariants, platformVndkVersion)
}
if m.RamdiskAvailable() {