iOS: clean up build shell script

Address shell linter comments. Follow our usual naming for build dirs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-04-02 09:59:25 -07:00
parent 5178ea2d15
commit 6c5c2bfb18

View file

@ -41,7 +41,7 @@ done
# set up easy to use variables with the important paths # set up easy to use variables with the important paths
TOP=$(pwd) TOP=$(pwd)
SUBSURFACE_SOURCE=${TOP}/../../../subsurface SUBSURFACE_SOURCE=${TOP}/../../../subsurface
pushd ${SUBSURFACE_SOURCE}/.. pushd "$SUBSURFACE_SOURCE"/..
PARENT_DIR=$(pwd) PARENT_DIR=$(pwd)
popd popd
@ -49,7 +49,7 @@ popd
mkdir -p build-ios mkdir -p build-ios
IOS_QT=~/Qt IOS_QT=~/Qt
QT_VERSION=$(cd ${IOS_QT}; ls -d [1-9]* | awk -F. '{ printf("%02d.%02d.%02d\n", $1,$2,$3); }' | sort -n | tail -1 | sed -e 's/\.0/\./g;s/^0//') QT_VERSION=$(cd "$IOS_QT"; ls -d [1-9]* | awk -F. '{ printf("%02d.%02d.%02d\n", $1,$2,$3); }' | sort -n | tail -1 | sed -e 's/\.0/\./g;s/^0//')
if [ -z $QT_VERSION ] ; then if [ -z $QT_VERSION ] ; then
echo "Couldn't determine Qt version; giving up" echo "Couldn't determine Qt version; giving up"
@ -79,7 +79,7 @@ fi
# Build Subsurface-mobile by default # Build Subsurface-mobile by default
SUBSURFACE_MOBILE=1 SUBSURFACE_MOBILE=1
pushd ${SUBSURFACE_SOURCE} pushd "$SUBSURFACE_SOURCE"
bash scripts/mobilecomponents.sh bash scripts/mobilecomponents.sh
popd popd
@ -87,15 +87,15 @@ popd
# now build all the dependencies for the three relevant architectures (x86_64 is for the simulator) # now build all the dependencies for the three relevant architectures (x86_64 is for the simulator)
# get all 3rd part libraries # get all 3rd part libraries
../../scripts/get-dep-lib.sh ios ${PARENT_DIR} ../../scripts/get-dep-lib.sh ios "$PARENT_DIR"
for ARCH in $ARCHS; do for ARCH in $ARCHS; do
echo next building for $ARCH echo next building for $ARCH
INSTALL_ROOT=$PARENT_DIR/install-root/ios/$ARCH INSTALL_ROOT=$PARENT_DIR/install-root/ios/$ARCH
mkdir -p $INSTALL_ROOT/lib $INSTALL_ROOT/bin $INSTALL_ROOT/include mkdir -p "$INSTALL_ROOT"/lib "$INSTALL_ROOT"/bin "$INSTALL_ROOT"/include
PKG_CONFIG_LIBDIR=$INSTALL_ROOT/lib/pkgconfig PKG_CONFIG_LIBDIR="$INSTALL_ROOT"/lib/pkgconfig
declare -x PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR declare -x PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR
declare -x PREFIX=$INSTALL_ROOT declare -x PREFIX=$INSTALL_ROOT
@ -113,12 +113,12 @@ for ARCH in $ARCHS; do
fi fi
declare -x ARCH_NAME=$ARCH declare -x ARCH_NAME=$ARCH
declare -x SDK=$SDK_NAME declare -x SDK=$SDK_NAME
declare -x SDK_DIR=`xcrun --sdk $SDK_NAME --show-sdk-path` declare -x SDK_DIR=$(xcrun --sdk $SDK_NAME --show-sdk-path)
declare -x PLATFORM_DIR=`xcrun --sdk $SDK_NAME --show-sdk-platform-path` declare -x PLATFORM_DIR=$(xcrun --sdk $SDK_NAME --show-sdk-platform-path)
declare -x CC=`xcrun -sdk $SDK_NAME -find clang` declare -x CC=$(xcrun -sdk $SDK_NAME -find clang)
declare -x CXX=`xcrun -sdk $SDK_NAME -find clang++` declare -x CXX=$(xcrun -sdk $SDK_NAME -find clang++)
declare -x LD=`xcrun -sdk $SDK_NAME -find ld` declare -x LD=$(xcrun -sdk $SDK_NAME -find ld)
declare -x CFLAGS="-arch $ARCH_NAME -isysroot $SDK_DIR -miphoneos-version-min=6.0 -I$SDK_DIR/usr/include -fembed-bitcode" declare -x CFLAGS="-arch $ARCH_NAME -isysroot $SDK_DIR -miphoneos-version-min=6.0 -I$SDK_DIR/usr/include -fembed-bitcode"
declare -x CXXFLAGS="$CFLAGS" declare -x CXXFLAGS="$CFLAGS"
declare -x LDFLAGS="$CFLAGS -lsqlite3 -lpthread -lc++ -L$SDK_DIR/usr/lib -fembed-bitcode" declare -x LDFLAGS="$CFLAGS -lsqlite3 -lpthread -lc++ -L$SDK_DIR/usr/lib -fembed-bitcode"
@ -155,32 +155,32 @@ for ARCH in $ARCHS; do
fi fi
# the config.sub in libxslt is too old # the config.sub in libxslt is too old
pushd ${PARENT_DIR}/libxslt pushd "$PARENT_DIR"/libxslt
autoreconf --install autoreconf --install
popd popd
if [ ! -e $PKG_CONFIG_LIBDIR/libxslt.pc ] ; then if [ ! -e "$PKG_CONFIG_LIBDIR"/libxslt.pc ] ; then
mkdir -p ${PARENT_DIR}/libxslt/build-ios/$ARCH_NAME mkdir -p "$PARENT_DIR"/libxslt-build-$ARCH
pushd ${PARENT_DIR}/libxslt/build-ios/$ARCH_NAME pushd "$PARENT_DIR"/libxslt-build-$ARCH
${PARENT_DIR}/libxslt/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --without-python --without-crypto --enable-static --disable-shared "$PARENT_DIR"/libxslt/configure --host=$BUILDCHAIN --prefix="$PREFIX" --without-python --without-crypto --enable-static --disable-shared
make make
make install make install
popd popd
fi fi
if [ ! -e $PKG_CONFIG_LIBDIR/libzip.pc ] ; then if [ ! -e "$PKG_CONFIG_LIBDIR"/libzip.pc ] ; then
pushd ${PARENT_DIR}/libzip pushd "$PARENT_DIR"/libzip
# don't waste time on building command line tools, examples, manual, and regression tests - and don't build the BZIP2 support we don't need # don't waste time on building command line tools, examples, manual, and regression tests - and don't build the BZIP2 support we don't need
sed -i.bak 's/ADD_SUBDIRECTORY(src)//;s/ADD_SUBDIRECTORY(examples)//;s/ADD_SUBDIRECTORY(man)//;s/ADD_SUBDIRECTORY(regress)//' CMakeLists.txt sed -i.bak 's/ADD_SUBDIRECTORY(src)//;s/ADD_SUBDIRECTORY(examples)//;s/ADD_SUBDIRECTORY(man)//;s/ADD_SUBDIRECTORY(regress)//' CMakeLists.txt
mkdir -p ${PARENT_DIR}/libzip/build-ios/$ARCH_NAME mkdir -p "$PARENT_DIR"/libzip-build-$ARCH
pushd ${PARENT_DIR}/libzip/build-ios/$ARCH_NAME pushd "$PARENT_DIR"/libzip-build-$ARCH
cmake -DBUILD_SHARED_LIBS="OFF" \ cmake -DBUILD_SHARED_LIBS="OFF" \
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \ -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \ -DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_PREFIX_PATH=${PREFIX} \ -DCMAKE_PREFIX_PATH="$PREFIX" \
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE \ -DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE \
-DENABLE_OPENSSL=FALSE \ -DENABLE_OPENSSL=FALSE \
-DENABLE_GNUTLS=FALSE \ -DENABLE_GNUTLS=FALSE \
${PARENT_DIR}/libzip "$PARENT_DIR"/libzip
# quiet the super noise warnings # quiet the super noise warnings
sed -i.bak 's/C_FLAGS = /C_FLAGS = -Wno-nullability-completeness -Wno-expansion-to-defined /' lib/CMakeFiles/zip.dir/flags.make sed -i.bak 's/C_FLAGS = /C_FLAGS = -Wno-nullability-completeness -Wno-expansion-to-defined /' lib/CMakeFiles/zip.dir/flags.make
make make
@ -190,25 +190,25 @@ for ARCH in $ARCHS; do
popd popd
fi fi
pushd ${PARENT_DIR}/libgit2 pushd "$PARENT_DIR"/libgit2
# libgit2 with -Wall on iOS creates megabytes of warnings... # libgit2 with -Wall on iOS creates megabytes of warnings...
sed -i.bak 's/ADD_C_FLAG_IF_SUPPORTED(-W/# ADD_C_FLAG_IF_SUPPORTED(-W/' CMakeLists.txt sed -i.bak 's/ADD_C_FLAG_IF_SUPPORTED(-W/# ADD_C_FLAG_IF_SUPPORTED(-W/' CMakeLists.txt
popd popd
if [ ! -e $PKG_CONFIG_LIBDIR/libgit2.pc ] ; then if [ ! -e $PKG_CONFIG_LIBDIR/libgit2.pc ] ; then
mkdir -p ${PARENT_DIR}/libgit2/build-ios/$ARCH mkdir -p "$PARENT_DIR"/libgit2-build-$ARCH
pushd ${PARENT_DIR}/libgit2/build-ios/$ARCH pushd "$PARENT_DIR"/libgit2-build-$ARCH
cmake ${PARENT_DIR}/libgit2 \ cmake "$PARENT_DIR"/libgit2 \
-G "Unix Makefiles" \ -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS="OFF" \ -DBUILD_SHARED_LIBS="OFF" \
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \ -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \
-DSHA1_TYPE=builtin \ -DSHA1_TYPE=builtin \
-DBUILD_CLAR=OFF \ -DBUILD_CLAR=OFF \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \ -DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_PREFIX_PATH=${PREFIX} \ -DCMAKE_PREFIX_PATH="$PREFIX" \
-DCURL=OFF \ -DCURL=OFF \
-DUSE_SSH=OFF \ -DUSE_SSH=OFF \
${PARENT_DIR}/libgit2/ "$PARENT_DIR"/libgit2/
sed -i.bak 's/C_FLAGS = /C_FLAGS = -Wno-nullability-completeness -Wno-expansion-to-defined /' CMakeFiles/git2.dir/flags.make sed -i.bak 's/C_FLAGS = /C_FLAGS = -Wno-nullability-completeness -Wno-expansion-to-defined /' CMakeFiles/git2.dir/flags.make
make make
make install make install
@ -230,16 +230,16 @@ for ARCH in $ARCHS; do
autoreconf --install autoreconf --install
popd popd
fi fi
mkdir -p ${PARENT_DIR}/libdivecomputer-build-ios/$ARCH mkdir -p "$PARENT_DIR"/libdivecomputer-build-$ARCH
if [ ! -f ${PARENT_DIR}/libdivecomputer-build-ios/${ARCH}/git.SHA ] ; then if [ ! -f "$PARENT_DIR"/libdivecomputer-build-$ARCH/git.SHA ] ; then
echo "" > ${PARENT_DIR}/libdivecomputer-build-ios/${ARCH}/git.SHA echo "" > "$PARENT_DIR"/libdivecomputer-build-$ARCH/git.SHA
fi fi
CURRENT_SHA=$(cd ../../libdivecomputer ; git describe) CURRENT_SHA=$(cd ../../libdivecomputer ; git describe)
PREVIOUS_SHA=$(cat ${PARENT_DIR}/libdivecomputer-build-ios/${ARCH}/git.SHA) PREVIOUS_SHA=$(cat "$PARENT_DIR"/libdivecomputer-build-$ARCH/git.SHA)
if [ ! "$CURRENT_SHA" = "$PREVIOUS_SHA" ] ; then if [ ! "$CURRENT_SHA" = "$PREVIOUS_SHA" ] ; then
echo $CURRENT_SHA > ${PARENT_DIR}/libdivecomputer-build-ios/${ARCH}/git.SHA echo $CURRENT_SHA > "$PARENT_DIR"/libdivecomputer-build-$ARCH/git.SHA
pushd ${PARENT_DIR}/libdivecomputer-build-ios/$ARCH pushd "$PARENT_DIR"/libdivecomputer-build-$ARCH
${SUBSURFACE_SOURCE}/libdivecomputer/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --enable-static --disable-shared --enable-examples=no --without-libusb --without-hidapi --enable-ble ${SUBSURFACE_SOURCE}/libdivecomputer/configure --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared --enable-examples=no --without-libusb --without-hidapi --enable-ble
make make
make install make install
popd popd
@ -248,12 +248,12 @@ for ARCH in $ARCHS; do
done done
# build googlemaps # build googlemaps
mkdir -p ${PARENT_DIR}/googlemaps/build-ios mkdir -p "$PARENT_DIR"/googlemaps/build-ios
pushd ${PARENT_DIR}/googlemaps/build-ios pushd "$PARENT_DIR"/googlemaps/build-ios
${IOS_QT}/${QT_VERSION}/ios/bin/qmake ${PARENT_DIR}/googlemaps/googlemaps.pro CONFIG+=release "$IOS_QT"/"$QT_VERSION"/ios/bin/qmake "$PARENT_DIR"/googlemaps/googlemaps.pro CONFIG+=release
make make
if [ "$DEBUGRELEASE" != "Release" ] ; then if [ "$DEBUGRELEASE" != "Release" ] ; then
${IOS_QT}/${QT_VERSION}/ios/bin/qmake ${PARENT_DIR}/googlemaps/googlemaps.pro CONFIG+=debug "$IOS_QT"/"$QT_VERSION"/ios/bin/qmake "$PARENT_DIR"/googlemaps/googlemaps.pro CONFIG+=debug
make clean make clean
make make
fi fi
@ -261,21 +261,21 @@ popd
# now combine the libraries into fat libraries # now combine the libraries into fat libraries
ARCH_ROOT=$PARENT_DIR/install-root/ios ARCH_ROOT=$PARENT_DIR/install-root/ios
cp -a $ARCH_ROOT/x86_64/* $ARCH_ROOT cp -a "$ARCH_ROOT"/x86_64/* "$ARCH_ROOT"
if [ "$TARGET" = "iphoneos" ] ; then if [ "$TARGET" = "iphoneos" ] ; then
pushd $ARCH_ROOT/lib pushd "$ARCH_ROOT"/lib
for LIB in $(find . -type f -name \*.a); do for LIB in $(find . -type f -name \*.a); do
lipo $ARCH_ROOT/armv7/lib/$LIB $ARCH_ROOT/arm64/lib/$LIB $ARCH_ROOT/x86_64/lib/$LIB -create -output $LIB lipo "$ARCH_ROOT"/armv7/lib/"$LIB" "$ARCH_ROOT"/arm64/lib/"$LIB" "$ARCH_ROOT"/x86_64/lib/"$LIB" -create -output "$LIB"
done done
popd popd
fi fi
pushd ${SUBSURFACE_SOURCE}/translations pushd "$SUBSURFACE_SOURCE"/translations
SRCS=$(ls *.ts | grep -v source) SRCS=$(ls ./*.ts | grep -v source)
popd popd
mkdir -p build-ios/translations mkdir -p build-ios/translations
for src in $SRCS; do for src in $SRCS; do
${IOS_QT}/${QT_VERSION}/ios/bin/lrelease ${SUBSURFACE_SOURCE}/translations/$src -qm build-ios/translations/${src/.ts/.qm} "$IOS_QT"/"$QT_VERSION"/ios/bin/lrelease "$SUBSURFACE_SOURCE"/translations/"$src" -qm build-ios/translations/"${src/.ts/.qm}"
done done
# in order to be able to use xcode without going through Qt Creator # in order to be able to use xcode without going through Qt Creator
@ -293,10 +293,10 @@ for BUILD_NOW in $BUILD_LOOP; do
else else
DRCONFIG="release" DRCONFIG="release"
fi fi
BUILDX=build-Subsurface-mobile-Qt_$(echo ${QT_VERSION} | tr . _)_for_iOS-${BUILD_NOW} BUILDX=build-Subsurface-mobile-Qt_$(echo "$QT_VERSION" | tr . _)_for_iOS-"$BUILD_NOW"
mkdir -p ${BUILDX} mkdir -p "$BUILDX"
pushd ${BUILDX} pushd "$BUILDX"
${IOS_QT}/${QT_VERSION}/ios/bin/qmake ../Subsurface-mobile.pro \ "$IOS_QT"/"$QT_VERSION"/ios/bin/qmake ../Subsurface-mobile.pro \
-spec macx-ios-clang CONFIG+=$TARGET CONFIG+=$TARGET2 CONFIG+=$DRCONFIG -spec macx-ios-clang CONFIG+=$TARGET CONFIG+=$TARGET2 CONFIG+=$DRCONFIG
make make