build-system: Use a list instead of string + regexp

There are actually more datatypes in bash than just strings. One can for
example hold a list of strings in a list, and use that to keep track of
what we're expected to do.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
This commit is contained in:
Anton Lundin 2018-06-18 22:25:11 +02:00 committed by Dirk Hohndel
parent c4bf9e6d6e
commit 1157ad3faf

View file

@ -110,22 +110,22 @@ if [ "$(which curl)" == "" ] ; then
else else
CURL="curl -O " CURL="curl -O "
fi fi
BUILD_COMMON="libzip libgit2 googlemaps" COMMON_PACKAGES=(libzip libgit2 googlemaps)
case ${PLATFORM} in case ${PLATFORM} in
scripts) scripts)
BUILD="${BUILD_COMMON} hidapi libcurl libusb openssl libssh2" PACKAGES=("${COMMON_PACKAGES[@]}" hidapi libcurl libusb openssl libssh2)
;; ;;
ios) ios)
BUILD="${BUILD_COMMON} libxslt" PACKAGES=("${COMMON_PACKAGES[@]}" libxslt)
;; ;;
android) android)
BUILD="${BUILD_COMMON} libxslt sqlite libxml2 openssl libftdi libusb" PACKAGES=("${COMMON_PACKAGES[@]}" libxslt sqlite libxml2 openssl libftdi libusb)
;; ;;
single) single)
BUILD="$3" PACKAGES=("$3")
;; ;;
singleAndroid) singleAndroid)
BUILD="$3" PACKAGES=("$3")
;; ;;
*) *)
echo "Unknown platform ${PLATFORM}, choose between native, ios or android" echo "Unknown platform ${PLATFORM}, choose between native, ios or android"
@ -139,58 +139,53 @@ set -e
# get ready to download needed sources # get ready to download needed sources
cd "${INSTDIR}" cd "${INSTDIR}"
if [[ "$BUILD" = *"libcurl"* ]]; then for package in "${PACKAGES[@]}" ; do
git_checkout_library libcurl $CURRENT_LIBCURL https://github.com/curl/curl.git case "$package" in
fi libcurl)
git_checkout_library libcurl $CURRENT_LIBCURL https://github.com/curl/curl.git
if [[ "$BUILD" = *"libgit2"* ]]; then ;;
git_checkout_library libgit2 $CURRENT_LIBGIT2 https://github.com/libgit2/libgit2.git libgit2)
fi git_checkout_library libgit2 $CURRENT_LIBGIT2 https://github.com/libgit2/libgit2.git
;;
if [[ "$BUILD" = *"libssh2"* ]]; then libssh2)
git_checkout_library libssh2 $CURRENT_LIBSSH2 https://github.com/libssh2/libssh2.git git_checkout_library libssh2 $CURRENT_LIBSSH2 https://github.com/libssh2/libssh2.git
fi ;;
libusb)
if [[ "$BUILD" = *"libusb"* ]]; then git_checkout_library libusb $CURRENT_LIBUSB https://github.com/libusb/libusb.git
git_checkout_library libusb $CURRENT_LIBUSB https://github.com/libusb/libusb.git ;;
fi libxml2)
git_checkout_library libxml2 $CURRENT_LIBXML2 https://github.com/GNOME/libxml2.git
if [[ "$BUILD" = *"libxml2"* ]];then ;;
git_checkout_library libxml2 $CURRENT_LIBXML2 https://github.com/GNOME/libxml2.git libxslt)
fi git_checkout_library libxslt $CURRENT_XSLT https://github.com/GNOME/libxslt.git
;;
if [[ "$BUILD" = *"libxslt"* ]]; then breeze-icons)
git_checkout_library libxslt $CURRENT_XSLT https://github.com/GNOME/libxslt.git git_checkout_library breeze-icons master https://github.com/kde/breeze-icons.git
fi ;;
googlemaps)
if [[ "$BUILD" = *"breeze-icons"* ]]; then git_checkout_library googlemaps master https://github.com/Subsurface-divelog/googlemaps.git
git_checkout_library breeze-icons master https://github.com/kde/breeze-icons.git ;;
fi hidapi)
git_checkout_library hidapi master https://github.com/signal11/hidapi.git
if [[ "$BUILD" = *"googlemaps"* ]]; then ;;
git_checkout_library googlemaps master https://github.com/Subsurface-divelog/googlemaps.git kirigami)
fi git_checkout_library kirigami $CURRENT_KIRIGAMI https://github.com/KDE/kirigami.git
;;
if [[ "$BUILD" = *"hidapi"* ]]; then openssl)
git_checkout_library hidapi master https://github.com/signal11/hidapi.git git_checkout_library openssl $CURRENT_OPENSSL https://github.com/openssl/openssl.git
fi ;;
libzip)
if [[ "$BUILD" = *"kirigami"* ]]; then curl_download_library libzip https://subsurface-divelog.org/downloads/ libzip-${CURRENT_LIBZIP}.tar.xz
git_checkout_library kirigami $CURRENT_KIRIGAMI https://github.com/KDE/kirigami.git ;;
fi libftdi)
curl_download_library libftdi1 https://www.intra2net.com/en/developer/libftdi/download/ libftdi1-${CURRENT_LIBFTDI}.tar.bz2
if [[ "$BUILD" = *"openssl"* ]]; then ;;
git_checkout_library openssl $CURRENT_OPENSSL https://github.com/openssl/openssl.git sqlite)
fi curl_download_library sqlite http://www.sqlite.org/2017/ sqlite-autoconf-${CURRENT_SQLITE}.tar.gz
;;
if [[ "$BUILD" = *"libzip"* ]]; then *)
curl_download_library libzip https://subsurface-divelog.org/downloads/ libzip-${CURRENT_LIBZIP}.tar.xz echo "unknown package \"$package\""
fi exit 1
;;
if [[ "$BUILD" = *"libftdi"* ]]; then esac
curl_download_library libftdi1 https://www.intra2net.com/en/developer/libftdi/download/ libftdi1-${CURRENT_LIBFTDI}.tar.bz2 done
fi
if [[ "$BUILD" = *"sqlite"* ]]; then
curl_download_library sqlite http://www.sqlite.org/2017/ sqlite-autoconf-${CURRENT_SQLITE}.tar.gz
fi