Support linking against NDK prebuilt libraries

When sdk_version is specified, we need to use the prebuilt ndk versions
of these libraries instead of the platform versions.

Change-Id: I4ff33a234a985041ebe11ab148d64d0f8df66fc4
This commit is contained in:
Dan Willemsen 2016-07-07 21:40:39 -07:00
parent 6886183d8f
commit 97704edd5d
2 changed files with 39 additions and 3 deletions

View File

@ -115,6 +115,26 @@ var (
illegalFlags = []string{
"-w",
}
ndkPrebuiltSharedLibs = []string{
"android",
"c",
"dl",
"EGL",
"GLESv1_CM",
"GLESv2",
"GLESv3",
"jnigraphics",
"log",
"mediandk",
"m",
"OpenMAXAL",
"OpenSLES",
"stdc++",
"vulkan",
"z",
}
ndkPrebuiltSharedLibraries = addPrefix(append([]string(nil), ndkPrebuiltSharedLibs...), "lib")
)
func init() {
@ -800,6 +820,22 @@ func (c *Module) deps(ctx BaseModuleContext) Deps {
deps.SharedLibs = lastUniqueElements(deps.SharedLibs)
deps.LateSharedLibs = lastUniqueElements(deps.LateSharedLibs)
if ctx.sdk() {
version := "." + ctx.sdkVersion()
rewriteNdkLibs := func(list []string) []string {
for i, entry := range list {
if inList(entry, ndkPrebuiltSharedLibraries) {
list[i] = "ndk_" + entry + version
}
}
return list
}
deps.SharedLibs = rewriteNdkLibs(deps.SharedLibs)
deps.LateSharedLibs = rewriteNdkLibs(deps.LateSharedLibs)
}
for _, lib := range deps.ReexportSharedLibHeaders {
if !inList(lib, deps.SharedLibs) {
ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
@ -1320,10 +1356,9 @@ func (linker *baseLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
}
if ctx.sdk() {
version := ctx.sdkVersion()
deps.SharedLibs = append(deps.SharedLibs,
"ndk_libc."+version,
"ndk_libm."+version,
"libc",
"libm",
)
}
}

View File

@ -40,6 +40,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${clangExtraNoOverrideCflags}")
ctx.Strict("GLOBAL_CPPFLAGS_NO_OVERRIDE", "")
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
hostTargets := ctx.Config().Targets[android.Host]
makeVarsToolchain(ctx, "", hostTargets[0])