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
diff --git a/cc/genrule.go b/cc/genrule.go
index 0c06ae6..0fb3e2d 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -79,15 +79,7 @@
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) 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