mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 10:33:52 +01:00
Merge pull request #4462 from stephan57160/master
Problem: Android build scripts need more enhancements.
This commit is contained in:
commit
037dd199af
@ -23,7 +23,7 @@ of platforms, where libzmq has been successfully compiled on.
|
||||
|
||||
| OS and version | Architecture | Compiler and version | Build system | Remarks |
|
||||
|----------------------------------------|-------------------------|-------------------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Android NDK r24 | arm, arm64, x86, x86_64 | llvm (see NDK) | autotools | DRAFT |
|
||||
| Android NDK r25 | 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 |
|
||||
|
@ -1,15 +1,31 @@
|
||||
# Android Build
|
||||
|
||||
## Prerequisites
|
||||
## Preamble
|
||||
|
||||
The last known NDK is automatically downloaded, if not specified otherwise.
|
||||
|
||||
As indicated in the main [README](../../README.md#supported-platforms-with-primary-CI), Android support is still DRAFT.
|
||||
|
||||
## Configuration
|
||||
|
||||
This project is tested against Android NDK version r25, but should
|
||||
support older ones too.
|
||||
### Basics
|
||||
|
||||
This project uses NDK `android-ndk-r25`, by default, but you can specify
|
||||
Basically, LIBZMQ build for Android, relies on exported variables.
|
||||
|
||||
Provided build scripts can mainly be used like
|
||||
|
||||
export XXX=xxx
|
||||
export YYY=yyy
|
||||
...
|
||||
cd <libzmq>/builds/android
|
||||
./<build_script>
|
||||
|
||||
|
||||
### Android NDK
|
||||
|
||||
LIBZMQ is tested against Android NDK versions r19 to r25.
|
||||
|
||||
By default, LIBZMQ uses NDK `android-ndk-r25`, but you can specify
|
||||
a different one:
|
||||
|
||||
export NDK_VERSION=android-ndk-r23c
|
||||
@ -18,7 +34,7 @@ If you already have installed your favorite NDK somewhere, all you have to
|
||||
do is to export and set NDK_VERSION and ANDROID_NDK_ROOT environment
|
||||
variables, e.g:
|
||||
|
||||
export NDK_VERSION=android-ndk-r23b
|
||||
export NDK_VERSION="android-ndk-r23b"
|
||||
export ANDROID_NDK_ROOT=$HOME/${NDK_VERSION}
|
||||
|
||||
**Important:** ANDROID_NDK_ROOT must be an absolute path !
|
||||
@ -38,14 +54,44 @@ To specify the build directory set the environment variable below:
|
||||
|
||||
**Important:** ANDROID_BUILD_ROOT must be an absolute path !
|
||||
|
||||
All libraries will be generated under:
|
||||
### Android build folder
|
||||
|
||||
All Android libraries will be generated under:
|
||||
|
||||
${ANDROID_BUILD_DIR}/prefix/<arch>/lib
|
||||
|
||||
where <_arch_> is one of `arm`, `arm64`, `x86` or `x86_64`.
|
||||
where <arch> is one of `arm`, `arm64`, `x86` or `x86_64`.
|
||||
|
||||
You can also check configuration variables in `build.sh` itself, in its
|
||||
"Configuration & tuning options" comment block.
|
||||
### Android build cleanup
|
||||
|
||||
Build and Dependency storage folders are automatically cleaned,
|
||||
by ci_build.sh. This can be avoided with the help of
|
||||
|
||||
ANDROID_BUILD_DIR="no"
|
||||
|
||||
If you turn this to "no", make sure to clean what has to be, before
|
||||
calling `build.sh` or `ci_build.sh`.
|
||||
|
||||
### Prebuilt Android libraries
|
||||
|
||||
Android prebuilt libraries have to be stored under
|
||||
|
||||
ANDROID_BUILD_DIR/prefix/<arch>/lib
|
||||
|
||||
Do not forget to disable [Android cleanup](#android-build-cleanup).
|
||||
|
||||
### Dependencies
|
||||
|
||||
By default, `build.sh` download dependencies under `/tmp/tmp-deps`.
|
||||
|
||||
You can specify another folder with the help of ANDROID_DEPENDENCIES_DIR:
|
||||
|
||||
ANDROID_DEPENDENCIES_DIR=${HOME}/my_dependencies
|
||||
|
||||
If you place your own dependency source trees there,
|
||||
do not forget to disable [Android cleanup](#android-build-cleanup).
|
||||
|
||||
### Cryptographic configuration
|
||||
|
||||
The variable CURVE accepts 3 different values:
|
||||
|
||||
@ -53,6 +99,11 @@ The variable CURVE accepts 3 different values:
|
||||
"libsodium" : LIBZMQ is built with LIBSODIUM encryption support (see below).
|
||||
"tweetnacl" : LIBZMQ is build with embedded encryption support.
|
||||
|
||||
### Other configuration variables
|
||||
|
||||
You can also check configuration variables in `build.sh` itself, in its
|
||||
"Configuration & tuning options" comment block.
|
||||
|
||||
## LIBSODIUM
|
||||
|
||||
LIBSODIUM is built along with LIBZMQ, when CURVE="libsodium".
|
||||
@ -69,19 +120,36 @@ official STABLE branch.
|
||||
See chapter [Configuration](#configuration) for configuration options and
|
||||
other details.
|
||||
|
||||
Select your prefered parameters:
|
||||
Select your preferred parameters:
|
||||
|
||||
export XXX=xxx
|
||||
export YYY=yyy
|
||||
...
|
||||
|
||||
And, in the android directory, run:
|
||||
and run:
|
||||
|
||||
cd <libzmq>/builds/android
|
||||
./build.sh [ arm | arm64 | x86 | x86_64 ]
|
||||
|
||||
Parameter selection and the calls to build.sh can be located in a
|
||||
SHELL script, like in ci_build.sh.
|
||||
|
||||
## CI build
|
||||
|
||||
Basically, it will call `build.sh` once, for each Android target.
|
||||
|
||||
This script accepts the same configuration variables, but some are set
|
||||
with different default values. For instance, the dependencies are not
|
||||
downloaded or cloned in `/tmp/tmp-deps, but inside LIBZMQ clone.
|
||||
|
||||
It can be used in the same way as build.sh
|
||||
|
||||
export XXX=xxx
|
||||
export YYY=yyy
|
||||
cd <libzmq>/builds/android
|
||||
./ci_build.sh
|
||||
|
||||
|
||||
## Dockerfile
|
||||
|
||||
An example of Docker file is provided, for Ubuntu 22.04
|
||||
|
@ -31,6 +31,7 @@
|
||||
#
|
||||
###
|
||||
#
|
||||
# Courtesy of Joe Eli McIlvain; original code at:
|
||||
# https://github.com/jemc/android_build_helper
|
||||
# android_build_helper.sh
|
||||
#
|
||||
@ -43,9 +44,11 @@
|
||||
# To get the latest version of this script, please download from:
|
||||
# https://github.com/jemc/android_build_helper
|
||||
#
|
||||
# You are free to modify this script, but if you add improvements,
|
||||
# please consider submitting a pull request to the aforementioned upstream
|
||||
# repository for the benefit of other users.
|
||||
# You are free to modify and redistribute this script, but if you add
|
||||
# improvements, please consider submitting a pull request or patch to the
|
||||
# aforementioned upstream repository for the benefit of other users.
|
||||
#
|
||||
# This script is provided with no express or implied warranties.
|
||||
#
|
||||
|
||||
########################################################################
|
||||
@ -81,8 +84,32 @@ function android_download_ndk {
|
||||
ANDROID_BUILD_FAIL+=(" $(dirname "${ANDROID_NDK_ROOT}/")")
|
||||
fi
|
||||
|
||||
if [ -z "${ANDROID_NDK_FILENAME}" ] ; then
|
||||
ANDROID_BUILD_FAIL+=("Please set the ANDROID_NDK_FILENAME environment variable")
|
||||
android_build_check_fail
|
||||
|
||||
local filename
|
||||
local platform="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||
case "${platform}" in
|
||||
linux*)
|
||||
if [ "${NDK_NUMBER}" -ge 2300 ] ; then
|
||||
# Since NDK 23, NDK archives are renamed.
|
||||
filename=${NDK_VERSION}-linux.zip
|
||||
else
|
||||
filename=${NDK_VERSION}-linux-x86_64.zip
|
||||
fi
|
||||
;;
|
||||
darwin*)
|
||||
if [ "${NDK_NUMBER}" -ge 2300 ] ; then
|
||||
# Since NDK 23, NDK archives are renamed.
|
||||
filename=${NDK_VERSION}-darwin.zip
|
||||
else
|
||||
filename=${NDK_VERSION}-darwin-x86_64.zip
|
||||
fi
|
||||
;;
|
||||
*) android_build_trace "Unsupported platform ('${platform}')" ; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ -z "${filename}" ] ; then
|
||||
ANDROID_BUILD_FAIL+=("Unable to detect NDK filename.")
|
||||
fi
|
||||
|
||||
android_build_check_fail
|
||||
@ -90,14 +117,14 @@ function android_download_ndk {
|
||||
android_build_trace "Downloading NDK '${NDK_VERSION}'..."
|
||||
(
|
||||
cd "$(dirname "${ANDROID_NDK_ROOT}")" \
|
||||
&& rm -f "${ANDROID_NDK_FILENAME}" \
|
||||
&& wget -q "http://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}" -O "${ANDROID_NDK_FILENAME}" \
|
||||
&& android_build_trace "Extracting NDK '${ANDROID_NDK_FILENAME}'..." \
|
||||
&& unzip -q "${ANDROID_NDK_FILENAME}" \
|
||||
&& rm -f "${filename}" \
|
||||
&& wget -q "http://dl.google.com/android/repository/${filename}" -O "${filename}" \
|
||||
&& android_build_trace "Extracting NDK '${filename}'..." \
|
||||
&& unzip -q "${filename}" \
|
||||
&& android_build_trace "NDK extracted under '${ANDROID_NDK_ROOT}'."
|
||||
) || {
|
||||
ANDROID_BUILD_FAIL+=("Failed to install NDK ('${NDK_VERSION}')")
|
||||
ANDROID_BUILD_FAIL+=(" ${ANDROID_NDK_FILENAME}")
|
||||
ANDROID_BUILD_FAIL+=(" ${filename}")
|
||||
}
|
||||
|
||||
android_build_check_fail
|
||||
@ -106,24 +133,12 @@ function android_download_ndk {
|
||||
function android_build_set_env {
|
||||
BUILD_ARCH=$1
|
||||
|
||||
platform="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||
local platform="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||
case "${platform}" in
|
||||
linux*)
|
||||
if [ "${NDK_NUMBER}" -ge 2300 ] ; then
|
||||
# Since NDK 23, NDK archives are renamed.
|
||||
export ANDROID_NDK_FILENAME=${NDK_VERSION}-linux.zip
|
||||
else
|
||||
export ANDROID_NDK_FILENAME=${NDK_VERSION}-linux-x86_64.zip
|
||||
fi
|
||||
export ANDROID_BUILD_PLATFORM=linux-x86_64
|
||||
;;
|
||||
darwin*)
|
||||
if [ "${NDK_NUMBER}" -ge 2300 ] ; then
|
||||
# Since NDK 23, NDK archives are renamed.
|
||||
export ANDROID_NDK_FILENAME=${NDK_VERSION}-darwin.zip
|
||||
else
|
||||
export ANDROID_NDK_FILENAME=${NDK_VERSION}-darwin-x86_64.zip
|
||||
fi
|
||||
export ANDROID_BUILD_PLATFORM=darwin-x86_64
|
||||
;;
|
||||
*) android_build_trace "Unsupported platform ('${platform}')" ; exit 1 ;;
|
||||
@ -157,9 +172,9 @@ function android_build_set_env {
|
||||
|
||||
# Since NDK r22 the "platforms" dir got removed
|
||||
if [ -d "${ANDROID_NDK_ROOT}/platforms" ]; then
|
||||
export ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/platforms/android-${MIN_SDK_VERSION}/arch-${TOOLCHAIN_ARCH}"
|
||||
export ANDROID_BUILD_SYSROOT="${ANDROID_NDK_ROOT}/platforms/android-${MIN_SDK_VERSION}/arch-${TOOLCHAIN_ARCH}"
|
||||
else
|
||||
export ANDROID_BUILD_SYSROOT="${ANDROID_BUILD_TOOLCHAIN}/sysroot"
|
||||
export ANDROID_BUILD_SYSROOT="${ANDROID_BUILD_TOOLCHAIN}/sysroot"
|
||||
fi
|
||||
export ANDROID_BUILD_PREFIX="${ANDROID_BUILD_DIR}/prefix/${TOOLCHAIN_ARCH}"
|
||||
|
||||
@ -167,10 +182,10 @@ function android_build_set_env {
|
||||
export ANDROID_STL="libc++_shared.so"
|
||||
if [ -x "${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${TOOLCHAIN_ABI}/${ANDROID_STL}" ] ; then
|
||||
export ANDROID_STL_ROOT="${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${TOOLCHAIN_ABI}"
|
||||
else
|
||||
else
|
||||
export ANDROID_STL_ROOT="${ANDROID_BUILD_SYSROOT}/usr/lib/${TOOLCHAIN_HOST}"
|
||||
|
||||
# NDK 25 requires -L<path-to-libc.so> ...
|
||||
# NDK 25 requires -L<path-to-libc.so> ...
|
||||
# I don't understand why, but without it, ./configure fails to build a valid 'conftest'.
|
||||
export ANDROID_LIBC_ROOT="${ANDROID_BUILD_SYSROOT}/usr/lib/${TOOLCHAIN_HOST}/${MIN_SDK_VERSION}"
|
||||
fi
|
||||
@ -445,46 +460,132 @@ function android_show_configure_opts {
|
||||
echo ""
|
||||
}
|
||||
|
||||
function android_clone_library {
|
||||
local tag="$1" ; shift
|
||||
local clone_root="$1" ; shift
|
||||
local clone_url="$1" ; shift
|
||||
local clone_branch="$1" ; shift
|
||||
# Initialize env variable XXX_ROOT, given dependency name "xxx".
|
||||
# If XXX_ROOT is not set:
|
||||
# If ${PROJECT_ROOT}/../xxx exists
|
||||
# set XXX_ROOT with it.
|
||||
# Else
|
||||
# set XXX_ROOT with ${ANDROID_DEPENDENCIES_DIR}/xxx.
|
||||
# Else
|
||||
# Verify that folder XXX_ROOT exists.
|
||||
function android_init_dependency_root {
|
||||
local lib_name
|
||||
lib_name="$1"
|
||||
local variable_name
|
||||
variable_name="$(echo "${lib_name}" | tr '[:lower:]' '[:upper:]')_ROOT"
|
||||
local variable_value
|
||||
variable_value="$(eval echo "\${${variable_name}}")"
|
||||
|
||||
mkdir -p "$(dirname "${clone_root}")"
|
||||
if [ -n "${clone_branch}" ] ; then
|
||||
android_build_trace "Cloning '${clone_url}' (branch '${clone_branch}') under '${clone_root}'."
|
||||
git clone --quiet --depth 1 -b "${clone_branch}" "${clone_url}" "${clone_root}"
|
||||
else
|
||||
android_build_trace "Cloning '${clone_url}' (default branch) under '${clone_root}'."
|
||||
git clone --quiet --depth 1 "${clone_url}" "${clone_root}"
|
||||
if [ -z "${PROJECT_ROOT}" ] ; then
|
||||
android_build_trace "Error: Variable PROJECT_ROOT is not set."
|
||||
exit 1
|
||||
fi
|
||||
( cd "${clone_root}" && git log --oneline -n 1) || exit 1
|
||||
if [ ! -d "${PROJECT_ROOT}" ] ; then
|
||||
android_build_trace "Error: Cannot find folder '${PROJECT_ROOT}'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${variable_value}" ] ; then
|
||||
if [ -d "${PROJECT_ROOT}/../${lib_name}" ] ; then
|
||||
eval "export ${variable_name}=\"$(cd "${PROJECT_ROOT}/../${lib_name}" && pwd)\""
|
||||
else
|
||||
eval "export ${variable_name}=\"${ANDROID_DEPENDENCIES_DIR}/${lib_name}\""
|
||||
fi
|
||||
variable_value="$(eval echo "\${${variable_name}}")"
|
||||
elif [ ! -d "${variable_value}" ] ; then
|
||||
android_build_trace "Error: Folder '${variable_value}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
android_build_trace "${variable_name}=${variable_value}"
|
||||
}
|
||||
|
||||
# Caller must set CONFIG_OPTS before call.
|
||||
function android_download_library {
|
||||
local tag="$1" ; shift
|
||||
local root="$1" ; shift
|
||||
local url="$1" ; shift
|
||||
local parent="$(dirname "${root}")"
|
||||
local archive="$(basename "${url}")"
|
||||
|
||||
mkdir -p "${parent}"
|
||||
cd "${parent}"
|
||||
|
||||
android_build_trace "Downloading ${tag} from '${url}' ..."
|
||||
rm -f "${archive}"
|
||||
wget -q "${url}"
|
||||
case "${archive}" in
|
||||
*."tar.gz" ) folder="$(basename "${archive}" ".tar.gz")" ;;
|
||||
*."tgz" ) folder="$(basename "${archive}" ".tgz")" ;;
|
||||
* ) android_build_trace "Unsupported extension for '${archive}'." ; exit 1 ;;
|
||||
esac
|
||||
android_build_trace "Extracting '${archive}' ..."
|
||||
tar -xzf "${archive}"
|
||||
if [ ! -d "${root}" ] ; then
|
||||
mv "${folder}" "${root}"
|
||||
fi
|
||||
android_build_trace "${tag} extracted under under '${root}'."
|
||||
}
|
||||
|
||||
function android_clone_library {
|
||||
local tag="$1" ; shift
|
||||
local root="$1" ; shift
|
||||
local url="$1" ; shift
|
||||
local branch="$1" ; shift
|
||||
|
||||
mkdir -p "$(dirname "${root}")"
|
||||
if [ -n "${branch}" ] ; then
|
||||
android_build_trace "Cloning '${url}' (branch '${branch}') under '${root}'."
|
||||
git clone --quiet --depth 1 -b "${branch}" "${url}" "${root}"
|
||||
else
|
||||
android_build_trace "Cloning '${url}' (default branch) under '${root}'."
|
||||
git clone --quiet --depth 1 "${url}" "${root}"
|
||||
fi
|
||||
( cd "${root}" && git log --oneline -n 1) || exit 1
|
||||
}
|
||||
|
||||
# Caller must set CONFIG_OPTS[], before call.
|
||||
function android_build_library {
|
||||
local tag=$1 ; shift
|
||||
local clone_root=$1 ; shift
|
||||
local root=$1 ; shift
|
||||
|
||||
android_build_trace "Cleaning library '${tag}'."
|
||||
(
|
||||
cd "${clone_root}" \
|
||||
&& ( make clean || : ) && \
|
||||
rm -f config.status
|
||||
) || exit 1
|
||||
if [ -n "${ANDROID_BUILD_PREFIX}" ] && [ -d "${ANDROID_BUILD_PREFIX}" ] ; then
|
||||
# Remove *.la files as they might cause errors with cross compiled libraries
|
||||
find "${ANDROID_BUILD_PREFIX}" -name '*.la' -exec rm {} +
|
||||
fi
|
||||
|
||||
cd "${root}" \
|
||||
&& ( make clean || : ) \
|
||||
&& rm -f config.status
|
||||
) &> /dev/null
|
||||
|
||||
android_build_trace "Building library '${tag}'."
|
||||
(
|
||||
# Remove *.la files as they might cause errors with cross compiled libraries
|
||||
find "${ANDROID_BUILD_PREFIX}" -name '*.la' -exec rm {} +
|
||||
set -e
|
||||
|
||||
cd "${clone_root}" \
|
||||
&& ./autogen.sh \
|
||||
&& android_show_configure_opts "${tag}" "${CONFIG_OPTS[@]}" \
|
||||
&& ./configure "${CONFIG_OPTS[@]}" \
|
||||
&& make -j 4 \
|
||||
&& make install
|
||||
) || exit 1
|
||||
android_show_configure_opts "${tag}" "${CONFIG_OPTS[@]}"
|
||||
|
||||
cd "${root}"
|
||||
if [ -e autogen.sh ]; then
|
||||
./autogen.sh 2> /dev/null
|
||||
fi
|
||||
if [ -e buildconf ]; then
|
||||
./buildconf 2> /dev/null
|
||||
fi
|
||||
if [ ! -e autogen.sh ] && [ ! -e buildconf ] && [ ! -e ./configure ] && [ -s ./configure.ac ] ; then
|
||||
libtoolize --copy --force && \
|
||||
aclocal -I . && \
|
||||
autoheader && \
|
||||
automake --add-missing --copy && \
|
||||
autoconf || \
|
||||
autoreconf -fiv
|
||||
fi
|
||||
|
||||
./configure "${CONFIG_OPTS[@]}"
|
||||
make -j 4
|
||||
make install
|
||||
)
|
||||
}
|
||||
|
||||
########################################################################
|
||||
@ -493,9 +594,12 @@ function android_build_library {
|
||||
# Get directory of current script (if not already set)
|
||||
# This directory is also the basis for the build directories the get created.
|
||||
if [ -z "$ANDROID_BUILD_DIR" ]; then
|
||||
ANDROID_BUILD_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
export ANDROID_BUILD_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
fi
|
||||
|
||||
# Where to download our dependencies
|
||||
export ANDROID_DEPENDENCIES_DIR="${ANDROID_DEPENDENCIES_DIR:-/tmp/tmp-deps}"
|
||||
|
||||
# Set up a variable to hold the global failure reasons, separated by newlines
|
||||
# (Empty string indicates no failure)
|
||||
ANDROID_BUILD_FAIL=()
|
||||
@ -503,13 +607,10 @@ ANDROID_BUILD_FAIL=()
|
||||
########################################################################
|
||||
# Sanity checks
|
||||
########################################################################
|
||||
if [ -z "${NDK_VERSION}" ] ; then
|
||||
android_build_trace "NDK_VERSION not set !"
|
||||
exit 1
|
||||
fi
|
||||
case "${NDK_VERSION}" in
|
||||
"android-ndk-r"[0-9][0-9] ) : ;;
|
||||
"android-ndk-r"[0-9][0-9][a-z] ) : ;;
|
||||
"" ) android_build_trace "Variable NDK_VERSION not set." ; exit 1 ;;
|
||||
* ) android_build_trace "Invalid format for NDK_VERSION ('${NDK_VERSION}')" ; exit 1 ;;
|
||||
esac
|
||||
|
||||
@ -522,7 +623,7 @@ fi
|
||||
# Compute NDK version into a numeric form:
|
||||
# android-ndk-r21e -> 2105
|
||||
# android-ndk-r25 -> 2500
|
||||
########################################################################
|
||||
########################################################################
|
||||
export NDK_NUMBER="$(( $(echo "${NDK_VERSION}"|sed -e 's|android-ndk-r||g' -e 's|[a-z]||g') * 100 ))"
|
||||
NDK_VERSION_LETTER="$(echo "${NDK_VERSION}"|sed -e 's|android-ndk-r[0-9][0-9]||g'|tr '[:lower:]' '[:upper:]')"
|
||||
if [ -n "${NDK_VERSION_LETTER}" ] ; then
|
||||
|
@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Exit if any step fails
|
||||
set -e
|
||||
|
||||
# Use directory of current script as the working directory
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||
LIBZMQ_ROOT="$(cd ../.. && pwd)"
|
||||
PROJECT_ROOT="$(cd ../.. && pwd)"
|
||||
|
||||
########################################################################
|
||||
# Configuration & tuning options.
|
||||
@ -25,8 +26,14 @@ export MIN_SDK_VERSION=${MIN_SDK_VERSION:-21}
|
||||
# ${ANDROID_BUILD_DIR}/prefix/<build_arch>/lib will contain produced libraries
|
||||
export ANDROID_BUILD_DIR="${ANDROID_BUILD_DIR:-${PWD}}"
|
||||
|
||||
# Where to download our dependencies: default to /tmp/tmp-deps
|
||||
export ANDROID_DEPENDENCIES_DIR="${ANDROID_DEPENDENCIES_DIR:-/tmp/tmp-deps}"
|
||||
|
||||
# Clean before processing
|
||||
export ANDROID_BUILD_CLEAN="${ANDROID_BUILD_CLEAN:-}"
|
||||
export ANDROID_BUILD_CLEAN="${ANDROID_BUILD_CLEAN:-no}"
|
||||
|
||||
# Set this to 'no', to enable verbose ./configure
|
||||
export CI_CONFIG_QUIET="${CI_CONFIG_QUIET:-no}"
|
||||
|
||||
# Select CURVE implementation:
|
||||
# - "" # Do not use any CURVE implementation.
|
||||
@ -34,12 +41,21 @@ export ANDROID_BUILD_CLEAN="${ANDROID_BUILD_CLEAN:-}"
|
||||
# - "tweetnacl" # Use internal TWEETNACL implementation.
|
||||
export CURVE="${CURVE:-}"
|
||||
|
||||
# By default, dependencies will be cloned to /tmp/tmp-deps.
|
||||
# If you have your own source tree for LIBSODIUM, uncomment
|
||||
# the line below, and provide its absolute path:
|
||||
# export LIBSODIUM_ROOT="<absolute_path_to_LIBSODIUM_source_tree>"
|
||||
|
||||
########################################################################
|
||||
# Utilities
|
||||
########################################################################
|
||||
# Get access to android_build functions and variables
|
||||
# Perform some sanity checks and calculate some variables.
|
||||
source "${PROJECT_ROOT}/builds/android/android_build_helper.sh"
|
||||
|
||||
function usage {
|
||||
echo "LIBZMQ - Usage:"
|
||||
echo " export XXX=yyy"
|
||||
echo " export XXX=xxx"
|
||||
echo " ./build.sh [ arm | arm64 | x86 | x86_64 ]"
|
||||
echo ""
|
||||
echo "See this file (configuration & tuning options) for details"
|
||||
@ -47,35 +63,6 @@ function usage {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Initialize env variable XXX_ROOT, given dependency name "xxx".
|
||||
# If XXX_ROOT is not set:
|
||||
# If a folder xxx exists close to current clone, set XXX_ROOT with it.
|
||||
# Else, set XXX_ROOT with /tmp/tmp-deps/xxx.
|
||||
# Else
|
||||
# Verify that folder XXX_ROOT exists.
|
||||
function init_dependency_root {
|
||||
local lib_name
|
||||
lib_name="$1"
|
||||
local variable_name
|
||||
variable_name="$(echo "${lib_name}" | tr '[:lower:]' '[:upper:]')_ROOT"
|
||||
local variable_value
|
||||
variable_value="$(eval echo "\${${variable_name}}")"
|
||||
|
||||
if [ -z "${variable_value}" ] ; then
|
||||
if [ -d "${LIBZMQ_ROOT}/../${lib_name}" ] ; then
|
||||
eval "export ${variable_name}=\"$(cd "${LIBZMQ_ROOT}/../${lib_name}" && pwd)\""
|
||||
else
|
||||
eval "export ${variable_name}=\"/tmp/tmp-deps/${lib_name}\""
|
||||
fi
|
||||
variable_value="$(eval echo "\${${variable_name}}")"
|
||||
elif [ ! -d "${variable_value}" ] ; then
|
||||
echo "LIBZMQ - Error: Folder '${variable_value}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "LIBZMQ - ${variable_name}=${variable_value}"
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# Sanity checks
|
||||
########################################################################
|
||||
@ -84,7 +71,8 @@ BUILD_ARCH="$1"
|
||||
|
||||
# Set ROOT path for LIBSODIUM source tree, if CURVE is "libsodium"
|
||||
if [ "${CURVE}x" = "libsodiumx" ] ; then
|
||||
init_dependency_root "libsodium"
|
||||
# Check or initialize LIBSODIUM_ROOT
|
||||
android_init_dependency_root "libsodium"
|
||||
fi
|
||||
|
||||
########################################################################
|
||||
@ -96,10 +84,6 @@ export ANDROID_BUILD_CXXSTL="gnustl_shared_49"
|
||||
# Additional flags for LIBTOOL, for LIBZMQ and other dependencies.
|
||||
export LIBTOOL_EXTRA_LDFLAGS='-avoid-version'
|
||||
|
||||
# Get access to android_build functions and variables
|
||||
# Perform some sanity checks and calculate some variables.
|
||||
source ./android_build_helper.sh
|
||||
|
||||
# Set up android build environment and set ANDROID_BUILD_OPTS array
|
||||
android_build_set_env "${BUILD_ARCH}"
|
||||
android_download_ndk
|
||||
@ -107,20 +91,20 @@ android_build_env
|
||||
android_build_opts
|
||||
|
||||
# Check for environment variable to clear the prefix and do a clean build
|
||||
if [[ $ANDROID_BUILD_CLEAN ]]; then
|
||||
if [ "${ANDROID_BUILD_CLEAN}" = "yes" ]; then
|
||||
android_build_trace "Doing a clean build (removing previous build and dependencies)..."
|
||||
rm -rf "${ANDROID_BUILD_PREFIX:-android-build-prefix-not-set}"/*
|
||||
rm -rf "${ANDROID_BUILD_PREFIX:?}"/*
|
||||
|
||||
# Called shells MUST not clean after ourselves !
|
||||
export ANDROID_BUILD_CLEAN=""
|
||||
export ANDROID_BUILD_CLEAN="no"
|
||||
fi
|
||||
|
||||
VERIFY=("libzmq.so")
|
||||
DEPENDENCIES=()
|
||||
if [ -z "${CURVE}" ]; then
|
||||
CURVE="--disable-curve"
|
||||
elif [ "${CURVE}" == "libsodium" ]; then
|
||||
CURVE="--with-libsodium=yes"
|
||||
VERIFY+=("libsodium.so")
|
||||
DEPENDENCIES+=("libsodium.so")
|
||||
##
|
||||
# Build LIBSODIUM from latest STABLE branch
|
||||
|
||||
@ -131,8 +115,9 @@ elif [ "${CURVE}" == "libsodium" ]; then
|
||||
|
||||
(
|
||||
CONFIG_OPTS=()
|
||||
CONFIG_OPTS+=("--quiet")
|
||||
[ "${CI_CONFIG_QUIET}" = "yes" ] && CONFIG_OPTS+=("--quiet")
|
||||
CONFIG_OPTS+=("${ANDROID_BUILD_OPTS[@]}")
|
||||
CONFIG_OPTS+=("--without-docs")
|
||||
CONFIG_OPTS+=("--disable-soname-versions")
|
||||
|
||||
android_build_library "LIBSODIUM" "${LIBSODIUM_ROOT}"
|
||||
@ -146,17 +131,15 @@ fi
|
||||
##
|
||||
# Build libzmq from local source
|
||||
|
||||
(android_build_verify_so "${VERIFY[@]}" &> /dev/null) || {
|
||||
(cd "${LIBZMQ_ROOT}" && ( make clean || : ) && rm -f ./config.status ) || exit 1
|
||||
|
||||
(android_build_verify_so "libzmq.so" "${DEPENDENCIES[@]}" &> /dev/null) || {
|
||||
(
|
||||
CONFIG_OPTS=()
|
||||
CONFIG_OPTS+=("--quiet")
|
||||
[ "${CI_CONFIG_QUIET}" = "yes" ] && CONFIG_OPTS+=("--quiet")
|
||||
CONFIG_OPTS+=("${ANDROID_BUILD_OPTS[@]}")
|
||||
CONFIG_OPTS+=("${CURVE}")
|
||||
CONFIG_OPTS+=("--without-docs")
|
||||
|
||||
android_build_library "LIBZMQ" "${LIBZMQ_ROOT}"
|
||||
android_build_library "LIBZMQ" "${PROJECT_ROOT}"
|
||||
) || exit 1
|
||||
}
|
||||
|
||||
@ -167,6 +150,9 @@ cp "${ANDROID_STL_ROOT}/${ANDROID_STL}" "${ANDROID_BUILD_PREFIX}/lib/."
|
||||
|
||||
##
|
||||
# Verify shared libraries in prefix
|
||||
for library in "libzmq.so" "${DEPENDENCIES[@]}" ; do
|
||||
android_build_verify_so "${library}"
|
||||
done
|
||||
|
||||
android_build_verify_so "${VERIFY[@]}" "${ANDROID_STL}"
|
||||
android_build_verify_so "libzmq.so" "${DEPENDENCIES[@]}" "${ANDROID_STL}"
|
||||
android_build_trace "Android build successful"
|
||||
|
@ -10,13 +10,20 @@ cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||
export NDK_VERSION="${NDK_VERSION:-android-ndk-r25}"
|
||||
export ANDROID_NDK_ROOT="${ANDROID_NDK_ROOT:-/tmp/${NDK_VERSION}}"
|
||||
export MIN_SDK_VERSION=${MIN_SDK_VERSION:-21}
|
||||
export ANDROID_BUILD_DIR="${ANDROID_BUILD_DIR:-${PWD}}"
|
||||
export ANDROID_BUILD_DIR="${ANDROID_BUILD_DIR:-${PWD}/.build}"
|
||||
export ANDROID_BUILD_CLEAN="${ANDROID_BUILD_CLEAN:-yes}"
|
||||
export ANDROID_DEPENDENCIES_DIR="${ANDROID_DEPENDENCIES_DIR:-${PWD}/.deps}"
|
||||
|
||||
# Cleanup.
|
||||
rm -rf /tmp/android_build/
|
||||
rm -rf "${PWD}/prefix"
|
||||
rm -rf /tmp/tmp-deps
|
||||
mkdir -p /tmp/tmp-deps
|
||||
if [ "${ANDROID_BUILD_CLEAN}" = "yes" ] ; then
|
||||
rm -rf "${ANDROID_BUILD_DIR}/prefix"
|
||||
mkdir -p "${ANDROID_BUILD_DIR}/prefix"
|
||||
rm -rf "${ANDROID_DEPENDENCIES_DIR}"
|
||||
mkdir -p "${ANDROID_DEPENDENCIES_DIR}"
|
||||
|
||||
# Called shells MUST not clean after ourselves !
|
||||
export ANDROID_BUILD_CLEAN="no"
|
||||
fi
|
||||
|
||||
./build.sh "arm"
|
||||
./build.sh "arm64"
|
||||
|
Loading…
Reference in New Issue
Block a user