Remove VNDK related code from Soong

As VNDK definition is fully removed from Android.bp, VNDK related code
can be removed from Soong. This change removes VNDK related code except
VNDK prebuilt which is required to build former versions of VNDK APEX
with prebuilts.

Bug: 330100430
Test: AOSP CF build succeeded
Ignore-AOSP-First: Resolve Conflict
Change-Id: Id9c8993343221c8464c97296bde0ff40b14b9b0b
diff --git a/cc/image.go b/cc/image.go
index f8c5ca5..08335ba 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -17,8 +17,6 @@
 // functions to determine where a module is installed, etc.
 
 import (
-	"fmt"
-	"reflect"
 	"strings"
 
 	"android/soong/android"
@@ -157,52 +155,6 @@
 	return c.ModuleBase.InstallInRecovery()
 }
 
-func visitPropsAndCompareVendorAndProductProps(v reflect.Value) bool {
-	if v.Kind() != reflect.Struct {
-		return true
-	}
-	for i := 0; i < v.NumField(); i++ {
-		prop := v.Field(i)
-		if prop.Kind() == reflect.Struct && v.Type().Field(i).Name == "Target" {
-			vendor_prop := prop.FieldByName("Vendor")
-			product_prop := prop.FieldByName("Product")
-			if vendor_prop.Kind() != reflect.Struct && product_prop.Kind() != reflect.Struct {
-				// Neither Target.Vendor nor Target.Product is defined
-				continue
-			}
-			if vendor_prop.Kind() != reflect.Struct || product_prop.Kind() != reflect.Struct ||
-				!reflect.DeepEqual(vendor_prop.Interface(), product_prop.Interface()) {
-				// If only one of either Target.Vendor or Target.Product is
-				// defined or they have different values, it fails the build
-				// since VNDK must have the same properties for both vendor
-				// and product variants.
-				return false
-			}
-		} else if !visitPropsAndCompareVendorAndProductProps(prop) {
-			// Visit the substructures to find Target.Vendor and Target.Product
-			return false
-		}
-	}
-	return true
-}
-
-// In the case of VNDK, vendor and product variants must have the same properties.
-// VNDK installs only one file and shares it for both vendor and product modules on
-// runtime. We may not define different versions of a VNDK lib for each partition.
-// This function is used only for the VNDK modules that is available to both vendor
-// and product partitions.
-func (c *Module) compareVendorAndProductProps() bool {
-	if !c.IsVndk() && !Bool(c.VendorProperties.Product_available) {
-		panic(fmt.Errorf("This is only for product available VNDK libs. %q is not a VNDK library or not product available", c.Name()))
-	}
-	for _, properties := range c.GetProperties() {
-		if !visitPropsAndCompareVendorAndProductProps(reflect.ValueOf(properties).Elem()) {
-			return false
-		}
-	}
-	return true
-}
-
 // ImageMutatableModule provides a common image mutation interface for  LinkableInterface modules.
 type ImageMutatableModule interface {
 	android.Module
@@ -260,62 +212,9 @@
 var _ ImageMutatableModule = (*Module)(nil)
 
 func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
-	m.CheckVndkProperties(mctx)
 	MutateImage(mctx, m)
 }
 
-// CheckVndkProperties checks whether the VNDK-related properties are set correctly.
-// If properties are not set correctly, results in a module context property error.
-func (m *Module) CheckVndkProperties(mctx android.BaseModuleContext) {
-	vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
-	productSpecific := mctx.ProductSpecific()
-
-	if vndkdep := m.vndkdep; vndkdep != nil {
-		if vndkdep.isVndk() {
-			if vendorSpecific || productSpecific {
-				if !vndkdep.isVndkExt() {
-					mctx.PropertyErrorf("vndk",
-						"must set `extends: \"...\"` to vndk extension")
-				} else if Bool(m.VendorProperties.Vendor_available) {
-					mctx.PropertyErrorf("vendor_available",
-						"must not set at the same time as `vndk: {extends: \"...\"}`")
-				} else if Bool(m.VendorProperties.Product_available) {
-					mctx.PropertyErrorf("product_available",
-						"must not set at the same time as `vndk: {extends: \"...\"}`")
-				}
-			} else {
-				if vndkdep.isVndkExt() {
-					mctx.PropertyErrorf("vndk",
-						"must set `vendor: true` or `product_specific: true` to set `extends: %q`",
-						m.getVndkExtendsModuleName())
-				}
-				if !Bool(m.VendorProperties.Vendor_available) {
-					mctx.PropertyErrorf("vndk",
-						"vendor_available must be set to true when `vndk: {enabled: true}`")
-				}
-				if Bool(m.VendorProperties.Product_available) {
-					// If a VNDK module creates both product and vendor variants, they
-					// must have the same properties since they share a single VNDK
-					// library on runtime.
-					if !m.compareVendorAndProductProps() {
-						mctx.ModuleErrorf("product properties must have the same values with the vendor properties for VNDK modules")
-					}
-				}
-			}
-		} else {
-			if vndkdep.isVndkSp() {
-				mctx.PropertyErrorf("vndk",
-					"must set `enabled: true` to set `support_system_process: true`")
-			}
-			if vndkdep.isVndkExt() {
-				mctx.PropertyErrorf("vndk",
-					"must set `enabled: true` to set `extends: %q`",
-					m.getVndkExtendsModuleName())
-			}
-		}
-	}
-}
-
 func (m *Module) VendorAvailable() bool {
 	return Bool(m.VendorProperties.Vendor_available)
 }
@@ -456,7 +355,7 @@
 		} else {
 			vendorVariants = append(vendorVariants, m.SnapshotVersion(mctx))
 		}
-	} else if m.HasNonSystemVariants() && !m.IsVndkExt() {
+	} else if m.HasNonSystemVariants() {
 		// This will be available to /system unless it is product_specific
 		// which will be handled later.
 		coreVariantNeeded = true