From f6bad1b6071005387e86c5206093198d814c663e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Jul 2022 23:27:21 +0300 Subject: [PATCH] build-cross-tools: Factorize the option handling, to ease handling more options --- build-cross-tools.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/build-cross-tools.sh b/build-cross-tools.sh index 1376ff1..57c901c 100755 --- a/build-cross-tools.sh +++ b/build-cross-tools.sh @@ -16,18 +16,35 @@ set -e -if [ $# -lt 3 ]; then +while [ $# -gt 0 ]; do + case "$1" in + --with-python) + PYTHON=1 + ;; + *) + if [ -z "$NATIVE" ]; then + NATIVE="$1" + elif [ -z "$PREFIX" ]; then + PREFIX="$1" + elif [ -z "$CROSS_ARCH" ]; then + CROSS_ARCH="$1" + else + echo Unrecognized parameter $1 + exit 1 + fi + ;; + esac + shift +done +if [ -z "$CROSS_ARCH" ]; then echo $0 native prefix arch [--with-python] exit 1 fi -NATIVE="$1" -PREFIX="$2" -CROSS_ARCH="$3" export PATH="$NATIVE/bin:$PATH" HOST=$CROSS_ARCH-w64-mingw32 -if [ "$4" = "--with-python" ]; then +if [ -n "$PYTHON" ]; then PYTHON_NATIVE_PREFIX="$(cd "$(dirname "$0")" && pwd)/python-native" [ -d "$PYTHON_NATIVE_PREFIX" ] || rm -rf "$PYTHON_NATIVE_PREFIX" ./build-python.sh $PYTHON_NATIVE_PREFIX