From fac114b9a502395ba3adacf2a47b604d386c5e5e Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 14 Nov 2018 21:22:00 -0800 Subject: [PATCH 1/3] Remove legacy NDK code. Test: make checkbuild Bug: None Change-Id: Ib25e851b5ac25e918c5e20d79348c6d705bddeb2 --- cc/compiler.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cc/compiler.go b/cc/compiler.go index 5ac5d7959..ad1fc6d93 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -299,6 +299,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps } if ctx.useSdk() { + // TODO: Switch to --sysroot. // The NDK headers are installed to a common sysroot. While a more // typical Soong approach would be to only make the headers for the // library you're using available, we're trying to emulate the NDK @@ -307,6 +308,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps "-isystem "+getCurrentIncludePath(ctx).String(), "-isystem "+getCurrentIncludePath(ctx).Join(ctx, config.NDKTriple(tc)).String()) + // TODO: Migrate to API suffixed triple? // 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. @@ -316,14 +318,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps } flags.GlobalFlags = append(flags.GlobalFlags, "-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 - // headers. - legacyIncludes := fmt.Sprintf( - "prebuilts/ndk/current/platforms/android-%s/arch-%s/usr/include", - ctx.sdkVersion(), ctx.Arch().ArchType.String()) - flags.SystemIncludeFlags = append(flags.SystemIncludeFlags, "-isystem "+legacyIncludes) } if ctx.useVndk() { From a3b83662b8b51b90d642a992f90689ed96a645c2 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 15 Nov 2018 11:28:28 -0800 Subject: [PATCH 2/3] Up the NDK's minimum supported API level. r18 doesn't support ICS. Test: m checkbuild Bug: http://b/119587551 Change-Id: I39ffa21c428bcdd7e970476bedc7d6dffb7b3c43 --- android/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/config.go b/android/config.go index 0171cc069..c737b7092 100644 --- a/android/config.go +++ b/android/config.go @@ -482,7 +482,7 @@ func (c *config) PlatformSdkCodename() string { } func (c *config) MinSupportedSdkVersion() int { - return 14 + return 16 } func (c *config) DefaultAppTargetSdkInt() int { From 90b9bbc5dc024a5fff4119527149b5cc0b4ecf99 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 15 Nov 2018 11:29:28 -0800 Subject: [PATCH 3/3] Don't use libandroid_support post-21. Test: m checkbuild Bug: http://b/119587551 Change-Id: I7ee1cdc7c0119dbec0e57522b9b494aeb3c16a43 --- cc/stl.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cc/stl.go b/cc/stl.go index 8eee6124d..9dc8107e5 100644 --- a/cc/stl.go +++ b/cc/stl.go @@ -17,6 +17,7 @@ package cc import ( "android/soong/android" "fmt" + "strconv" ) func getNdkStlFamily(m *Module) string { @@ -110,6 +111,26 @@ func (stl *stl) begin(ctx BaseModuleContext) { }() } +func needsLibAndroidSupport(ctx BaseModuleContext) bool { + versionStr, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch()) + if err != nil { + ctx.PropertyErrorf("sdk_version", err.Error()) + } + + if versionStr == "current" { + return false + } + + version, err := strconv.Atoi(versionStr) + if err != nil { + panic(fmt.Sprintf( + "invalid API level returned from normalizeNdkApiLevel: %q", + versionStr)) + } + + return version < 21 +} + func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps { switch stl.Properties.SelectedStl { case "libstdc++": @@ -141,7 +162,9 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps { } else { deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl, "ndk_libc++abi") } - deps.StaticLibs = append(deps.StaticLibs, "ndk_libandroid_support") + if needsLibAndroidSupport(ctx) { + deps.StaticLibs = append(deps.StaticLibs, "ndk_libandroid_support") + } if ctx.Arch().ArchType == android.Arm { deps.StaticLibs = append(deps.StaticLibs, "ndk_libunwind") }