Add __ANDROID_SDK_VERSION__=<ver> macro

sdk_version is passed for relevant variants.
If not specified or "current",
it maps to "10000" for platform variants, and
"min_sdk_version" of the apex for apex variants.

Bug: 150860940
Test: m (soong test)
      manually check build.ninja
Change-Id: I5102ab0c5086b5ad29d16ac45af55d32062167b4
diff --git a/cc/cc.go b/cc/cc.go
index 8b3c772..04d30f1 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -290,6 +290,7 @@
 	staticBinary() bool
 	header() bool
 	toolchain() config.Toolchain
+	canUseSdk() bool
 	useSdk() bool
 	sdkVersion() string
 	useVndk() bool
@@ -313,6 +314,7 @@
 	useClangLld(actx ModuleContext) bool
 	isForPlatform() bool
 	apexName() string
+	apexSdkVersion() int
 	hasStubsVariants() bool
 	isStubs() bool
 	bootstrap() bool
@@ -1045,8 +1047,12 @@
 	return ctx.mod.header()
 }
 
+func (ctx *moduleContextImpl) canUseSdk() bool {
+	return ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inRecovery() && !ctx.ctx.Fuchsia()
+}
+
 func (ctx *moduleContextImpl) useSdk() bool {
-	if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inRecovery() && !ctx.ctx.Fuchsia() {
+	if ctx.canUseSdk() {
 		return String(ctx.mod.Properties.Sdk_version) != ""
 	}
 	return false
@@ -1179,6 +1185,10 @@
 	return ctx.mod.ApexName()
 }
 
+func (ctx *moduleContextImpl) apexSdkVersion() int {
+	return ctx.mod.ApexProperties.Info.MinSdkVersion
+}
+
 func (ctx *moduleContextImpl) hasStubsVariants() bool {
 	return ctx.mod.HasStubsVariants()
 }