diff options
author | Fred Hornsey <hornseyf@objectcomputing.com> | 2020-12-03 01:15:50 -0600 |
---|---|---|
committer | Fred Hornsey <hornseyf@objectcomputing.com> | 2020-12-03 01:44:29 -0600 |
commit | b02baa8bf80c71bdee79a9e0e94284125317de03 (patch) | |
tree | c971ec8ada8caadcd045378eead9e155de56f1a8 | |
parent | 1c2a17feff1f9cbac974a56f743b73225e3c7b54 (diff) | |
download | ATCD-b02baa8bf80c71bdee79a9e0e94284125317de03.tar.gz |
Support Using Android NDK Directly
Instead of having to use a standalone toolchain generated from the NDK.
Also:
- Make NEON the default on 32 bit arm
- Update NEWS file with all this that matters to users and the last
commit
- Remove a bunch of unneeded arguments
- Remove need to pass a macro about android/ndk-version.h unless the
NDK is old
- Add NDK Beta to NDK version macros
-rw-r--r-- | ACE/NEWS | 11 | ||||
-rw-r--r-- | ACE/ace/config-android.h | 71 | ||||
-rw-r--r-- | ACE/include/makeinclude/platform_android.GNU | 78 | ||||
-rw-r--r-- | ACE/include/makeinclude/platform_clang_common.GNU | 9 |
4 files changed, 111 insertions, 58 deletions
@@ -11,6 +11,17 @@ USER VISIBLE CHANGES BETWEEN ACE-6.5.12 and ACE-7.0.0 or you can disable dlclose yourself by adding `#define ACE_LACKS_DLCLOSE` to your ace/config.h file +. Android Support: + + . Support for building with the Android NDK directly instead of having to use + the generated standalone toolchain. See ACE-INSTALL.html for how to. + + . Made it eaiser to use gnuace built libraries in Android Studio native + projects. + + . Building with neon support is now the default when ANDROID_ABI is + armeabi-v7a. + USER VISIBLE CHANGES BETWEEN ACE-6.5.11 and ACE-6.5.12 ====================================================== diff --git a/ACE/ace/config-android.h b/ACE/ace/config-android.h index d3d89f39d5b..6c975cb942d 100644 --- a/ACE/ace/config-android.h +++ b/ACE/ace/config-android.h @@ -10,12 +10,8 @@ // There is a large number of combinations of these two that can lead to // problems. -// Location of the __ANDROID_API__ define -// #include $NDK_ROOT/sysroot/usr/include/android/api-level.h -#include "android/api-level.h" - #if !defined (__ANDROID_API__) -# error __ANDROID_API__ must be defined +# include <android/api-level.h> #endif #define ACE_ANDROID @@ -26,27 +22,35 @@ /* * Android NDK Revision Macros * - * Revsions Scheme Work Like This: - * Revision | __NDK_MAJOR__ | __NDK_MINOR__ - * r16 | 16 | 0 - * r16b | 16 | 1 - * r16c | 16 | 2 + * Revisions Scheme Work Like This: + * Revision | __NDK_MAJOR__ | __NDK_MINOR__ | __NDK__BETA__ + * r16 | 16 | 0 | 0 + * r16b | 16 | 1 | 0 + * r16c | 16 | 2 | 0 + * r22-beta1| 22 | 0 | 1 + * + * __NDK_BETA__ is starts at 1 and increments until release when it is 0. * * After r16, NDK version macros are defined in android/ndk-version.h Before * that they must be defined in platform_macros.GNU before the include of * platform_android.GNU. */ -#define ACE_ANDROID_NDK_AT_LEAST(MAJ, MIN) \ - (__NDK_MAJOR__ > (MAJ) || (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ >= (MIN))) - -#define ACE_ANDROID_NDK_EXACTLY(MAJ, MIN) \ - (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ == (MIN)) - -#define ACE_ANDROID_NDK_LESS_THAN(MAJ, MIN) \ - (__NDK_MAJOR__ < (MAJ) || (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ < (MIN))) - -#ifdef ACE_ANDROID_NDK_HAS_NDK_VERSION_H -# include "android/ndk-version.h" +#define ACE_ANDROID_NDK_AT_LEAST(MAJ, MIN, BET) (\ + (__NDK_MAJOR__ > (MAJ)) || \ + (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ >= (MIN)) || \ + (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ == (MIN) && \ + (__NDK_BETA__ == 0 || __NDK_BETA__ >= (BET)) \ + ) \ +) + +#define ACE_ANDROID_NDK_EXACTLY(MAJ, MIN, BET) \ + (__NDK_MAJOR__ == (MAJ) && __NDK_MINOR__ == (MIN) && __NDK_BETA__ == (BETA)) + +#define ACE_ANDROID_NDK_LESS_THAN(MAJ, MIN, BET) \ + !ACE_ANDROID_NDK_AT_LEAST((MAJ), (MIN), (BET)) + +#ifndef ACE_ANDROID_NDK_MISSING_NDK_VERSION_H +# include <android/ndk-version.h> #else # ifndef __NDK_MAJOR__ # error ndk-version.h is missing, __NDK_MAJOR__ for Android NDK must be defined! @@ -54,10 +58,13 @@ # ifndef __NDK_MINOR__ # error ndk-version.h is missing, __NDK_MINOR__ for Android NDK must be defined! # endif +# ifndef __NDK_BETA__ +# define __NDK_BETA__ 0 +# endif #endif // ucontext.h and clock_settime() were added in r10c -#if ACE_ANDROID_NDK_AT_LEAST(10, 2) +#if ACE_ANDROID_NDK_AT_LEAST(10, 2, 0) # define ACE_HAS_UCONTEXT_T # define ACE_HAS_CLOCK_SETTIME #else @@ -65,7 +72,7 @@ #endif // NDK has these by r12b -#if ACE_ANDROID_NDK_LESS_THAN(12, 1) +#if ACE_ANDROID_NDK_LESS_THAN(12, 1, 0) # define ACE_LACKS_GETHOSTENT # define ACE_LACKS_LOCALECONV # define ACE_LACKS_WCHAR_STD_NAMESPACE @@ -73,11 +80,11 @@ # define TAO_LACKS_WCHAR_CXX_STDLIB #endif -#if ACE_ANDROID_NDK_LESS_THAN(12, 1) || __ANDROID_API__ < 18 +#if ACE_ANDROID_NDK_LESS_THAN(12, 1, 0) || __ANDROID_API__ < 18 # define ACE_LACKS_LOG2 #endif -#if ACE_ANDROID_NDK_LESS_THAN(12, 1) || __ANDROID_API__ < 21 +#if ACE_ANDROID_NDK_LESS_THAN(12, 1, 0) || __ANDROID_API__ < 21 # define ACE_LACKS_SEARCH_H # define ACE_LACKS_SYS_SEM_H # define ACE_LACKS_SEMBUF_T @@ -88,7 +95,7 @@ # define ACE_HAS_SEMUN #endif -#if ACE_ANDROID_NDK_LESS_THAN(15, 0) && __ANDROID_API__ < 21 +#if ACE_ANDROID_NDK_LESS_THAN(15, 0, 0) && __ANDROID_API__ < 21 // NOTE: The && is correct, SYS_GETTID is present in API 16 in r15 onwards # ifdef ACE_HAS_GETTID # undef ACE_HAS_GETTID @@ -96,20 +103,20 @@ #endif // NDK has telldir() and seekdir() by 15c -#if ACE_ANDROID_NDK_LESS_THAN(15, 2) || __ANDROID_API__ < 23 +#if ACE_ANDROID_NDK_LESS_THAN(15, 2, 0) || __ANDROID_API__ < 23 # define ACE_LACKS_TELLDIR # define ACE_LACKS_SEEKDIR #endif // strbuf was added by r16 -#if ACE_ANDROID_NDK_LESS_THAN(16, 0) +#if ACE_ANDROID_NDK_LESS_THAN(16, 0, 0) # ifdef ACE_HAS_STRBUF_T # undef ACE_HAS_STRBUF_T # endif #endif // fd_mask was added in r17c -#if ACE_ANDROID_NDK_LESS_THAN(17, 2) +#if ACE_ANDROID_NDK_LESS_THAN(17, 2, 0) # define ACE_LACKS_FD_MASK #endif @@ -123,11 +130,11 @@ # endif #endif -#if ACE_ANDROID_NDK_LESS_THAN(15, 0) +#if ACE_ANDROID_NDK_LESS_THAN(15, 0, 0) # define ACE_LACKS_STRUCT_IF_NAMEINDEX #endif -#if ACE_ANDROID_NDK_LESS_THAN(15, 0) || __ANDROID_API__ < 24 +#if ACE_ANDROID_NDK_LESS_THAN(15, 0, 0) || __ANDROID_API__ < 24 # define ACE_LACKS_IF_NAMEINDEX #endif @@ -137,7 +144,7 @@ # define ACE_LACKS_ENDHOSTENT #endif -#if !defined(ACE_HAS_GLIBC_2_2_3) && (ACE_ANDROID_NDK_AT_LEAST(15, 0) || __ANDROID_API__ >= 21) +#if !defined(ACE_HAS_GLIBC_2_2_3) && (ACE_ANDROID_NDK_AT_LEAST(15, 0, 0) || __ANDROID_API__ >= 21) # define ACE_HAS_CPU_SET_T #endif diff --git a/ACE/include/makeinclude/platform_android.GNU b/ACE/include/makeinclude/platform_android.GNU index 9a2306a6c17..92b894d5118 100644 --- a/ACE/include/makeinclude/platform_android.GNU +++ b/ACE/include/makeinclude/platform_android.GNU @@ -3,6 +3,9 @@ # This file allows ACE and applications using ACE GNU Makefiles to be built for # Android by cross compiling on Linux. +# See here for latest documentation on how to invoke the NDK: +# https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md + # We always include config-android.h on Android platforms. ACE_PLATFORM_CONFIG ?= config-android.h @@ -49,48 +52,72 @@ ifeq ($(ANDROID_ABI), neon) ANDROID_ABI := armeabi-v7a-with-neon endif -android_neon ?= 0 +android_neon ?= 1 ifeq ($(ANDROID_ABI),armeabi-v7a-with-neon) ANDROID_ABI := armeabi-v7a android_neon := 1 endif -# NDK says -Wl,--fix-cortex-a8 is required for working around a CPU bug -# in some Cortex-A8 implementations - ifeq ($(ANDROID_ABI),armeabi-v7a) - CROSS_COMPILE := arm-linux-androideabi- - FLAGS_C_CC += -march=armv7-a -mfloat-abi=softfp + CROSS_COMPILE := armv7a-linux-androideabi ifeq ($(android_neon),1) FLAGS_C_CC += -mfpu=neon else FLAGS_C_CC += -mfpu=vfpv3-d16 endif - LDFLAGS += -march=armv7-a -Wl,--fix-cortex-a8 + # NDK says -Wl,--fix-cortex-a8 is required for working around a CPU bug + # in some Cortex-A8 implementations + LDFLAGS += -Wl,--fix-cortex-a8 endif ifeq ($(ANDROID_ABI),arm64-v8a) - CROSS_COMPILE := aarch64-linux-android- - FLAGS_C_CC += -march=armv8-a - LDFLAGS += -march=armv8-a + CROSS_COMPILE := aarch64-linux-android endif ifeq ($(ANDROID_ABI),x86) - CROSS_COMPILE := i686-linux-android- + CROSS_COMPILE := i686-linux-android endif ifeq ($(ANDROID_ABI),x86_64) - CROSS_COMPILE := x86_64-linux-android- + CROSS_COMPILE := x86_64-linux-android endif ifndef CROSS_COMPILE - $(error ANDROID_ABI passed (set to: $(ANDROID_ABI)) is not valid) + $(error ANDROID_ABI $(ANDROID_ABI) is not valid) endif -# Export so child processes can use tools from the same toolchain. -export CROSS_COMPILE +ifdef android_ndk + # If we are given the Android NDK path, use that instead of PATH. + ifndef android_api + $(error android_ndk also requires defining android_api) + endif + + android_ndk_tools ?= $(wildcard $(android_ndk)/toolchains/llvm/prebuilt/*/bin) + ifndef android_ndk_tool_prefix + android_ndk_tool_prefix := $(CROSS_COMPILE)$(android_api)- + endif + + # We dont want this being used again except to signal that this is a + # cross-compile build. If it is this command (probably) wont exist. + CROSS_COMPILE := fake + + override_cross_compile = 1 + CC = $(android_ndk_tools)/$(android_ndk_tool_prefix)clang + CXX = $(android_ndk_tools)/$(android_ndk_tool_prefix)clang++ + AR = $(android_ndk_tools)/llvm-ar + +else + CROSS_COMPILE := $(CROSS_COMPILE)- + + # Export so child processes can use tools from the same toolchain. + export CROSS_COMPILE +endif ifeq ($(android_force_clang),0) + ifdef android_api + $(error Must use a standalone toolchain to use GCC) + endif + # Determine if the g++ compiler is GCC or Clang. # There are at least 3 assumptions being made here: # - There is a g++ command to get the version from @@ -98,17 +125,18 @@ ifeq ($(android_force_clang),0) # - If g++ is actually clang, then we can replace that with clang++ gplusplus_version = $(shell $(CROSS_COMPILE)g++$(CROSS_COMPILE_SUFFIX) --version) actually_is_clang := $(strip $(findstring clang,$(gplusplus_version))) +else ifeq ($(android_force_clang),1) + actually_is_clang := 1 else - ifeq ($(android_force_clang),1) - actually_is_clang := 1 - else - $(error Invalid value for android_force_clang: $(android_force_clang)) - endif + $(error Invalid value for android_force_clang: $(android_force_clang)) endif FLAGS_C_CC += -W -Wall -Wpointer-arith ifeq ($(threads),1) - CPPFLAGS += -D_REENTRANT $(PLATFORM_AIO_SUPPORT) + CPPFLAGS += -D_REENTRANT + ifdef PLATFORM_AIO_SUPPORT + CPPFLAGS += $(PLATFORM_AIO_SUPPORT) + endif endif # threads # Use -pipes by default @@ -154,8 +182,8 @@ else include $(ACE_ROOT)/include/makeinclude/platform_g++_common.GNU endif -ifeq ($(shell echo '\#include "android/ndk-version.h"' | $(CXX) -E - > /dev/null 2>&1; echo $$?), 0) - CPPFLAGS += -DACE_ANDROID_NDK_HAS_NDK_VERSION_H +ifneq ($(shell echo '\#include <android/ndk-version.h>' | $(CXX) -E - > /dev/null 2>&1; echo $$?), 0) + CPPFLAGS += -DACE_ANDROID_NDK_MISSING_NDK_VERSION_H endif ifdef __NDK_MAJOR__ @@ -166,6 +194,10 @@ ifdef __NDK_MINOR__ CPPFLAGS += -D__NDK_MINOR__=$(__NDK_MINOR__) endif +ifdef __NDK_BETA__ + CPPFLAGS += -D__NDK_BETA__=$(__NDK_BETA__) +endif + OCFLAGS ?= -O3 OCCFLAGS ?= -O3 diff --git a/ACE/include/makeinclude/platform_clang_common.GNU b/ACE/include/makeinclude/platform_clang_common.GNU index efcc8121413..075ac65fbf8 100644 --- a/ACE/include/makeinclude/platform_clang_common.GNU +++ b/ACE/include/makeinclude/platform_clang_common.GNU @@ -6,9 +6,12 @@ CCFLAGS += -fdelayed-template-parsing ifneq ($(CROSS_COMPILE),) CROSS-COMPILE = 1 # Build using the cross-tools - CC = ${CROSS_COMPILE}clang${CROSS_COMPILE_SUFFIX} - CXX = ${CROSS_COMPILE}clang++${CROSS_COMPILE_SUFFIX} - AR = ${CROSS_COMPILE}ar${CROSS_COMPILE_SUFFIX} + override_cross_compile ?= 0 + ifeq ($(override_cross_compile),0) + CC = ${CROSS_COMPILE}clang${CROSS_COMPILE_SUFFIX} + CXX = ${CROSS_COMPILE}clang++${CROSS_COMPILE_SUFFIX} + AR = ${CROSS_COMPILE}ar${CROSS_COMPILE_SUFFIX} + endif # Cross-linker requires this for linked in shared libs that depend # themselves on other shared libs (not directly linked in) LDFLAGS += -Wl,-rpath-link,$(ACE_ROOT)/lib |