From ebedf678de4a013590c29bfb97bd445c12e7b010 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 8 Nov 2016 15:06:22 -0800 Subject: [PATCH] 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 --- cc/binary.go | 17 +++++++++++++---- cc/compiler.go | 6 +++++- cc/library.go | 12 ++++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/cc/binary.go b/cc/binary.go index b02943947..c16dae601 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -101,15 +101,24 @@ func (binary *binaryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps } 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 c1040dd0c..1798f4eba 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -183,8 +183,12 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag // 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 5fb522a56..dff38c84c 100644 --- a/cc/library.go +++ b/cc/library.go @@ -335,8 +335,16 @@ func (library *libraryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) De 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...)