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
This commit is contained in:
Dan Albert 2016-11-08 15:06:22 -08:00
parent 90f7a4dcab
commit ebedf678de
3 changed files with 28 additions and 7 deletions

View file

@ -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
}
}
}

View file

@ -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

View file

@ -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...)