mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 18:40:27 +01:00
Merge pull request #3827 from sappo/master
Improve android build handling
This commit is contained in:
commit
917921095e
129
README.md
129
README.md
@ -15,28 +15,28 @@ protocols and more.
|
||||
|
||||
## Supported platforms <a name="#platforms"/>
|
||||
|
||||
Libzmq is mainly written in C++98 with some optional C++11-fragments. For
|
||||
configuration either autotools or CMake is employed. See below for some lists
|
||||
Libzmq is mainly written in C++98 with some optional C++11-fragments. For
|
||||
configuration either autotools or CMake is employed. See below for some lists
|
||||
of platforms, where libzmq has been successfully compiled on.
|
||||
|
||||
### Supported platforms with primary CI
|
||||
|
||||
OS and version | Architecture | Compiler and version | Build system | Remarks
|
||||
-------------- | ------------ | -------------------- | ------------ | -------
|
||||
Android NDK 11c | ARM | gcc ? | autotools |
|
||||
Ubuntu 14.04.5 LTS (trusty) | amd64 | clang 5.0.0 | autotools | STABLE, extras: GSSAPI, PGM, NORM, C++98 mode only
|
||||
Ubuntu 14.04.5 LTS (trusty) | amd64 | gcc 4.8.4 | autotools | STABLE, DRAFT, extras: GSSAPI, PGM, NORM, TIPC, IPV6, also POLLER=poll, POLLER=select, also valgrind and address sanitizer executions
|
||||
Ubuntu 14.04.5 LTS (trusty) | amd64 | gcc 4.8.4 | CMake 3.12.2 | STABLE
|
||||
Windows Server 2012 R2 | x86 | Visual Studio 2008 | CMake 3.12.2 | DRAFT
|
||||
Windows Server 2012 R2 | x86 | Visual Studio 2010 SP1 | CMake 3.12.2 | DRAFT
|
||||
Windows Server 2012 R2 | x86 | Visual Studio 2012 Update 5 | CMake 3.12.2 | DRAFT
|
||||
Windows Server 2012 R2 | x86, amd64 | Visual Studio 2013 Update 5 | CMake 3.12.2 | DRAFT, STABLE (x86 Release only), also POLLER=epoll
|
||||
Windows Server 2012 R2 | x86 | Visual Studio 2015 Update 3 | CMake 3.12.2 | DRAFT
|
||||
Windows Server 2016 | x86 | Visual Studio 2017 15.9.6 | CMake 3.13.3 | DRAFT
|
||||
cygwin 3.0.0 on Windows Server 2012 R2 | amd64 | gcc 7.4.0 | CMake 3.6.2 | DRAFT
|
||||
MSYS2 ? on Windows Server 2012 R2 | amd64 | gcc 6.4.0 | CMake ? | DRAFT
|
||||
Mac OS X 10.13 | amd64 | Xcode 9.4.1, Apple LLVM 9.1.0 | autotools | STABLE, DRAFT
|
||||
Mac OS X 10.13 | amd64 | Xcode 9.4.1, Apple LLVM 9.1.0 | CMake 3.11.4 | DRAFT
|
||||
| OS and version | Architecture | Compiler and version | Build system | Remarks |
|
||||
|----------------------------------------|-------------------------|-------------------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Android NDK r20 | arm, arm64, x86, x86_64 | llvm (see NDK) | autotools | DRAFT |
|
||||
| Ubuntu 14.04.5 LTS (trusty) | amd64 | clang 5.0.0 | autotools | STABLE, extras: GSSAPI, PGM, NORM, C++98 mode only |
|
||||
| Ubuntu 14.04.5 LTS (trusty) | amd64 | gcc 4.8.4 | autotools | STABLE, DRAFT, extras: GSSAPI, PGM, NORM, TIPC, IPV6, also POLLER=poll, POLLER=select, also valgrind and address sanitizer executions |
|
||||
| Ubuntu 14.04.5 LTS (trusty) | amd64 | gcc 4.8.4 | CMake 3.12.2 | STABLE |
|
||||
| Windows Server 2012 R2 | x86 | Visual Studio 2008 | CMake 3.12.2 | DRAFT |
|
||||
| Windows Server 2012 R2 | x86 | Visual Studio 2010 SP1 | CMake 3.12.2 | DRAFT |
|
||||
| Windows Server 2012 R2 | x86 | Visual Studio 2012 Update 5 | CMake 3.12.2 | DRAFT |
|
||||
| Windows Server 2012 R2 | x86, amd64 | Visual Studio 2013 Update 5 | CMake 3.12.2 | DRAFT, STABLE (x86 Release only), also POLLER=epoll |
|
||||
| Windows Server 2012 R2 | x86 | Visual Studio 2015 Update 3 | CMake 3.12.2 | DRAFT |
|
||||
| Windows Server 2016 | x86 | Visual Studio 2017 15.9.6 | CMake 3.13.3 | DRAFT |
|
||||
| cygwin 3.0.0 on Windows Server 2012 R2 | amd64 | gcc 7.4.0 | CMake 3.6.2 | DRAFT |
|
||||
| MSYS2 ? on Windows Server 2012 R2 | amd64 | gcc 6.4.0 | CMake ? | DRAFT |
|
||||
| Mac OS X 10.13 | amd64 | Xcode 9.4.1, Apple LLVM 9.1.0 | autotools | STABLE, DRAFT |
|
||||
| Mac OS X 10.13 | amd64 | Xcode 9.4.1, Apple LLVM 9.1.0 | CMake 3.11.4 | DRAFT |
|
||||
|
||||
Note: the platforms are regularly updated by the service providers, so this information might get out of date
|
||||
without any changes on the side of libzmq. For Appveyor, refer to https://www.appveyor.com/updates/ regarding
|
||||
@ -44,69 +44,69 @@ platform updates. For travis-ci, refer to https://changelog.travis-ci.com/ regar
|
||||
|
||||
### Supported platforms with secondary CI
|
||||
|
||||
OS and version | Architecture | Compiler and version | Build system | Remarks
|
||||
-------------- | ------------ | -------------------- | ------------ | -------
|
||||
CentOS 6 | x86, amd64 | ? | autotools |
|
||||
CentOS 7 | amd64 | ? | autotools |
|
||||
Debian 8.0 | x86, amd64 | ? | autotools |
|
||||
Debian 9.0 | ARM64, x86, amd64 | ? | autotools |
|
||||
Fedora 28 | ARM64, ARM32, amd64 | ? | autotools |
|
||||
Fedora 29 | ARM64, ARM32, amd64 | ? | autotools |
|
||||
Fedora Rawhide | ARM64, ARM32, amd64 | ? | autotools |
|
||||
RedHat Enterprise Linux 7 | amd64, ppc64 | ? | autotools |
|
||||
SuSE Linux Enterprise 12 SP4 | ARM64, amd64, ppc64, s390x | ? | autotools |
|
||||
SuSE Linux Enterprise 15 | amd64 | ? | autotools |
|
||||
xUbuntu 12.04 | x86, amd64 | ? | autotools |
|
||||
xUbuntu 14.04 | x86, amd64 | ? | autotools |
|
||||
xUbuntu 16.04 | x86, amd64 | ? | autotools |
|
||||
xUbuntu 18.04 | x86, amd64 | ? | autotools |
|
||||
xUbuntu 18.10 | x86, amd64 | ? | autotools |
|
||||
| OS and version | Architecture | Compiler and version | Build system | Remarks |
|
||||
|------------------------------|----------------------------|----------------------|--------------|---------|
|
||||
| CentOS 6 | x86, amd64 | ? | autotools | |
|
||||
| CentOS 7 | amd64 | ? | autotools | |
|
||||
| Debian 8.0 | x86, amd64 | ? | autotools | |
|
||||
| Debian 9.0 | ARM64, x86, amd64 | ? | autotools | |
|
||||
| Fedora 28 | ARM64, ARM32, amd64 | ? | autotools | |
|
||||
| Fedora 29 | ARM64, ARM32, amd64 | ? | autotools | |
|
||||
| Fedora Rawhide | ARM64, ARM32, amd64 | ? | autotools | |
|
||||
| RedHat Enterprise Linux 7 | amd64, ppc64 | ? | autotools | |
|
||||
| SuSE Linux Enterprise 12 SP4 | ARM64, amd64, ppc64, s390x | ? | autotools | |
|
||||
| SuSE Linux Enterprise 15 | amd64 | ? | autotools | |
|
||||
| xUbuntu 12.04 | x86, amd64 | ? | autotools | |
|
||||
| xUbuntu 14.04 | x86, amd64 | ? | autotools | |
|
||||
| xUbuntu 16.04 | x86, amd64 | ? | autotools | |
|
||||
| xUbuntu 18.04 | x86, amd64 | ? | autotools | |
|
||||
| xUbuntu 18.10 | x86, amd64 | ? | autotools | |
|
||||
|
||||
### Supported platforms with known active users
|
||||
|
||||
At the time of writing, no explicit reports have been available. Please report your experiences by opening a PR
|
||||
At the time of writing, no explicit reports have been available. Please report your experiences by opening a PR
|
||||
adding an entry or moving an entry from the section below.
|
||||
|
||||
Under "last report", please name either the SHA1 in case of an unreleased version, or the version number in
|
||||
Under "last report", please name either the SHA1 in case of an unreleased version, or the version number in
|
||||
case of a released version.
|
||||
|
||||
OS and version | Architecture | Compiler and version | Build system | Last report | Remarks
|
||||
-------------- | ------------ | -------------------- | ------------ | ----------- | -------
|
||||
Solaris 10 | x86, amd64, sparc | GCC 8.1.0 | CMake | 2019/03/18 |
|
||||
DragonFly BSD | amd64 | gcc 8.3 | autotools | 2018/08/07 git-72854e63 |
|
||||
IBM i | ppc64 | gcc 6.3 | autotools | 2019/10/02 git-25320a3 |
|
||||
| OS and version | Architecture | Compiler and version | Build system | Last report | Remarks |
|
||||
|----------------|-------------------|----------------------|--------------|-------------------------|---------|
|
||||
| Solaris 10 | x86, amd64, sparc | GCC 8.1.0 | CMake | 2019/03/18 | |
|
||||
| DragonFly BSD | amd64 | gcc 8.3 | autotools | 2018/08/07 git-72854e63 | |
|
||||
| IBM i | ppc64 | gcc 6.3 | autotools | 2019/10/02 git-25320a3 | |
|
||||
|
||||
|
||||
### Supported platforms without known active users
|
||||
|
||||
Note: this list is incomplete and inaccurate and still needs some work.
|
||||
|
||||
OS and version | Architecture | Compiler and version | Build system | Remarks
|
||||
-------------- | ------------ | -------------------- | ------------ | -------
|
||||
Any Linux distribution | x86, amd64 | gcc ?+, clang ?+, icc ?+ | autotools, CMake |
|
||||
SunOS, Solaris | x86, amd64 | SunPro | autotools, CMake |
|
||||
GNU/kFreeBSD | ? | ? | autotools, CMake |
|
||||
FreeBSD | ? | ? | autotools, CMake |
|
||||
NetBSD | ? | ? | autotools, CMake |
|
||||
OpenBSD | ? | ? | autotools, CMake |
|
||||
DragonFly BSD | amd64 | gcc 8.3 | autotools, CMake |
|
||||
HP-UX | ? | ? | autotools, CMake |
|
||||
GNU/Hurd | ? | ? | autotools |
|
||||
VxWorks 6.8 | ? | ? | ? |
|
||||
Windows CE | ? | ? | ? |
|
||||
Windows UWP | ? | ? | ? |
|
||||
OpenVMS | ? | ? | ? |
|
||||
| OS and version | Architecture | Compiler and version | Build system | Remarks |
|
||||
|------------------------|--------------|--------------------------|------------------|---------|
|
||||
| Any Linux distribution | x86, amd64 | gcc ?+, clang ?+, icc ?+ | autotools, CMake | |
|
||||
| SunOS, Solaris | x86, amd64 | SunPro | autotools, CMake | |
|
||||
| GNU/kFreeBSD | ? | ? | autotools, CMake | |
|
||||
| FreeBSD | ? | ? | autotools, CMake | |
|
||||
| NetBSD | ? | ? | autotools, CMake | |
|
||||
| OpenBSD | ? | ? | autotools, CMake | |
|
||||
| DragonFly BSD | amd64 | gcc 8.3 | autotools, CMake | |
|
||||
| HP-UX | ? | ? | autotools, CMake | |
|
||||
| GNU/Hurd | ? | ? | autotools | |
|
||||
| VxWorks 6.8 | ? | ? | ? | |
|
||||
| Windows CE | ? | ? | ? | |
|
||||
| Windows UWP | ? | ? | ? | |
|
||||
| OpenVMS | ? | ? | ? | |
|
||||
|
||||
### Unsupported platforms
|
||||
|
||||
OS and version | Architecture | Compiler and version | Remarks
|
||||
-------------- | ------------ | -------------------- | -------
|
||||
QNX 6.3 | ? | gcc 3.3.5 | see #3371, support was added by a user, but not contributed to upstream
|
||||
Windows 10 | ARM, ARM64 | Visual Studio 2017 | see #3366, probably only minor issues
|
||||
| OS and version | Architecture | Compiler and version | Remarks |
|
||||
|----------------|--------------|----------------------|-------------------------------------------------------------------------|
|
||||
| QNX 6.3 | ? | gcc 3.3.5 | see #3371, support was added by a user, but not contributed to upstream |
|
||||
| Windows 10 | ARM, ARM64 | Visual Studio 2017 | see #3366, probably only minor issues |
|
||||
|
||||
For more details, see [here](SupportedPlatforms.md).
|
||||
|
||||
For some platforms (Linux, Mac OS X), [prebuilt binary packages are supplied by the ZeroMQ organization](#installation).
|
||||
For some platforms (Linux, Mac OS X), [prebuilt binary packages are supplied by the ZeroMQ organization](#installation).
|
||||
For other platforms, you need to [build your own binaries](#build).
|
||||
|
||||
## Installation of binary packages <a name="installation"/>
|
||||
@ -157,6 +157,11 @@ For OSX users, packages are available via brew.
|
||||
|
||||
To build from sources, see the INSTALL file included with the distribution.
|
||||
|
||||
### Android
|
||||
|
||||
To build from source, see [REAMDE](./builds/android/README.md) file in the
|
||||
android build directory.
|
||||
|
||||
## Resources
|
||||
|
||||
Extensive documentation is provided with the distribution. Refer to
|
||||
|
@ -1,83 +1,29 @@
|
||||
LIBZMQ ANDROID COMPILATION STEPS
|
||||
================================
|
||||
To launch the docker build:
|
||||
# Android Build
|
||||
|
||||
$ docker build .
|
||||
## Prerequisites
|
||||
|
||||
To launch the android build, you have to first install the android-ndk first in your HOME directory:
|
||||
You need the Android Native Development Kit (NDK) installed. See
|
||||
[here](https://developer.android.com/ndk) to download it.
|
||||
|
||||
$ cd ~
|
||||
$ export ANDROID_NDK_VERSION="r10e"
|
||||
$ wget -q https://dl.google.com/android/ndk/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.bin -O android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.bin
|
||||
$ #check the hashes before executing this binary
|
||||
$ md5sum android-ndk-r10e-linux-x86_64.bin
|
||||
# 19af543b068bdb7f27787c2bc69aba7f android-ndk-r10e-linux-x86_64.bin
|
||||
$ sha256sum android-ndk-r10e-linux-x86_64.bin
|
||||
# 102d6723f67ff1384330d12c45854315d6452d6510286f4e5891e00a5a8f1d5a android-ndk-r10e-linux-x86_64.bin
|
||||
$ chmod +x android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.bin
|
||||
$ ./android-ndk-r10e-linux-x86_64.bin
|
||||
$ export ANDROID_NDK_ROOT=${HOME}/android-ndk-r10e
|
||||
$ export TOOLCHAIN_NAME=arm-linux-androideabi-4.9
|
||||
$ export TOOLCHAIN_HOST=arm-linux-androideabi
|
||||
$ export TOOLCHAIN_PATH=${ANDROID_NDK_ROOT}/toolchains/${TOOLCHAIN_NAME}/prebuilt/linux-x86_64/bin
|
||||
$ export TOOLCHAIN_ARCH=arm
|
||||
This project is tested against Android NDK version r20.
|
||||
|
||||
Then you can launch the build:
|
||||
If you installed version r20 all you have to do is to expose the NDK root
|
||||
directory as environment variable, e.g:
|
||||
|
||||
$ cd ~/libzmq/builds/android
|
||||
$ ./build.sh
|
||||
Cloning into 'libsodium'...
|
||||
remote: Counting objects: 15246, done.
|
||||
remote: Compressing objects: 100% (182/182), done.
|
||||
Receiving objects: 16% (2440/15246)
|
||||
[...]
|
||||
export ANDROID_NDK_ROOT=$HOME/android-ndk-r20
|
||||
|
||||
A successful build should finish with the following message and give you back your shell prompt:
|
||||
If you installed another version you have to expose the NDK root directory as
|
||||
well as the NDK version, e.g:
|
||||
|
||||
[...]
|
||||
make[2]: Leaving directory '/tmp/android_build/arm-linux-androideabi-4.9/libzmq'
|
||||
make[1]: Leaving directory '/tmp/android_build/arm-linux-androideabi-4.9/libzmq'
|
||||
libzmq android build succeeded
|
||||
$
|
||||
export ANDROID_NDK_ROOT=$HOME/android-ndk-r17c
|
||||
export NDK_VERSION=android-ndk-r17c
|
||||
|
||||
You will then be able to see libzmq.so compiled in the prefix/ directory:
|
||||
To specify the minimum sdk version set the environment variable below:
|
||||
|
||||
$ cd ~/libzmq/builds/android/prefix/arm-linux-androideabi-4.9/lib
|
||||
$ ls
|
||||
libsodium.a libsodium.la libsodium.so libzmq.a libzmq.la libzmq.so pkgconfig
|
||||
export MIN_SDK_VERSION=21 # Default value if unset
|
||||
|
||||
You can then triple check that they are ARM libs:
|
||||
## Build
|
||||
|
||||
$ cd ~/libzmq/builds/android/prefix/arm-linux-androideabi-4.9/lib
|
||||
$ file libzmq.so
|
||||
libzmq.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, not stripped
|
||||
In the android directory, run:
|
||||
|
||||
|
||||
COMPILE WITH DOCKERFILE
|
||||
=======================
|
||||
|
||||
To launch the docker build with a tagged image as a result:
|
||||
|
||||
$ cd ~/libzmq/builds/android
|
||||
$ docker build -t libzmq-android:`date +"%y%m%d-%H%M%S"` .
|
||||
$ docker build -t libzmq-android:latest .
|
||||
|
||||
If it is successful, it will end by "libzmq android build succeeded" followed by the ContainerID "e53db616aff4":
|
||||
|
||||
[...]
|
||||
make[2]: Leaving directory `/tmp/android_build/arm-linux-androideabi-4.9/libzmq'
|
||||
make[1]: Leaving directory `/tmp/android_build/arm-linux-androideabi-4.9/libzmq'
|
||||
libzmq android build succeeded
|
||||
---> e53db616aff4
|
||||
Removing intermediate container 8a5f3e34f3da
|
||||
Successfully built e53db616aff4
|
||||
$
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
libzmq-android 151218-101411 e53db616aff4 18 hours ago 5.495 GB
|
||||
|
||||
If you want to collect the artifacts on the build, you can specify a directory in your HOME directory, such as "$HOME/libzmq-android-bins" for example:
|
||||
|
||||
$ mkdir -pv $HOME/libzmq-android-bins
|
||||
$ docker run -v $HOME/libzmq-android-bins:/data libzmq-android:latest "cp -v /home/zmq/libzmq/builds/android/prefix/arm-linux-androideabi-4.9/lib/* /data"
|
||||
./build.sh [ arm | arm64 | x86 | x86_64 ]
|
||||
|
@ -69,72 +69,80 @@ function android_build_check_fail {
|
||||
fi
|
||||
}
|
||||
|
||||
function android_build_arch {
|
||||
export TOOLCHAIN_PATH="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
|
||||
export TOOLCHAIN_HOST=$1
|
||||
export TOOLCHAIN_COMP=$2
|
||||
export TOOLCHAIN_CXXSTL=$3
|
||||
export TOOLCHAIN_ARCH=$4
|
||||
}
|
||||
|
||||
function android_build_env {
|
||||
##
|
||||
# Check that necessary environment variables are set
|
||||
|
||||
|
||||
if [ -z "$ANDROID_NDK_ROOT" ]; then
|
||||
ANDROID_BUILD_FAIL+=("Please set the ANDROID_NDK_ROOT environment variable")
|
||||
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r20\")")
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$TOOLCHAIN_PATH" ]; then
|
||||
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_PATH environment variable")
|
||||
ANDROID_BUILD_FAIL+=(" (eg. \"/home/user/android/android-ndk-r20/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin\")")
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$TOOLCHAIN_HOST" ]; then
|
||||
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_HOST environment variable")
|
||||
ANDROID_BUILD_FAIL+=(" (eg. \"arm-linux-androideabi\")")
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$TOOLCHAIN_COMP" ]; then
|
||||
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_COMP environment variable")
|
||||
ANDROID_BUILD_FAIL+=(" (eg. \"armv7a-linux-androideabi\")")
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$TOOLCHAIN_CXXSTL" ]; then
|
||||
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_CXXSTL environment variable")
|
||||
ANDROID_BUILD_FAIL+=(" (eg. \"armeabi-v7abi\")")
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$TOOLCHAIN_ARCH" ]; then
|
||||
ANDROID_BUILD_FAIL+=("Please set the TOOLCHAIN_ARCH environment variable")
|
||||
ANDROID_BUILD_FAIL+=(" (eg. \"arm\")")
|
||||
fi
|
||||
|
||||
|
||||
android_build_check_fail
|
||||
|
||||
|
||||
##
|
||||
# Check that directories given by environment variables exist
|
||||
|
||||
|
||||
if [ ! -d "$ANDROID_NDK_ROOT" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The ANDROID_NDK_ROOT directory does not exist")
|
||||
ANDROID_BUILD_FAIL+=(" ${ANDROID_NDK_ROOT}")
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d "$TOOLCHAIN_PATH" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The TOOLCHAIN_PATH directory does not exist")
|
||||
ANDROID_BUILD_FAIL+=(" ${TOOLCHAIN_PATH}")
|
||||
fi
|
||||
|
||||
|
||||
##
|
||||
# Set up some local variables and check them
|
||||
|
||||
|
||||
ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/platforms/android-${MIN_SDK_VERSION}/arch-${TOOLCHAIN_ARCH}"
|
||||
|
||||
|
||||
if [ ! -d "$ANDROID_BUILD_SYSROOT" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The ANDROID_BUILD_SYSROOT directory does not exist")
|
||||
ANDROID_BUILD_FAIL+=(" ${ANDROID_BUILD_SYSROOT}")
|
||||
fi
|
||||
|
||||
ANDROID_BUILD_PREFIX="${ANDROID_BUILD_DIR}/prefix/${TOOLCHAIN_NAME}"
|
||||
|
||||
|
||||
ANDROID_BUILD_PREFIX="${ANDROID_BUILD_DIR}/prefix/${TOOLCHAIN_ARCH}"
|
||||
|
||||
mkdir -p "$ANDROID_BUILD_PREFIX" || {
|
||||
ANDROID_BUILD_FAIL+=("Failed to make ANDROID_BUILD_PREFIX directory")
|
||||
ANDROID_BUILD_FAIL+=(" ${ANDROID_BUILD_PREFIX}")
|
||||
}
|
||||
|
||||
|
||||
android_build_check_fail
|
||||
}
|
||||
|
||||
@ -147,37 +155,37 @@ function _android_build_opts_process_binaries {
|
||||
local AR="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ar"
|
||||
local RANLIB="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-ranlib"
|
||||
local STRIP="${TOOLCHAIN_PATH}/${TOOLCHAIN_HOST}-strip"
|
||||
|
||||
|
||||
if [ ! -x "${CC}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The CC binary does not exist or is not executable")
|
||||
ANDROID_BUILD_FAIL+=(" ${CC}")
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -x "${CXX}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The CXX binary does not exist or is not executable")
|
||||
ANDROID_BUILD_FAIL+=(" ${CXX}")
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -x "${LD}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The LD binary does not exist or is not executable")
|
||||
ANDROID_BUILD_FAIL+=(" ${LD}")
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -x "${AS}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The AS binary does not exist or is not executable")
|
||||
ANDROID_BUILD_FAIL+=(" ${AS}")
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -x "${AR}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The AR binary does not exist or is not executable")
|
||||
ANDROID_BUILD_FAIL+=(" ${AR}")
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -x "${RANLIB}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The RANLIB binary does not exist or is not executable")
|
||||
ANDROID_BUILD_FAIL+=(" ${RANLIB}")
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -x "${STRIP}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("The STRIP binary does not exist or is not executable")
|
||||
ANDROID_BUILD_FAIL+=(" ${STRIP}")
|
||||
@ -191,17 +199,17 @@ function _android_build_opts_process_binaries {
|
||||
ANDROID_BUILD_OPTS+=("AR=${AR}")
|
||||
ANDROID_BUILD_OPTS+=("RANLIB=${RANLIB}")
|
||||
ANDROID_BUILD_OPTS+=("STRIP=${STRIP}")
|
||||
|
||||
|
||||
android_build_check_fail
|
||||
}
|
||||
|
||||
# Set the ANDROID_BUILD_OPTS variable to a bash array of configure options
|
||||
function android_build_opts {
|
||||
ANDROID_BUILD_OPTS=()
|
||||
|
||||
|
||||
_android_build_opts_process_binaries
|
||||
|
||||
local LIBS="-lc -lgcc -ldl -lc++_shared"
|
||||
local LIBS="-lc -lgcc -ldl -lm -llog -lc++_shared"
|
||||
local LDFLAGS="-L${ANDROID_BUILD_PREFIX}/lib"
|
||||
LDFLAGS+=" -L${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${TOOLCHAIN_CXXSTL}"
|
||||
CFLAGS+=" -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE"
|
||||
@ -212,7 +220,7 @@ function android_build_opts {
|
||||
ANDROID_BUILD_OPTS+=("CXXFLAGS=${CXXFLAGS} ${ANDROID_BUILD_EXTRA_CXXFLAGS}")
|
||||
ANDROID_BUILD_OPTS+=("LDFLAGS=${LDFLAGS} ${ANDROID_BUILD_EXTRA_LDFLAGS}")
|
||||
ANDROID_BUILD_OPTS+=("LIBS=${LIBS} ${ANDROID_BUILD_EXTRA_LIBS}")
|
||||
|
||||
|
||||
ANDROID_BUILD_OPTS+=("PKG_CONFIG_LIBDIR=${ANDROID_NDK_ROOT}/prebuilt/${HOST_PLATFORM}/lib/pkgconfig")
|
||||
ANDROID_BUILD_OPTS+=("PKG_CONFIG_PATH=${ANDROID_BUILD_PREFIX}/lib/pkgconfig")
|
||||
ANDROID_BUILD_OPTS+=("PKG_CONFIG_SYSROOT_DIR=${ANDROID_BUILD_SYSROOT}")
|
||||
@ -220,7 +228,7 @@ function android_build_opts {
|
||||
ANDROID_BUILD_OPTS+=("--with-sysroot=${ANDROID_BUILD_SYSROOT}")
|
||||
ANDROID_BUILD_OPTS+=("--host=${TOOLCHAIN_HOST}")
|
||||
ANDROID_BUILD_OPTS+=("--prefix=${ANDROID_BUILD_PREFIX}")
|
||||
|
||||
|
||||
android_build_check_fail
|
||||
}
|
||||
|
||||
@ -231,14 +239,14 @@ function android_build_opts {
|
||||
function android_build_verify_so {
|
||||
local soname="$1"
|
||||
shift # Get rid of first argument - the rest represent dependencies
|
||||
|
||||
|
||||
local sofile="${ANDROID_BUILD_PREFIX}/lib/${soname}"
|
||||
if [ ! -f "${sofile}" ]; then
|
||||
ANDROID_BUILD_FAIL+=("Found no library named ${soname}")
|
||||
ANDROID_BUILD_FAIL+=(" ${sofile}")
|
||||
fi
|
||||
android_build_check_fail
|
||||
|
||||
|
||||
if command -v readelf >/dev/null 2>&1 ; then
|
||||
local readelf_bin="readelf"
|
||||
elif command -v greadelf >/dev/null 2>&1 ; then
|
||||
@ -249,7 +257,7 @@ function android_build_verify_so {
|
||||
android_build_check_fail
|
||||
|
||||
local elfoutput=$(LC_ALL=C $readelf_bin -d ${sofile})
|
||||
|
||||
|
||||
local soname_regexp='soname: \[([[:alnum:]\.]+)\]'
|
||||
if [[ $elfoutput =~ $soname_regexp ]]; then
|
||||
local parsed_soname="${BASH_REMATCH[1]}"
|
||||
@ -261,13 +269,13 @@ function android_build_verify_so {
|
||||
ANDROID_BUILD_FAIL+=("Failed to meaningfully parse readelf output for library ${soname}:")
|
||||
ANDROID_BUILD_FAIL+=(" ${elfoutput}")
|
||||
fi
|
||||
|
||||
|
||||
for dep_soname do
|
||||
if [[ $elfoutput != *"library: [${dep_soname}]"* ]]; then
|
||||
ANDROID_BUILD_FAIL+=("Library ${soname} was expected to be linked to library with soname:")
|
||||
ANDROID_BUILD_FAIL+=(" ${dep_soname}")
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
android_build_check_fail
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function usage {
|
||||
echo "Usage ./build.sh [ arm | arm64 | x86 | x86_64 ]"
|
||||
}
|
||||
|
||||
# Use directory of current script as the build directory and working directory
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||
ANDROID_BUILD_DIR="$(pwd)"
|
||||
@ -10,12 +14,73 @@ source ${ANDROID_BUILD_DIR}/android_build_helper.sh
|
||||
# Choose a C++ standard library implementation from the ndk
|
||||
ANDROID_BUILD_CXXSTL="gnustl_shared_49"
|
||||
|
||||
BUILD_ARCH=$1
|
||||
|
||||
if [ -z $BUILD_ARCH ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $(uname | tr '[:upper:]' '[:lower:]') in
|
||||
linux*)
|
||||
export HOST_PLATFORM=linux-x86_64
|
||||
;;
|
||||
darwin*)
|
||||
export HOST_PLATFORM=darwin-x86_64
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported platform"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set default values used in ci builds
|
||||
|
||||
export NDK_VERSION=${NDK_VERSION:-android-ndk-r20}
|
||||
# With NDK r20, the minimum SDK version range is [16, 29].
|
||||
# SDK version 21 is the minimum version for 64-bit builds.
|
||||
export MIN_SDK_VERSION=${MIN_SDK_VERSION:-21}
|
||||
|
||||
# Set variables for each architecture
|
||||
HOST_ARM="arm-linux-androideabi"
|
||||
HOST_ARM64="aarch64-linux-android"
|
||||
HOST_X86="i686-linux-android"
|
||||
HOST_X86_64="x86_64-linux-android"
|
||||
|
||||
COMP_ARM="armv7a-linux-androideabi${MIN_SDK_VERSION}"
|
||||
COMP_ARM64="aarch64-linux-android${MIN_SDK_VERSION}"
|
||||
COMP_X86="i686-linux-android${MIN_SDK_VERSION}"
|
||||
COMP_X86_64="x86_64-linux-android${MIN_SDK_VERSION}"
|
||||
|
||||
CXXSTL_ARM="armeabi-v7a"
|
||||
CXXSTL_ARM64="arm64-v8a"
|
||||
CXXSTL_X86="x86"
|
||||
CXXSTL_X86_64="x86_64"
|
||||
|
||||
ARCH_ARM="arm"
|
||||
ARCH_ARM64="arm64"
|
||||
ARCH_X86="x86"
|
||||
ARCH_X86_64="x86_64"
|
||||
|
||||
if [ $BUILD_ARCH == "arm" ]; then
|
||||
android_build_arch $HOST_ARM $COMP_ARM $CXXSTL_ARM $ARCH_ARM
|
||||
elif [ $BUILD_ARCH == "x86" ]; then
|
||||
android_build_arch $HOST_X86 $COMP_X86 $CXXSTL_X86 $ARCH_X86
|
||||
elif [ $BUILD_ARCH == "arm64" ]; then
|
||||
android_build_arch $HOST_ARM64 $COMP_ARM64 $CXXSTL_ARM64 $ARCH_ARM64
|
||||
elif [ $BUILD_ARCH == "x86_64" ]; then
|
||||
android_build_arch $HOST_X86_64 $COMP_X86_64 $CXXSTL_X86_64 $ARCH_X86_64
|
||||
else
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set up android build environment and set ANDROID_BUILD_OPTS array
|
||||
android_build_env
|
||||
android_build_opts
|
||||
|
||||
# Use a temporary build directory
|
||||
cache="/tmp/android_build/${TOOLCHAIN_NAME}"
|
||||
cache="/tmp/android_build/${TOOLCHAIN_ARCH}"
|
||||
rm -rf "${cache}"
|
||||
mkdir -p "${cache}"
|
||||
|
||||
@ -56,7 +121,7 @@ LIBTOOL_EXTRA_LDFLAGS='-avoid-version'
|
||||
(android_build_verify_so ${VERIFY} &> /dev/null) || {
|
||||
rm -rf "${cache}/libzmq"
|
||||
(cp -r ../.. "${cache}/libzmq" && cd "${cache}/libzmq" && make clean)
|
||||
|
||||
|
||||
(cd "${cache}/libzmq" && ./autogen.sh \
|
||||
&& ./configure --quiet "${ANDROID_BUILD_OPTS[@]}" ${CURVE} --without-docs \
|
||||
&& make -j 4 \
|
||||
|
@ -1,69 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
NDK_VERSION=android-ndk-r20
|
||||
NDK_ABI_VERSION=4.9
|
||||
export NDK_VERSION=android-ndk-r20
|
||||
export ANDROID_NDK_ROOT="/tmp/${NDK_VERSION}"
|
||||
|
||||
if [ $TRAVIS_OS_NAME == "linux" ]
|
||||
then
|
||||
case $(uname | tr '[:upper:]' '[:lower:]') in
|
||||
linux*)
|
||||
HOST_PLATFORM=linux-x86_64
|
||||
elif [ $TRAVIS_OS_NAME == "osx" ]
|
||||
then
|
||||
;;
|
||||
darwin*)
|
||||
HOST_PLATFORM=darwin-x86_64
|
||||
else
|
||||
echo "Unsupported platform $TRAVIS_OS_NAME"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported platform"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -d "/tmp/${NDK_VERSION}" ] ; then
|
||||
if [ ! -d "${ANDROID_NDK_ROOT}" ]; then
|
||||
export FILENAME=$NDK_VERSION-$HOST_PLATFORM.zip
|
||||
|
||||
(cd '/tmp' \
|
||||
&& wget http://dl.google.com/android/repository/$FILENAME -O $FILENAME \
|
||||
&& wget http://dl.google.com/android/repository/$FILENAME -O $FILENAME &> /dev/null \
|
||||
&& unzip -q $FILENAME) || exit 1
|
||||
unset FILENAME
|
||||
fi
|
||||
|
||||
function _build_arch {
|
||||
export ANDROID_NDK_ROOT="/tmp/${NDK_VERSION}"
|
||||
export TOOLCHAIN_PATH="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
|
||||
export TOOLCHAIN_HOST=$1
|
||||
export TOOLCHAIN_COMP=$2
|
||||
export TOOLCHAIN_CXXSTL=$3
|
||||
export TOOLCHAIN_ARCH=$4
|
||||
export TOOLCHAIN_NAME="${TOOLCHAIN_HOST}-${NDK_ABI_VERSION}"
|
||||
|
||||
source ./build.sh
|
||||
}
|
||||
|
||||
# Define the minimum Android API level for the library to run.
|
||||
# With NDK r20, the minimum SDK version range is [16, 29]
|
||||
export MIN_SDK_VERSION="21"
|
||||
|
||||
HOST_ARM="arm-linux-androideabi"
|
||||
HOST_ARM64="aarch64-linux-android"
|
||||
HOST_X86="i686-linux-android"
|
||||
HOST_X86_64="x86_64-linux-android"
|
||||
|
||||
COMP_ARM="armv7a-linux-androideabi${MIN_SDK_VERSION}"
|
||||
COMP_ARM64="aarch64-linux-android${MIN_SDK_VERSION}"
|
||||
COMP_X86="i686-linux-android${MIN_SDK_VERSION}"
|
||||
COMP_X86_64="x86_64-linux-android${MIN_SDK_VERSION}"
|
||||
|
||||
CXXSTL_ARM="armeabi-v7a"
|
||||
CXXSTL_ARM64="arm64-v8a"
|
||||
CXXSTL_X86="x86"
|
||||
CXXSTL_X86_64="x86_64"
|
||||
|
||||
ARCH_ARM="arm"
|
||||
ARCH_ARM64="arm64"
|
||||
ARCH_X86="x86"
|
||||
ARCH_X86_64="x86_64"
|
||||
|
||||
_build_arch $HOST_ARM $COMP_ARM $CXXSTL_ARM $ARCH_ARM
|
||||
_build_arch $HOST_X86 $COMP_X86 $CXXSTL_X86 $ARCH_X86
|
||||
|
||||
if [[ $MIN_SDK_VERSION -ge 21 ]] ; then
|
||||
_build_arch $HOST_ARM64 $COMP_ARM64 $CXXSTL_ARM64 $ARCH_ARM64
|
||||
_build_arch $HOST_X86_64 $COMP_X86_64 $CXXSTL_X86_64 $ARCH_X86_64
|
||||
fi
|
||||
|
||||
./build.sh "arm"
|
||||
./build.sh "arm64"
|
||||
./build.sh "x86"
|
||||
./build.sh "x86_64"
|
||||
|
Loading…
Reference in New Issue
Block a user