diff options
author | Howard Chu <hyc@symas.com> | 2019-11-01 03:38:13 +0000 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2019-11-03 21:14:45 +0000 |
commit | 643860776e923428d2d2207ec70ead52adcc9272 (patch) | |
tree | c8414b27be7c20b916149a4585e0453a673eae57 /contrib/depends | |
parent | Merge pull request #6079 (diff) | |
download | monero-643860776e923428d2d2207ec70ead52adcc9272.tar.xz |
Add Android support
Diffstat (limited to 'contrib/depends')
-rw-r--r-- | contrib/depends/Makefile | 6 | ||||
-rw-r--r-- | contrib/depends/hosts/android.mk | 20 | ||||
-rw-r--r-- | contrib/depends/packages/android_ndk.mk | 22 | ||||
-rw-r--r-- | contrib/depends/packages/boost.mk | 2 | ||||
-rw-r--r-- | contrib/depends/packages/openssl.mk | 5 | ||||
-rw-r--r-- | contrib/depends/packages/packages.mk | 10 | ||||
-rw-r--r-- | contrib/depends/packages/sodium.mk | 1 | ||||
-rw-r--r-- | contrib/depends/packages/zeromq.mk | 3 | ||||
-rw-r--r-- | contrib/depends/patches/zeromq/ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch | 38 | ||||
-rw-r--r-- | contrib/depends/toolchain.cmake.in | 36 |
10 files changed, 135 insertions, 8 deletions
diff --git a/contrib/depends/Makefile b/contrib/depends/Makefile index ec0e4cfae..7eedee15e 100644 --- a/contrib/depends/Makefile +++ b/contrib/depends/Makefile @@ -53,7 +53,10 @@ endif host_arch=$(firstword $(subst -, ,$(canonical_host))) host_vendor=$(word 2,$(subst -, ,$(canonical_host))) full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host)) +host_os:=$(findstring android,$(full_host_os)) +ifeq ($(host_os),) host_os:=$(findstring linux,$(full_host_os)) +endif host_os+=$(findstring darwin,$(full_host_os)) host_os+=$(findstring mingw32,$(full_host_os)) host_os:=$(strip $(host_os)) @@ -74,6 +77,9 @@ endif ifeq ($(host_os),darwin) host_cmake=Darwin endif +ifeq ($(host_os),android) +host_cmake=Android +endif AT_$(V):= AT_:=@ diff --git a/contrib/depends/hosts/android.mk b/contrib/depends/hosts/android.mk new file mode 100644 index 000000000..2a24435d4 --- /dev/null +++ b/contrib/depends/hosts/android.mk @@ -0,0 +1,20 @@ +ANDROID_API=21 + +ifeq ($(host_arch),arm) +host_toolchain=arm-linux-androideabi- +endif + +android_CC=$(host_toolchain)clang +android_CXX=$(host_toolchain)clang++ + +android_CFLAGS=-pipe +android_CXXFLAGS=$(android_CFLAGS) + +android_release_CFLAGS=-O2 +android_release_CXXFLAGS=$(android_release_CFLAGS) + +android_debug_CFLAGS=-g -O0 +android_debug_CXXFLAGS=$(android_debug_CFLAGS) + +android_native_toolchain=android_ndk + diff --git a/contrib/depends/packages/android_ndk.mk b/contrib/depends/packages/android_ndk.mk new file mode 100644 index 000000000..9b8a5332f --- /dev/null +++ b/contrib/depends/packages/android_ndk.mk @@ -0,0 +1,22 @@ +package=android_ndk +$(package)_version=17b +$(package)_download_path=https://dl.google.com/android/repository/ +$(package)_file_name=android-ndk-r$($(package)_version)-linux-x86_64.zip +$(package)_sha256_hash=5dfbbdc2d3ba859fed90d0e978af87c71a91a5be1f6e1c40ba697503d48ccecd + +define $(package)_set_vars +$(package)_config_opts_arm=--arch arm +$(package)_config_opts_aarch64=--arch arm64 +endef + +define $(package)_extract_cmds + echo $($(package)_sha256_hash) $($(1)_source_dir)/$($(package)_file_name) | sha256sum -c &&\ + unzip -q $($(1)_source_dir)/$($(package)_file_name) +endef + +define $(package)_stage_cmds + android-ndk-r$($(package)_version)/build/tools/make_standalone_toolchain.py --api 21 \ + --install-dir $(build_prefix) --stl=libc++ $($(package)_config_opts) &&\ + mv $(build_prefix) $($(package)_staging_dir)/$(host_prefix) +endef + diff --git a/contrib/depends/packages/boost.mk b/contrib/depends/packages/boost.mk index e60a1c677..3231df925 100644 --- a/contrib/depends/packages/boost.mk +++ b/contrib/depends/packages/boost.mk @@ -3,6 +3,7 @@ $(package)_version=1_64_0 $(package)_download_path=https://dl.bintray.com/boostorg/release/1.64.0/source/ $(package)_file_name=$(package)_$($(package)_version).tar.bz2 $(package)_sha256_hash=7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332 +$(package)_dependencies=libiconv define $(package)_set_vars $(package)_config_opts_release=variant=release @@ -10,6 +11,7 @@ $(package)_config_opts_debug=variant=debug $(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam $(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 $(package)_config_opts_linux=threadapi=pthread runtime-link=shared +$(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android $(package)_config_opts_darwin=--toolset=darwin-4.2.1 runtime-link=shared $(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static $(package)_config_opts_x86_64_mingw32=address-model=64 diff --git a/contrib/depends/packages/openssl.mk b/contrib/depends/packages/openssl.mk index 8d08900f5..f3b781f28 100644 --- a/contrib/depends/packages/openssl.mk +++ b/contrib/depends/packages/openssl.mk @@ -40,6 +40,8 @@ $(package)_config_opts_x86_64_linux=linux-x86_64 $(package)_config_opts_i686_linux=linux-generic32 $(package)_config_opts_arm_linux=linux-generic32 $(package)_config_opts_aarch64_linux=linux-generic64 +$(package)_config_opts_arm_android=--static android-armv7 no-asm +$(package)_config_opts_aarch64_android=--static android no-asm $(package)_config_opts_riscv64_linux=linux-generic64 $(package)_config_opts_mipsel_linux=linux-generic32 $(package)_config_opts_mips_linux=linux-generic32 @@ -51,7 +53,8 @@ endef define $(package)_preprocess_cmds sed -i.old "/define DATE/d" util/mkbuildinf.pl && \ - sed -i.old "s|engines apps test|engines|" Makefile.org + sed -i.old "s|engines apps test|engines|" Makefile.org && \ + sed -i -e "s/-mandroid //" Configure endef define $(package)_config_cmds diff --git a/contrib/depends/packages/packages.mk b/contrib/depends/packages/packages.mk index f4b9c6407..2d8030448 100644 --- a/contrib/depends/packages/packages.mk +++ b/contrib/depends/packages/packages.mk @@ -1,6 +1,14 @@ -packages:=boost openssl zeromq cppzmq expat ldns libiconv hidapi protobuf libusb +ifeq ($(host_os),android) +packages:=boost openssl zeromq libiconv +else +packages:=boost openssl zeromq lexpat dns libiconv hidapi protobuf libusb +endif + native_packages := native_ccache native_protobuf +android_native_packages = android_ndk +android_packages = ncurses readline sodium + darwin_native_packages = native_biplist native_ds_store native_mac_alias darwin_packages = sodium-darwin ncurses readline diff --git a/contrib/depends/packages/sodium.mk b/contrib/depends/packages/sodium.mk index b71f4383e..cdc690e69 100644 --- a/contrib/depends/packages/sodium.mk +++ b/contrib/depends/packages/sodium.mk @@ -8,6 +8,7 @@ $(package)_patches=fix-whitespace.patch define $(package)_set_vars $(package)_config_opts=--enable-static --disable-shared $(package)_config_opts+=--prefix=$(host_prefix) +$(package)_config_opts_android=RANLIB=$($(package)_ranlib) AR=$($(package)_ar) CC=$($(package)_cc) endef define $(package)_config_cmds diff --git a/contrib/depends/packages/zeromq.mk b/contrib/depends/packages/zeromq.mk index c3a405a60..46caf14cb 100644 --- a/contrib/depends/packages/zeromq.mk +++ b/contrib/depends/packages/zeromq.mk @@ -3,7 +3,7 @@ $(package)_version=4.1.7 $(package)_download_path=https://github.com/zeromq/zeromq4-1/releases/download/v$($(package)_version)/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=31c383cfcd3be1dc8a66e448c403029e793687e70473b89c4cc0bd626e7da299 -$(package)_patches=9114d3957725acd34aa8b8d011585812f3369411.patch 9e6745c12e0b100cd38acecc16ce7db02905e27c.patch +$(package)_patches=9114d3957725acd34aa8b8d011585812f3369411.patch 9e6745c12e0b100cd38acecc16ce7db02905e27c.patch ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch define $(package)_set_vars $(package)_config_opts=--without-documentation --disable-shared --without-libsodium --disable-curve @@ -14,6 +14,7 @@ endef define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/9114d3957725acd34aa8b8d011585812f3369411.patch && \ patch -p1 < $($(package)_patch_dir)/9e6745c12e0b100cd38acecc16ce7db02905e27c.patch && \ + patch -p1 < $($(package)_patch_dir)/ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch && \ ./autogen.sh endef diff --git a/contrib/depends/patches/zeromq/ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch b/contrib/depends/patches/zeromq/ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch new file mode 100644 index 000000000..a532df1b6 --- /dev/null +++ b/contrib/depends/patches/zeromq/ffe62d3398d5e0191f554f61049aa7ec9fc892ae.patch @@ -0,0 +1,38 @@ +From ffe62d3398d5e0191f554f61049aa7ec9fc892ae Mon Sep 17 00:00:00 2001 +From: Gregory Lemercier <greglemercier@free.fr> +Date: Sun, 7 Oct 2018 18:06:54 +0200 +Subject: [PATCH] Fix build on arm64 architectures with some strict compilers + +This patch fixes an issue that occurs on 64-bit architetures under +strict compiler rules. The code initially checked that the received +size stored in 'uint64_t' was not bigger than the max value of a +'size_t' variable, which is legitimate on 32-bit architectures where +'size_t' variables are stored on 32 bits. On 64-bit architectures, +this test no longer makes sense since 'uint64_t' and 'size_t' types +have the same size. The issue is fixed by ignoring this portion +of code when built for arm64. +--- + src/v1_decoder.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/v1_decoder.cpp b/src/v1_decoder.cpp +index b002dc9d..2c8c97a7 100644 +--- a/src/v1_decoder.cpp ++++ b/src/v1_decoder.cpp +@@ -114,11 +114,13 @@ int zmq::v1_decoder_t::eight_byte_size_ready () + return -1; + } + ++#ifndef __aarch64__ + // Message size must fit within range of size_t data type. + if (payload_length - 1 > std::numeric_limits <size_t>::max ()) { + errno = EMSGSIZE; + return -1; + } ++#endif + + const size_t msg_size = static_cast <size_t> (payload_length - 1); + +-- +2.20.1 + diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index ebe96b69c..0728515e3 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -1,4 +1,4 @@ -# Set the system name, either Darwin, Linux, or Windows +# Set the system name to one of Android, Darwin, Linux, or Windows SET(CMAKE_SYSTEM_NAME @depends@) SET(CMAKE_BUILD_TYPE @release_type@) @@ -18,13 +18,14 @@ SET(CMAKE_FIND_ROOT_PATH @prefix@ /usr) SET(ENV{PKG_CONFIG_PATH} @prefix@/lib/pkgconfig) -SET(LRELEASE_PATH @prefix@/native/bin CACHE FILEPATH "path to lrelease" FORCE) - SET(Readline_ROOT_DIR @prefix@) SET(Readline_INCLUDE_DIR @prefix@/include) SET(Readline_LIBRARY @prefix@/lib/libreadline.a) SET(Termcap_LIBRARY @prefix@/lib/libtinfo.a) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android") +SET(LRELEASE_PATH @prefix@/native/bin CACHE FILEPATH "path to lrelease" FORCE) + SET(LIBUNWIND_INCLUDE_DIR @prefix@/include) SET(LIBUNWIND_LIBRARIES @prefix@/lib/libunwind.a) SET(LIBUNWIND_LIBRARY_DIRS @prefix@/lib) @@ -37,6 +38,7 @@ SET(Protobuf_PROTOC_EXECUTABLE @prefix@/native/bin/protoc CACHE FILEPATH "Path t SET(Protobuf_INCLUDE_DIR @prefix@/include CACHE PATH "Protobuf include dir") SET(Protobuf_INCLUDE_DIRS @prefix@/include CACHE PATH "Protobuf include dir") SET(Protobuf_LIBRARY @prefix@/lib/libprotobuf.a CACHE FILEPATH "Protobuf library") +endif() SET(ZMQ_INCLUDE_PATH @prefix@/include) SET(ZMQ_LIB @prefix@/lib/libzmq.a) @@ -78,6 +80,22 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(CMAKE_OSX_ARCHITECTURES "x86_64") SET(LLVM_ENABLE_PIC OFF) SET(LLVM_ENABLE_PIE OFF) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") + SET(ANDROID TRUE) + if(ARCHITECTURE STREQUAL "arm") + SET(CMAKE_ANDROID_ARCH_ABI "armeabi-v7a") + SET(CMAKE_SYSTEM_PROCESSOR "armv7-a") + SET(CMAKE_ANDROID_ARM_MODE ON) + SET(CMAKE_C_COMPILER_TARGET arm-linux-androideabi) + SET(CMAKE_CXX_COMPILER_TARGET arm-linux-androideabi) + SET(_CMAKE_TOOLCHAIN_PREFIX arm-linux-androideabi-) + elseif(ARCHITECTURE STREQUAL "aarch64") + SET(CMAKE_ANDROID_ARCH_ABI "arm64-v8a") + SET(CMAKE_SYSTEM_PROCESSOR "aarch64") + endif() + SET(CMAKE_ANDROID_STANDALONE_TOOLCHAIN @prefix@/native) + SET(CMAKE_C_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang") + SET(CMAKE_CXX_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang++") else() SET(CMAKE_C_COMPILER @CC@) SET(CMAKE_CXX_COMPILER @CXX@) @@ -89,13 +107,21 @@ if(ARCHITECTURE STREQUAL "arm") set(ARM_ID "armv7-a") set(BUILD_64 OFF) set(CMAKE_BUILD_TYPE release) - set(BUILD_TAG "linux-armv7") + if(ANDROID) + set(BUILD_TAG "android-armv7") + else() + set(BUILD_TAG "linux-armv7") + endif() set(ARM7) elseif(ARCHITECTURE STREQUAL "aarch64") set(ARCH "armv8-a") set(ARM ON) set(ARM_ID "armv8-a") - set(BUILD_TAG "linux-armv8") + if(ANDROID) + set(BUILD_TAG "android-armv8") + else() + set(BUILD_TAG "linux-armv8") + endif() set(BUILD_64 ON) endif() |