Skip to content

Commit

Permalink
Merge pull request #3241 from GuangweiWang/fix-android-ub-build-issue
Browse files Browse the repository at this point in the history
fix ut build issue for android
  • Loading branch information
huili2 authored Feb 26, 2020
2 parents 0012aa3 + d61db70 commit 2b237e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build/platform-android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CFLAGS += -isystem $(NDKROOT)/sysroot/usr/include -isystem $(NDKROOT)/sysroot/us
CXXFLAGS += -fno-rtti -fno-exceptions
LDFLAGS += --sysroot=$(SYSROOT)
SHLDFLAGS = -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-soname,lib$(PROJECT_NAME).so
UTSHLDFLAGS = -Wl,-soname,libut.so

ifeq ($(NDK_TOOLCHAIN_VERSION), clang)
HOST_OS = $(shell uname -s | tr [A-Z] [a-z])
Expand All @@ -70,9 +71,11 @@ ifeq ($(NDK_TOOLCHAIN_VERSION), clang)

CFLAGS += -target $(TARGET_NAME)
LDFLAGS += -target $(TARGET_NAME) -gcc-toolchain $(GCC_TOOLCHAIN_PATH)
LDFLAGS += -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a
endif

# background reading: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#unwinding
LDFLAGS += -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a

ifneq ($(findstring /,$(CXX)),$(findstring \,$(CXX)))
ifneq ($(CXX),$(wildcard $(CXX)))
ifneq ($(CXX).exe,$(wildcard $(CXX).exe))
Expand All @@ -81,10 +84,18 @@ endif
endif
endif

ifeq ($(NDK_TOOLCHAIN_VERSION), clang)
STL_INCLUDES = \
-I$(NDKROOT)/sources/cxx-stl/llvm-libc++/include \
-I$(NDKROOT)/sources/cxx-stl/llvm-libc++abi/include
STL_LIB = \
$(NDKROOT)/sources/cxx-stl/llvm-libc++/libs/$(APP_ABI)/libc++_static.a
else
STL_INCLUDES = \
-I$(NDKROOT)/sources/cxx-stl/stlport/stlport
STL_LIB = \
$(NDKROOT)/sources/cxx-stl/stlport/libs/$(APP_ABI)/libstlport_static.a
endif

GTEST_INCLUDES = $(STL_INCLUDES)
CODEC_UNITTEST_INCLUDES = $(STL_INCLUDES)
Expand Down
4 changes: 4 additions & 0 deletions test/build/android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
ifeq ($(NDK_TOOLCHAIN_VERSION), clang)
APP_STL := c++_shared
else
APP_STL := stlport_shared
endif
APP_PLATFORM := android-12

0 comments on commit 2b237e4

Please sign in to comment.