Generate VNDK independent image variant with cc genrule
Image variants for CC modules were covered to work without VNDK version from previous commit, but CC genrule has its own image variant rule, so it should be also updated to generate vendor / product image variant without VNDK version. Bug: 316829758 Test: m nothing --no-skip-soong-tests passed Test: AOSP cuttlefish build succeeded Change-Id: I425dd425efcc57c7ff8f9964b303ad6f539c3b57
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