Merge "Generate VNDK independent image variant with cc genrule" into main am: 395c47f635
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2902107 Change-Id: Iaf17a0a2f0ff3cd6634c0a47b5e13235ac2ebb4e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -79,15 +79,7 @@ var _ android.ImageInterface = (*GenruleExtraProperties)(nil)
|
||||
func (g *GenruleExtraProperties) ImageMutatorBegin(ctx android.BaseModuleContext) {}
|
||||
|
||||
func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
|
||||
if ctx.DeviceConfig().VndkVersion() == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
if ctx.ProductSpecific() {
|
||||
return false
|
||||
}
|
||||
|
||||
return !(ctx.SocSpecific() || ctx.DeviceSpecific())
|
||||
return !(ctx.SocSpecific() || ctx.DeviceSpecific() || ctx.ProductSpecific())
|
||||
}
|
||||
|
||||
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
|
||||
@@ -115,26 +107,33 @@ func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleCon
|
||||
}
|
||||
|
||||
func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
|
||||
if ctx.DeviceConfig().VndkVersion() == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
var variants []string
|
||||
if Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific() {
|
||||
vndkVersion := ctx.DeviceConfig().VndkVersion()
|
||||
// If vndkVersion is current, we can always use PlatformVndkVersion.
|
||||
// If not, we assume modules under proprietary paths are compatible for
|
||||
// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
|
||||
// PLATFORM_VNDK_VERSION.
|
||||
if vndkVersion == "current" || !snapshot.IsVendorProprietaryModule(ctx) {
|
||||
variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
|
||||
} else {
|
||||
variants = append(variants, VendorVariationPrefix+vndkVersion)
|
||||
}
|
||||
}
|
||||
vndkVersion := ctx.DeviceConfig().VndkVersion()
|
||||
vendorVariantRequired := Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific()
|
||||
productVariantRequired := Bool(g.Product_available) || ctx.ProductSpecific()
|
||||
|
||||
if Bool(g.Product_available) || ctx.ProductSpecific() {
|
||||
variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
|
||||
if vndkVersion == "" {
|
||||
if vendorVariantRequired {
|
||||
variants = append(variants, VendorVariation)
|
||||
}
|
||||
if productVariantRequired {
|
||||
variants = append(variants, ProductVariation)
|
||||
}
|
||||
} else {
|
||||
if vendorVariantRequired {
|
||||
// If vndkVersion is current, we can always use PlatformVndkVersion.
|
||||
// If not, we assume modules under proprietary paths are compatible for
|
||||
// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
|
||||
// PLATFORM_VNDK_VERSION.
|
||||
if vndkVersion == "current" || !snapshot.IsVendorProprietaryModule(ctx) {
|
||||
variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
|
||||
} else {
|
||||
variants = append(variants, VendorVariationPrefix+vndkVersion)
|
||||
}
|
||||
}
|
||||
if productVariantRequired {
|
||||
variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
|
||||
}
|
||||
}
|
||||
|
||||
return variants
|
||||
|
@@ -16,6 +16,7 @@ package cc
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
@@ -186,3 +187,26 @@ func TestCmdPrefix(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestVendorProductVariantGenrule(t *testing.T) {
|
||||
bp := `
|
||||
cc_genrule {
|
||||
name: "gen",
|
||||
tool_files: ["tool"],
|
||||
cmd: "$(location tool) $(in) $(out)",
|
||||
out: ["out"],
|
||||
vendor_available: true,
|
||||
product_available: true,
|
||||
}
|
||||
`
|
||||
t.Helper()
|
||||
ctx := PrepareForTestWithCcIncludeVndk.RunTestWithBp(t, bp)
|
||||
|
||||
variants := ctx.ModuleVariantsForTests("gen")
|
||||
if !slices.Contains(variants, "android_vendor_arm64_armv8-a") {
|
||||
t.Errorf(`expected vendor variant, but does not exist in %v`, variants)
|
||||
}
|
||||
if !slices.Contains(variants, "android_product_arm64_armv8-a") {
|
||||
t.Errorf(`expected product variant, but does not exist in %v`, variants)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user