Support `sdk_version: "current"` for the NDK.

We need to fall back to the old CRT objects since we aren't generating
those yet.

Test: Created a test module using "current", checked that it linked
      the libs from current.
Bug: None

Change-Id: I5fe170d7b26154da8877672ac2acb7da0262fe38
diff --git a/cc/binary.go b/cc/binary.go
index b029439..c16dae6 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -101,15 +101,24 @@
 				}
 				deps.CrtEnd = "crtend_android"
 			} else {
+				// TODO(danalbert): Add generation of crt objects.
+				// For `sdk_version: "current"`, we don't actually have a
+				// freshly generated set of CRT objects. Use the last stable
+				// version.
+				version := ctx.sdkVersion()
+				if version == "current" {
+					version = ctx.AConfig().PlatformSdkVersion()
+				}
+
 				if binary.static() {
-					deps.CrtBegin = "ndk_crtbegin_static." + ctx.sdkVersion()
+					deps.CrtBegin = "ndk_crtbegin_static." + version
 				} else {
 					if binary.static() {
-						deps.CrtBegin = "ndk_crtbegin_static." + ctx.sdkVersion()
+						deps.CrtBegin = "ndk_crtbegin_static." + version
 					} else {
-						deps.CrtBegin = "ndk_crtbegin_dynamic." + ctx.sdkVersion()
+						deps.CrtBegin = "ndk_crtbegin_dynamic." + version
 					}
-					deps.CrtEnd = "ndk_crtend_android." + ctx.sdkVersion()
+					deps.CrtEnd = "ndk_crtend_android." + version
 				}
 			}
 		}
diff --git a/cc/compiler.go b/cc/compiler.go
index c1040dd..1798f4e 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -183,8 +183,12 @@
 		// Traditionally this has come from android/api-level.h, but with the
 		// libc headers unified it must be set by the build system since we
 		// don't have per-API level copies of that header now.
+		version := ctx.sdkVersion()
+		if version == "current" {
+			version = "__ANDROID_API_FUTURE__"
+		}
 		flags.GlobalFlags = append(flags.GlobalFlags,
-			"-D__ANDROID_API__="+ctx.sdkVersion())
+			"-D__ANDROID_API__="+version)
 
 		// Until the full NDK has been migrated to using ndk_headers, we still
 		// need to add the legacy sysroot includes to get the full set of
diff --git a/cc/library.go b/cc/library.go
index 5fb522a..dff38c8 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -335,8 +335,16 @@
 				deps.CrtBegin = "crtbegin_so"
 				deps.CrtEnd = "crtend_so"
 			} else {
-				deps.CrtBegin = "ndk_crtbegin_so." + ctx.sdkVersion()
-				deps.CrtEnd = "ndk_crtend_so." + ctx.sdkVersion()
+				// TODO(danalbert): Add generation of crt objects.
+				// For `sdk_version: "current"`, we don't actually have a
+				// freshly generated set of CRT objects. Use the last stable
+				// version.
+				version := ctx.sdkVersion()
+				if version == "current" {
+					version = ctx.AConfig().PlatformSdkVersion()
+				}
+				deps.CrtBegin = "ndk_crtbegin_so." + version
+				deps.CrtEnd = "ndk_crtend_so." + version
 			}
 		}
 		deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.Properties.Shared.Whole_static_libs...)