Android: Add support for NDK r18

NDK r18 drops GCC toolchains and some STL types.  We need to choose a
clang toolchain by default when no gcc toolchains are available.  Switch
the STL type default to `c++_static` when the old `gnustl_static`
default is not available.

Update the test suite to not run tests for STL types that do not exist.
Also do not expect the gcc toolchain `cpp` tool to be available because
r18 does not provide it.  Also teach it to tolerate `gcc -dumpmachine`
output like `arm--linux-android` that differs from the toolchain prefix.

Fixes: #18301
This commit is contained in:
Brad King
2018-08-27 15:28:53 -04:00
parent c4ab098097
commit ca97d4cb5f
5 changed files with 29 additions and 9 deletions
+3 -1
View File
@@ -32,8 +32,10 @@ if(CMAKE_ANDROID_NDK)
)
endif()
unset(_ANDROID_STL_TYPE_FOUND)
else()
elseif(IS_DIRECTORY ${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++)
set(CMAKE_ANDROID_STL_TYPE "gnustl_static")
else()
set(CMAKE_ANDROID_STL_TYPE "c++_static")
endif()
unset(_ANDROID_STL_TYPES)
@@ -35,7 +35,18 @@ elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION)
endif()
set(_ANDROID_TOOL_PATTERNS "*-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}")
else()
set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]")
# If we can find any gcc toolchains then use one by default.
# Otherwise we look for clang toolchains (e.g. NDK r18+).
file(GLOB _ANDROID_CONFIG_MKS_FOR_GCC
"${CMAKE_ANDROID_NDK}/build/core/toolchains/*-[0-9].[0-9]/config.mk"
"${CMAKE_ANDROID_NDK}/toolchains/*-[0-9].[0-9]/config.mk"
)
if(_ANDROID_CONFIG_MKS_FOR_GCC)
set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]")
else()
set(_ANDROID_TOOL_PATTERNS "*-clang")
endif()
unset(_ANDROID_CONFIG_MKS_FOR_GCC)
endif()
set(_ANDROID_CONFIG_MK_PATTERNS)
foreach(base "build/core/toolchains" "toolchains")