Rework vndk detection

Instead of having a module define `use_vndk: true`, assume that we're
building with the VNDK if we're installed on the vendor partition, and
BOARD_VNDK_VERSION==current. This now matches our behavior in Make.

Once BOARD_VNDK_VERSION!=current, we'll need to disable modules that
need to otherwise compile against the VNDK, since we can only compile
against the current VNDK.

Test: build.ninja for aosp_arm is the same before/after
Test: Ensure there are no boards that set BOARD_VNDK_VERSION
Change-Id: If937fa7bdb119648137af52daebadf486163484b
diff --git a/cc/cc.go b/cc/cc.go
index b27e8ee..84afa73 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -135,9 +135,6 @@
 	// Minimum sdk version supported when compiling against the ndk
 	Sdk_version string
 
-	// Whether to compile against the VNDK
-	Use_vndk bool
-
 	// don't insert default compiler flags into asflags, cflags,
 	// cppflags, conlyflags, ldflags, or include_dirs
 	No_default_compiler_flags *bool
@@ -145,7 +142,6 @@
 	AndroidMkSharedLibs []string `blueprint:"mutated"`
 	HideFromMake        bool     `blueprint:"mutated"`
 	PreventInstall      bool     `blueprint:"mutated"`
-	Vndk_version        string   `blueprint:"mutated"`
 }
 
 type UnusedProperties struct {
@@ -378,8 +374,8 @@
 
 func (ctx *moduleContextImpl) sdkVersion() string {
 	if ctx.ctx.Device() {
-		if ctx.mod.Properties.Use_vndk {
-			return ctx.mod.Properties.Vndk_version
+		if ctx.vndk() {
+			return "current"
 		} else {
 			return ctx.mod.Properties.Sdk_version
 		}
@@ -388,10 +384,7 @@
 }
 
 func (ctx *moduleContextImpl) vndk() bool {
-	if ctx.ctx.Device() {
-		return ctx.mod.Properties.Use_vndk
-	}
-	return false
+	return ctx.ctx.Os() == android.Android && ctx.ctx.Proprietary() && ctx.ctx.DeviceConfig().CompileVndk()
 }
 
 func (ctx *moduleContextImpl) selectedStl() string {
@@ -544,22 +537,11 @@
 		feature.begin(ctx)
 	}
 	if ctx.sdk() {
-		if ctx.vndk() {
-			ctx.PropertyErrorf("use_vndk",
-				"sdk_version and use_vndk cannot be used at the same time")
-		}
-
 		version, err := normalizeNdkApiLevel(ctx.sdkVersion(), ctx.Arch())
 		if err != nil {
 			ctx.PropertyErrorf("sdk_version", err.Error())
 		}
 		c.Properties.Sdk_version = version
-	} else if ctx.vndk() {
-		version, err := normalizeNdkApiLevel(ctx.DeviceConfig().VndkVersion(), ctx.Arch())
-		if err != nil {
-			ctx.ModuleErrorf("Bad BOARD_VNDK_VERSION: %s", err.Error())
-		}
-		c.Properties.Vndk_version = version
 	}
 }