mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-16 13:20:41 +00:00

Summary: Fixed `Android.rules` for running test suite on remote android - the build configuration is not compatible with ndk structure, change it to link to static libc++ - generally clang should be able to use libc++ and will link against the right library, but some libc++ installations require the user manually link libc++abi. - add flag `-lc++abi` to fix the test binary build failure Added `skipIfTargetAndroid` `skipUnlessTargetAndroid` for better test support - the `skipIfPlatform` method will ask `lldbplatformutil.getPlatform()` for platform info which is actually the os type, and //Android// is not os type but environment - create this function to handle the android target condition **To Run Test on Remote Android** 1 start lldb-server on your devices 2 run lldb-dotest with following configuration: `./lldb-dotest --out-of-tree-debugserver --arch aarch64 --platform-name remote-android --platform-url connect://localhost:12345 --platform-working-dir /data/local/tmp/ --compiler your/ndk/clang` Reviewers: xiaobai, labath Reviewed By: labath Subscribers: labath, javed.absar, kristof.beyls, srhines, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64118 llvm-svn: 365561
96 lines
2.8 KiB
Plaintext
96 lines
2.8 KiB
Plaintext
NDK_ROOT := $(shell dirname $(CC))/../../../../..
|
|
|
|
ifeq "$(findstring 64, $(ARCH))" "64"
|
|
# lowest 64-bit API level
|
|
API_LEVEL := 21
|
|
else ifeq "$(ARCH)" "i386"
|
|
# clone(2) declaration is present only since this api level
|
|
API_LEVEL := 17
|
|
else
|
|
# lowest supported 32-bit API level
|
|
API_LEVEL := 16
|
|
endif
|
|
|
|
ifeq "$(ARCH)" "arm"
|
|
SYSROOT_ARCH := arm
|
|
STL_ARCH := armeabi-v7a
|
|
TRIPLE := armv7-none-linux-androideabi
|
|
ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
|
|
else ifeq "$(ARCH)" "aarch64"
|
|
SYSROOT_ARCH := arm64
|
|
STL_ARCH := arm64-v8a
|
|
TRIPLE := aarch64-none-linux-android
|
|
else ifeq "$(ARCH)" "i386"
|
|
SYSROOT_ARCH := x86
|
|
STL_ARCH := x86
|
|
TRIPLE := i686-none-linux-android
|
|
else ifeq "$(ARCH)" "mips64r6"
|
|
SYSROOT_ARCH := mips64
|
|
STL_ARCH := mips64
|
|
TRIPLE := mips64el-none-linux-android
|
|
else ifeq "$(ARCH)" "mips32"
|
|
SYSROOT_ARCH := mips
|
|
STL_ARCH := mips
|
|
TRIPLE := mipsel-none-linux-android
|
|
else
|
|
SYSROOT_ARCH := $(ARCH)
|
|
STL_ARCH := $(ARCH)
|
|
TRIPLE := $(ARCH)-none-linux-android
|
|
endif
|
|
|
|
ifeq "$(findstring 86,$(ARCH))" "86"
|
|
TOOLCHAIN_DIR := $(STL_ARCH)-4.9
|
|
else ifeq "$(ARCH)" "arm"
|
|
TOOLCHAIN_DIR := arm-linux-androideabi-4.9
|
|
else
|
|
TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9
|
|
endif
|
|
|
|
ifeq "$(ARCH)" "arm"
|
|
TOOL_PREFIX := arm-linux-androideabi
|
|
else
|
|
TOOL_PREFIX := $(subst -none,,$(TRIPLE))
|
|
endif
|
|
|
|
ifeq "$(HOST_OS)" "Linux"
|
|
HOST_TAG := linux-x86_64
|
|
else ifeq "$(HOST_OS)" "Darwin"
|
|
HOST_TAG := darwin-x86_64
|
|
else
|
|
HOST_TAG := windows-x86_64
|
|
endif
|
|
|
|
GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
|
|
|
|
OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy
|
|
ARCHIVER ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-ar
|
|
|
|
ifeq "$(findstring clang,$(CC))" "clang"
|
|
ARCH_CFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
|
|
ARCH_LDFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
|
|
endif
|
|
|
|
ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \
|
|
-isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \
|
|
-D__ANDROID_API__=$(API_LEVEL)
|
|
ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
|
|
|
|
ifeq (1,$(USE_LIBSTDCPP))
|
|
ARCH_CFLAGS += \
|
|
-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
|
|
-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
|
|
-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
|
|
|
|
ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
|
|
else
|
|
ARCH_CXXFLAGS += \
|
|
-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
|
|
-isystem $(NDK_ROOT)/sources/android/support/include \
|
|
-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
|
|
|
|
ARCH_LDFLAGS += \
|
|
-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
|
|
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
|
|
-lc++abi
|
|
endif
|