Skip to content
Snippets Groups Projects
Commit 7d5df5d6 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

build: add multi-arch and 64 bits support

    (cherry-picked from vlc-android commits:
        3ef336c2ac667932c36338efe65be6bda0515e75,
        ec890fd36a3a5410c8e6c5af6f67275dab4f9290,
        c8dccbaf8bc525b1084998da3535b8ea8aae9f3f,
        79740e9ffa7d30de28f3bc6e38163ee10ad78c0d,
        a62f5ad965ff08d9fb62a4594717065050a6871c)
parent c7fdfb40
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,17 @@ SFLPHONE_APK=$(SRC)/bin/SFLphone-debug.apk ...@@ -29,6 +29,17 @@ SFLPHONE_APK=$(SRC)/bin/SFLphone-debug.apk
NDK_DEBUG=1 NDK_DEBUG=1
endif endif
define build_apk
@echo
@echo "=== Building $(SFLPHONE_APK) for $(ARCH) ==="
@echo
date +"%Y-%m-%d" > $(SRC)/assets/builddate.txt
echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt
git rev-parse --short HEAD > $(SRC)/assets/revision.txt
./gen-env.sh $(SRC)
$(VERBOSE)cd $(SRC) && ant $(ANT_OPTS) $(ANT_TARGET)
endef
$(SFLPHONE_APK): $(LIBSFLPHONEJNI) $(JAVA_SOURCES) $(SFLPHONE_APK): $(LIBSFLPHONEJNI) $(JAVA_SOURCES)
@echo @echo
@echo "=== Building $@ for $(ARCH) ===" @echo "=== Building $@ for $(ARCH) ==="
...@@ -58,6 +69,9 @@ $(LIBSFLPHONEJNI): $(LIBSFLPHONEJNI_H) ...@@ -58,6 +69,9 @@ $(LIBSFLPHONEJNI): $(LIBSFLPHONEJNI_H)
NDK_DEBUG=$(NDK_DEBUG) \ NDK_DEBUG=$(NDK_DEBUG) \
TARGET_CFLAGS="$$SFLPHONE_EXTRA_CFLAGS" TARGET_CFLAGS="$$SFLPHONE_EXTRA_CFLAGS"
apk:
$(call build_apk)
apkclean: apkclean:
rm -f $(SFLPHONE_APK) rm -f $(SFLPHONE_APK)
......
...@@ -16,8 +16,9 @@ export PATH=$ANDROID_SDK/platform-tools:${PATH} ...@@ -16,8 +16,9 @@ export PATH=$ANDROID_SDK/platform-tools:${PATH}
install swig-2.0.6 or later and python-2.7 or later on your system install swig-2.0.6 or later and python-2.7 or later on your system
## Build instructions ## Build instructions
Supported archs are: armeabi-v7a, armeabi, arm64-v8a, x86, x86_64 or mips
export ANDROID_ABI=armeabi-v7a export ANDROID_ABI=[insert list of arch here with spaces]
./compile.sh ./compile.sh
We use a tested hash to build sflphone core, but if you want to use master: We use a tested hash to build sflphone core, but if you want to use master:
......
...@@ -6,32 +6,107 @@ ...@@ -6,32 +6,107 @@
set -e set -e
BUILD= if [ -z "$ANDROID_NDK" -o -z "$ANDROID_SDK" ]; then
FETCH= echo "You must define ANDROID_NDK, ANDROID_SDK and ANDROID_ABI before starting."
case "$1" in echo "They must point to your NDK and SDK directories.\n"
exit 1
fi
if [ -z "$ANDROID_ABI" ]; then
echo "Please set ANDROID_ABI to your architecture: armeabi-v7a, armeabi, arm64-v8a, x86, x86_64 or mips."
exit 1
fi
if [ -z "$NO_FPU" ];then
NO_FPU=0
fi
if [ -z "$NO_ARMV6" ];then
NO_ARMV6=0
fi
BUILD=0
FETCH=0
RELEASE=0
JNI=0
for i in ${@}; do
case "$i" in
--fetch) --fetch)
FETCH=1 FETCH=1
shift
;; ;;
--build) --build)
BUILD=1 BUILD=1
shift ;;
release|--release)
RELEASE=1
;;
jni|--jni)
JNI=1
;; ;;
*) *)
FETCH=1
BUILD=1
;; ;;
esac esac
done
if [ -z "$ANDROID_NDK" -o -z "$ANDROID_SDK" ]; then if [ "$BUILD" = 0 -a "$FETCH" = 0 ];then
echo "You must define ANDROID_NDK, ANDROID_SDK and ANDROID_ABI before starting." BUILD=1
echo "They must point to your NDK and SDK directories.\n" FETCH=1
exit 1
fi fi
if [ -z "$ANDROID_ABI" ]; then if [ `set -- ${ANDROID_ABI}; echo $#` -gt 1 ]; then
echo "Please set ANDROID_ABI to your architecture: armeabi-v7a, armeabi, x86 or mips." ANDROID_ABI_LIST="${ANDROID_ABI}"
exit 1 echo "More than one ABI specified: ${ANDROID_ABI_LIST}"
for i in ${ANDROID_ABI_LIST}; do
echo "$i starts building"
ANDROID_NDK=$ANDROID_NDK ANDROID_SDK=$ANDROID_SDK \
NO_FPU=$NO_FPU NO_ARMV6=$NO_ARMV6 ANDROID_ABI=$i \
./compile.sh $* --jni || { echo "$i build KO"; exit 1; }
mkdir -p obj/
cp -r sflphone-android/libs/$i obj
echo "$i build OK"
done
for i in ${ANDROID_ABI_LIST}; do
cp -r obj/$i sflphone-android/libs/
rm -rf obj/$i
done
make -b -j1 RELEASE=$RELEASE apk || exit 1
exit 0
fi
HAVE_ARM=0
HAVE_X86=0
HAVE_MIPS=0
HAVE_64=0
# Set up ABI variables
if [ ${ANDROID_ABI} = "x86" ] ; then
TARGET_TUPLE="i686-linux-android"
PATH_HOST="x86"
HAVE_X86=1
PLATFORM_SHORT_ARCH="x86"
elif [ ${ANDROID_ABI} = "x86_64" ] ; then
TARGET_TUPLE="x86_64-linux-android"
PATH_HOST="x86_64"
HAVE_X86=1
HAVE_64=1
PLATFORM_SHORT_ARCH="x86_64"
elif [ ${ANDROID_ABI} = "mips" ] ; then
TARGET_TUPLE="mipsel-linux-android"
PATH_HOST=$TARGET_TUPLE
HAVE_MIPS=1
PLATFORM_SHORT_ARCH="mips"
elif [ ${ANDROID_ABI} = "arm64-v8a" ] ; then
TARGET_TUPLE="aarch64-linux-android"
PATH_HOST=$TARGET_TUPLE
HAVE_ARM=1
HAVE_64=1
PLATFORM_SHORT_ARCH="arm64"
else
TARGET_TUPLE="arm-linux-androideabi"
PATH_HOST=$TARGET_TUPLE
HAVE_ARM=1
PLATFORM_SHORT_ARCH="arm"
fi fi
# try to detect NDK version # try to detect NDK version
...@@ -40,7 +115,7 @@ case "$REL" in ...@@ -40,7 +115,7 @@ case "$REL" in
10*) 10*)
if [ "${HAVE_64}" = 1 ];then if [ "${HAVE_64}" = 1 ];then
GCCVER=4.9 GCCVER=4.9
ANDROID_API=android-L ANDROID_API=android-21
else else
GCCVER=4.8 GCCVER=4.8
ANDROID_API=android-9 ANDROID_API=android-9
...@@ -66,24 +141,6 @@ export GCCVER ...@@ -66,24 +141,6 @@ export GCCVER
export CXXSTL export CXXSTL
export ANDROID_API export ANDROID_API
# Set up ABI variables
if [ ${ANDROID_ABI} = "x86" ] ; then
TARGET_TUPLE="i686-linux-android"
PATH_HOST="x86"
HAVE_X86=1
PLATFORM_SHORT_ARCH="x86"
elif [ ${ANDROID_ABI} = "mips" ] ; then
TARGET_TUPLE="mipsel-linux-android"
PATH_HOST=$TARGET_TUPLE
HAVE_MIPS=1
PLATFORM_SHORT_ARCH="mips"
else
TARGET_TUPLE="arm-linux-androideabi"
PATH_HOST=$TARGET_TUPLE
HAVE_ARM=1
PLATFORM_SHORT_ARCH="arm"
fi
# XXX : important! # XXX : important!
[ "$HAVE_ARM" = 1 ] && cat << EOF [ "$HAVE_ARM" = 1 ] && cat << EOF
For an ARMv6 device without FPU: For an ARMv6 device without FPU:
...@@ -99,6 +156,7 @@ export PATH_HOST ...@@ -99,6 +156,7 @@ export PATH_HOST
export HAVE_ARM export HAVE_ARM
export HAVE_X86 export HAVE_X86
export HAVE_MIPS export HAVE_MIPS
export HAVE_64
export PLATFORM_SHORT_ARCH export PLATFORM_SHORT_ARCH
# Add the NDK toolchain to the PATH, needed both for contribs and for building # Add the NDK toolchain to the PATH, needed both for contribs and for building
...@@ -168,8 +226,12 @@ elif [ ${ANDROID_ABI} = "armeabi" ] ; then ...@@ -168,8 +226,12 @@ elif [ ${ANDROID_ABI} = "armeabi" ] ; then
EXTRA_CFLAGS="-mfpu=vfp -mcpu=arm1136jf-s -mfloat-abi=softfp" EXTRA_CFLAGS="-mfpu=vfp -mcpu=arm1136jf-s -mfloat-abi=softfp"
fi fi
fi fi
elif [ ${ANDROID_ABI} = "arm64-v8a" ] ; then
EXTRA_CFLAGS=""
elif [ ${ANDROID_ABI} = "x86" ] ; then elif [ ${ANDROID_ABI} = "x86" ] ; then
EXTRA_CFLAGS="-march=pentium" EXTRA_CFLAGS="-march=pentium -m32"
elif [ ${ANDROID_ABI} = "x86_64" ] ; then
EXTRA_CFLAGS=""
elif [ ${ANDROID_ABI} = "mips" ] ; then elif [ ${ANDROID_ABI} = "mips" ] ; then
EXTRA_CFLAGS="-march=mips32 -mtune=mips32r2 -mhard-float" EXTRA_CFLAGS="-march=mips32 -mtune=mips32r2 -mhard-float"
# All MIPS Linux kernels since 2.4.4 will trap any unimplemented FPU # All MIPS Linux kernels since 2.4.4 will trap any unimplemented FPU
...@@ -185,7 +247,7 @@ EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CX ...@@ -185,7 +247,7 @@ EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CX
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}/include" EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}/include"
# Setup LDFLAGS # Setup LDFLAGS
EXTRA_LDFLAGS="-l${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}/libgnustl_static.a" EXTRA_LDFLAGS="-L${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI} -lgnustl_static"
# Make in // # Make in //
UNAMES=$(uname -s) UNAMES=$(uname -s)
...@@ -259,16 +321,20 @@ which autopoint >/dev/null || make $MAKEFLAGS .gettext ...@@ -259,16 +321,20 @@ which autopoint >/dev/null || make $MAKEFLAGS .gettext
export PATH="$PATH:$PWD/../$TARGET_TUPLE/bin" export PATH="$PATH:$PWD/../$TARGET_TUPLE/bin"
export SFLPHONE_BUILD_DIR=sflphone/daemon/build-android-${TARGET_TUPLE} export SFLPHONE_BUILD_DIR=sflphone/daemon/build-android-${TARGET_TUPLE}
############ ############
# Make SFLPHONE # # Make SFLPHONE #
############ ############
cd ../.. && mkdir -p build-android-${TARGET_TUPLE} && cd build-android-${TARGET_TUPLE} cd ../.. && mkdir -p build-android-${TARGET_TUPLE} && cd build-android-${TARGET_TUPLE}
if [ $# -eq 1 ] && [ "$1" = "jni" ]; then if [ "$JNI" = 1 ]; then
CLEAN="jniclean" CLEAN="jniclean"
TARGET="sflphone-android/obj/local/${ANDROID_ABI}/libsflphone.so" TARGET="sflphone-android/obj/local/${ANDROID_ABI}/libsflphone.so"
else else
CLEAN="distclean" CLEAN="distclean"
TARGET=
fi
if [ ! -f config.h ]; then if [ ! -f config.h ]; then
echo "Bootstraping" echo "Bootstraping"
cd ../ cd ../
...@@ -278,11 +344,35 @@ else ...@@ -278,11 +344,35 @@ else
./make-swig.sh ./make-swig.sh
cd ../sflphone/daemon/build-android-${TARGET_TUPLE} cd ../sflphone/daemon/build-android-${TARGET_TUPLE}
echo "Configuring" echo "Configuring"
echo `pwd`
${ANDROID_PATH}/configure.sh ${OPTS} ${ANDROID_PATH}/configure.sh ${OPTS}
fi fi
TARGET=
# ANDROID NDK FIXUP (BLAME GOOGLE)
config_undef ()
{
previous_change=`stat -c "%y" config.h`
sed -i 's,#define '$1' 1,/\* #undef '$1' \*/,' config.h
# don't change modified date in order to don't trigger a full build
touch -d "$previous_change" config.h
}
# if config dependencies change, ./config.status --recheck
# is run and overwrite previously hacked config.h. So call make Makefile here
# and hack config.h after.
make $MAKEFLAGS Makefile
if [ ${ANDROID_ABI} = "x86" -a ${ANDROID_API} != "android-21" ] ; then
# NDK x86 libm.so has nanf symbol but no nanf definition, we don't known if
# intel devices has nanf. Assume they don't have it.
config_undef HAVE_NANF
fi
if [ ${ANDROID_API} = "android-21" ] ; then
# android-21 has empty sys/shm.h headers that triggers shm detection but it
# doesn't have any shm functions and/or symbols. */
config_undef HAVE_SYS_SHM_H
fi fi
# END OF ANDROID NDK FIXUP
echo "Building libsflphone" echo "Building libsflphone"
make $MAKEFLAGS make $MAKEFLAGS
......
#!/bin/bash
# Simple script to generate env.txt
ENVTXT=$1/assets/env.txt
function optional_var {
echo -n "$1=" >> $ENVTXT
ONE=\$$1
T=`eval echo $ONE`
if [ -z "$T" ]; then
echo -n "0" >> $ENVTXT
else
echo -n "$T" >> $ENVTXT
fi
echo -n -e "\n" >> $ENVTXT
}
rm -f $ENVTXT
echo -e "ANDROID_ABI=$ANDROID_ABI" >> $ENVTXT
optional_var "NO_FPU"
optional_var "NO_ARMV6"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment