Fix ndk and stl compiling
Move ndk linking against libc and libm out of system shared libraries
so that static libraries that link against the ndk can depend on
libc and libm, which is required to get the ndk sysroot include path.
Also make ndk stl versions only apply to the device variant of
multi-target builds.
Change-Id: I6926541da17b9baf3aa7f811a839c3b65c5d804d
diff --git a/cc/cc.go b/cc/cc.go
index d400df0..e9a183e 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -691,28 +691,15 @@
func (c *ccLinked) systemSharedLibs(ctx common.AndroidBaseContext) []string {
if ctx.ContainsProperty("system_shared_libs") {
return c.properties.System_shared_libs
+ } else if ctx.Device() && c.properties.Sdk_version == "" {
+ return []string{"libc", "libm"}
} else {
- if ctx.Host() {
- return []string{}
- } else if c.properties.Sdk_version != "" {
- version := c.properties.Sdk_version
- libs := []string{
- "ndk_libc." + version,
- "ndk_libm." + version,
- }
-
- if c.properties.Sdk_version != "" && c.stl(ctx) == "ndk_system" {
- libs = append([]string{"libstdc++"}, libs...)
- }
- return libs
- } else {
- return []string{"libc", "libm"}
- }
+ return nil
}
}
func (c *ccLinked) stl(ctx common.AndroidBaseContext) string {
- if c.properties.Sdk_version != "" {
+ if c.properties.Sdk_version != "" && ctx.Device() {
switch c.properties.Stl {
case "":
return "ndk_system"
@@ -823,6 +810,7 @@
// TODO: Make a system STL prebuilt for the NDK.
// The system STL doesn't have a prebuilt (it uses the system's libstdc++), but it does have
// its own includes. The includes are handled in ccBase.Flags().
+ depNames.SharedLibs = append([]string{"libstdc++"}, depNames.SharedLibs...)
case "ndk_libc++_shared", "ndk_libstlport_shared":
depNames.SharedLibs = append(depNames.SharedLibs, stl)
case "ndk_libc++_static", "ndk_libstlport_static", "ndk_libgnustl_static":
@@ -841,6 +829,14 @@
if c.shared() {
depNames.SharedLibs = append(depNames.SharedLibs, c.systemSharedLibs(ctx)...)
}
+
+ if c.properties.Sdk_version != "" {
+ version := c.properties.Sdk_version
+ depNames.SharedLibs = append(depNames.SharedLibs,
+ "ndk_libc."+version,
+ "ndk_libm."+version,
+ )
+ }
}
return depNames