Changeset 56b518d in subsurface


Ignore:
Timestamp:
Feb 6, 2017, 9:16:10 PM (5 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
97baf9b
Parents:
bed5ad3
git-author:
Anton Lundin <glance@…> (02/06/17 06:55:41)
git-committer:
Dirk Hohndel <dirk@…> (02/06/17 21:16:10)
Message:

android: Rework build.sh

This reworks build.sh for proper argument parsing and variable quoting.

Signed-off-by: Anton Lundin <glance@…>
Signed-off-by: Dirk Hohndel <dirk@…>

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • android-mobile/AndroidManifest.xml

    r54b97ec r56b518d  
    33    package="org.subsurfacedivelog.mobile"
    44    android:installLocation="auto"
    5     android:versionCode=@BUILD_NR@
    6     android:versionName=@SUBSURFACE_MOBILE_VERSION@ >
     5    android:versionCode="@BUILD_NR@"
     6    android:versionName="@SUBSURFACE_MOBILE_VERSION@" >
    77
    88    <application
  • packaging/android/build.sh

    r9d235d16 r56b518d  
    2222# Or just set QT5_ANDROID, ANDROID_SDK_ROOT and ANDROID_NDK_ROOT to where ever you have them.
    2323#
    24 set -e
     24set -eu
    2525PLATFORM=$(uname)
    2626# (trick to get the absolute path, either if we're called with a
     
    3030popd
    3131
     32# Set build defaults
    3233# is this a release or debug build
    3334BUILD_TYPE=Debug
    34 if [ "$1" = "release" ] || [ "$1" = "Release" ] ; then
    35         shift
    36         BUILD_TYPE=Release
    37 fi
    38 if [ "$1" = "debug" ] || [ "$1" = "Debug" ] ; then
    39         # this is the default - still need to eat the argument if given
    40         shift
    41 fi
    42 
    43 if [ "$1" = "-buildnr" ] ; then
    44         shift
    45         BUILD_NR="\"$1\""
    46         shift
    47 else
    48         BUILD_NR="\"0\""
    49 fi
     35# Build-nr in the android manifest.
     36BUILD_NR=0
     37# Should we build the desktop ui or the mobile ui?
     38SUBSURFACE_DESKTOP=OFF
     39# Which arch should we build for?
     40ARCH=arm
     41
     42while [ "$#" -gt 0 ] ; do
     43        case "$1" in
     44                Release|release)
     45                        shift
     46                        BUILD_TYPE=Release
     47                        ;;
     48                Debug|debug)
     49                        # this is the default - still need to eat the argument if given
     50                        BUILD_TYPE=Debug
     51                        shift
     52                        ;;
     53                -buildnr)
     54                        shift
     55                        BUILD_NR=$1
     56                        shift
     57                        ;;
     58                desktop)
     59                        SUBSURFACE_DESKTOP=ON
     60                        shift
     61                        ;;
     62                arm|x86)
     63                        ARCH=$1
     64                        shift
     65                ;;
     66        esac
     67done
     68
     69# Its needed by all sub-cmds
     70export ARCH
    5071
    5172# Configure where we can find things here
    5273export ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT-$SUBSURFACE_SOURCE/../android-ndk-r13b}
    5374
    54 if [ ! -z "$QT5_ANDROID" ] ; then
     75if [ -n "${QT5_ANDROID+X}" ] ; then
    5576        echo "Using Qt5 in $QT5_ANDROID"
    5677elif [ -d "$SUBSURFACE_SOURCE/../Qt/5.8" ] ; then
     
    85106LIBFTDI_VERSION=1.3
    86107
    87 # arm or x86
    88 if [ "$1" = "arm" ] || [ "$1" = "x86" ] ; then
    89         export ARCH=$1
    90         shift
    91 else
    92         export ARCH=arm
    93 fi
    94 
    95108if [ "$ARCH" = "arm" ] ; then
    96         QT_ARCH="armv7"
     109        QT_ARCH=armv7
    97110        BUILDCHAIN=arm-linux-androideabi
    98         OPENSSL_MACHINE="armv7"
     111        OPENSSL_MACHINE=armv7
    99112elif [ "$ARCH" = "x86" ] ; then
    100113        QT_ARCH=$ARCH
    101114        BUILDCHAIN=i686-linux-android
    102         OPENSSL_MACHINE="i686"
     115        OPENSSL_MACHINE=i686
    103116fi
    104117export QT5_ANDROID_BIN=${QT5_ANDROID}/android_${QT_ARCH}/bin
    105118
    106 if [ ! -e ndk-$ARCH ] ; then
    107         "$ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py" --arch=$ARCH --install-dir=ndk-$ARCH --api=16
     119if [ ! -e ndk-"$ARCH" ] ; then
     120        "$ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py" --arch="$ARCH" --install-dir=ndk-"$ARCH" --api=16
    108121fi
    109122export BUILDROOT=$PWD
     
    115128# autoconf seems to get lost without this
    116129export SYSROOT=${BUILDROOT}/ndk-$ARCH/sysroot
    117 export CFLAGS="--sysroot=${SYSROOT}"
    118 export CPPFLAGS="--sysroot=${SYSROOT}"
    119 export CXXFLAGS="--sysroot=${SYSROOT}"
     130export CFLAGS=--sysroot=${SYSROOT}
     131export CPPFLAGS=--sysroot=${SYSROOT}
     132export CXXFLAGS=--sysroot=${SYSROOT}
    120133# Junk needed for qt-android-cmake
    121134export ANDROID_STANDALONE_TOOLCHAIN=${BUILDROOT}/ndk-$ARCH
     
    134147fi
    135148if [ ! -e "$PKG_CONFIG_LIBDIR/sqlite3.pc" ] ; then
    136         mkdir -p sqlite-build-$ARCH
    137         pushd sqlite-build-$ARCH
     149        mkdir -p sqlite-build-"$ARCH"
     150        pushd sqlite-build-"$ARCH"
    138151        ../sqlite-autoconf-${SQLITE_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared
    139152        make
     
    149162fi
    150163if [ ! -e "$PKG_CONFIG_LIBDIR/libxml-2.0.pc" ] ; then
    151         mkdir -p libxml2-build-$ARCH
    152         pushd libxml2-build-$ARCH
     164        mkdir -p libxml2-build-"$ARCH"
     165        pushd libxml2-build-"$ARCH"
    153166        ../libxml2-${LIBXML2_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --without-python --without-iconv --enable-static --disable-shared
    154167        perl -pi -e 's/runtest\$\(EXEEXT\)//' Makefile
     
    168181fi
    169182if [ ! -e "$PKG_CONFIG_LIBDIR/libxslt.pc" ] ; then
    170         mkdir -p libxslt-build-$ARCH
    171         pushd libxslt-build-$ARCH
     183        mkdir -p libxslt-build-"$ARCH"
     184        pushd libxslt-build-"$ARCH"
    172185        ../libxslt-${LIBXSLT_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --with-libxml-prefix="$PREFIX" --without-python --without-crypto --enable-static --disable-shared
    173186        make
     
    183196fi
    184197if [ ! -e "$PKG_CONFIG_LIBDIR/libzip.pc" ] ; then
    185         mkdir -p libzip-build-$ARCH
    186         pushd libzip-build-$ARCH
     198        mkdir -p libzip-build-"$ARCH"
     199        pushd libzip-build-"$ARCH"
    187200        ../libzip-${LIBZIP_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared
    188201        make
     
    194207        wget -O openssl-${OPENSSL_VERSION}.tar.gz http://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
    195208fi
    196 if [ ! -e openssl-build-$ARCH ] ; then
     209if [ ! -e openssl-build-"$ARCH" ] ; then
    197210        tar -zxf openssl-${OPENSSL_VERSION}.tar.gz
    198         mv openssl-${OPENSSL_VERSION} openssl-build-$ARCH
     211        mv openssl-${OPENSSL_VERSION} openssl-build-"$ARCH"
    199212fi
    200213if [ ! -e "$PKG_CONFIG_LIBDIR/libssl.pc" ] ; then
    201         pushd openssl-build-$ARCH
     214        pushd openssl-build-"$ARCH"
    202215        perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
    203216        # Use env to make all these temporary, so they don't pollute later builds.
    204217        env SYSTEM=android \
    205                 CROSS_COMPILE="${BUILDCHAIN}-" \
     218                CROSS_COMPILE=${BUILDCHAIN}- \
    206219                MACHINE=$OPENSSL_MACHINE \
    207220                HOSTCC=gcc \
     
    227240        # We don't want to find the HTTP_Parser package of the build host by mistake
    228241        perl -pi -e 's/FIND_PACKAGE\(HTTP_Parser\)/#FIND_PACKAGE(HTTP_Parser)/' libgit2-${LIBGIT2_VERSION}/CMakeLists.txt
    229         mkdir -p libgit2-build-$ARCH
    230         pushd libgit2-build-$ARCH
     242        mkdir -p libgit2-build-"$ARCH"
     243        pushd libgit2-build-"$ARCH"
    231244        cmake -DCMAKE_SYSTEM_NAME=Android -DSHA1_TYPE=builtin \
    232245                -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=OFF \
     
    265278fi
    266279if [ ! -e "$PKG_CONFIG_LIBDIR/libusb-1.0.pc" ] ; then
    267         mkdir -p libusb-build-$ARCH
    268         pushd libusb-build-$ARCH
     280        mkdir -p libusb-build-"$ARCH"
     281        pushd libusb-build-"$ARCH"
    269282        ../libusb-${LIBUSB_VERSION}/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared --disable-udev --enable-system-log
    270283        # --enable-debug-log
     
    281294fi
    282295if [ ! -e "$PKG_CONFIG_LIBDIR/libftdi1.pc" ] && [ "$PLATFORM" != "Darwin" ] ; then
    283         mkdir -p libftdi1-build-$ARCH
    284         pushd libftdi1-build-$ARCH
     296        mkdir -p libftdi1-build-"$ARCH"
     297        pushd libftdi1-build-"$ARCH"
    285298        cmake ../libftdi1-${LIBFTDI_VERSION} -DCMAKE_C_COMPILER="$CC" -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" -DSTATICLIBS=ON -DPYTHON_BINDINGS=OFF -DDOCUMENTATION=OFF -DFTDIPP=OFF -DBUILD_TESTS=OFF -DEXAMPLES=OFF -DFTDI_EEPROM=OFF
    286299        make
     
    294307
    295308if [ ! -e "$PKG_CONFIG_LIBDIR/libdivecomputer.pc" ] ; then
    296         mkdir -p libdivecomputer-build-$ARCH
    297         pushd libdivecomputer-build-$ARCH
     309        mkdir -p libdivecomputer-build-"$ARCH"
     310        pushd libdivecomputer-build-"$ARCH"
    298311        "$SUBSURFACE_SOURCE"/../libdivecomputer/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared --enable-examples=no
    299312        make
     
    315328        SUBSURFACE_MOBILE=
    316329else
    317         SUBSURFACE_MOBILE="ON"
     330        SUBSURFACE_MOBILE=ON
    318331fi
    319332
     
    325338
    326339if [ ! -z "$SUBSURFACE_MOBILE" ] ; then
    327         mkdir -p subsurface-mobile-build-$ARCH
    328         cd subsurface-mobile-build-$ARCH
    329         MOBILE_CMAKE="-DSUBSURFACE_TARGET_EXECUTABLE=MobileExecutable"
    330 else
    331         mkdir -p subsurface-build-$ARCH
    332         cd subsurface-build-$ARCH
     340        mkdir -p subsurface-mobile-build-"$ARCH"
     341        cd subsurface-mobile-build-"$ARCH"
     342        MOBILE_CMAKE=-DSUBSURFACE_TARGET_EXECUTABLE=MobileExecutable
     343else
     344        MOBILE_CMAKE=""
     345        mkdir -p subsurface-build-"$ARCH"
     346        cd subsurface-build-"$ARCH"
    333347fi
    334348
     
    376390        rm -rf android-mobile
    377391        cp -a "$SUBSURFACE_SOURCE/android-mobile" .
    378         sed -i -e "s/@SUBSURFACE_MOBILE_VERSION@/\"$SUBSURFACE_MOBILE_VERSION\"/;s/@BUILD_NR@/$BUILD_NR/" android-mobile/AndroidManifest.xml
     392        sed -i -e "s/@SUBSURFACE_MOBILE_VERSION@/$SUBSURFACE_MOBILE_VERSION/;s/@BUILD_NR@/$BUILD_NR/" android-mobile/AndroidManifest.xml
    379393else
    380394        SUBSURFACE_VERSION=$(grep CANONICAL_VERSION_STRING ssrf-version.h | awk '{ print $3 }' | tr -d \")
Note: See TracChangeset for help on using the changeset viewer.