From 1569de761b45a78e742c67e99e27de4f0719e203 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 22 Nov 2024 22:14:05 +0100 Subject: [PATCH] Extract args processing in deps scripts Extract the code which process arguments to a function. This will make it optional, so that the script which just downloads the official adb binaries does not use arguments. --- app/deps/adb.sh | 1 + app/deps/common | 36 +++++++++++++++++++----------------- app/deps/ffmpeg.sh | 1 + app/deps/libusb.sh | 1 + app/deps/sdl.sh | 1 + 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/deps/adb.sh b/app/deps/adb.sh index b07f29b3..25727535 100755 --- a/app/deps/adb.sh +++ b/app/deps/adb.sh @@ -3,6 +3,7 @@ set -ex DEPS_DIR=$(dirname ${BASH_SOURCE[0]}) cd "$DEPS_DIR" . common +process_args "$@" VERSION=35.0.2 FILENAME=platform-tools_r$VERSION-win.zip diff --git a/app/deps/common b/app/deps/common index c1cc7729..6f8f80dc 100644 --- a/app/deps/common +++ b/app/deps/common @@ -1,25 +1,27 @@ #!/usr/bin/env bash # This file is intended to be sourced by other scripts, not executed -if [[ $# != 1 ]] -then - # : win32 or win64 - echo "Syntax: $0 " >&2 - exit 1 -fi +process_args() { + if [[ $# != 1 ]] + then + # : win32 or win64 + echo "Syntax: $0 " >&2 + exit 1 + fi -HOST="$1" + HOST="$1" -if [[ "$HOST" = win32 ]] -then - HOST_TRIPLET=i686-w64-mingw32 -elif [[ "$HOST" = win64 ]] -then - HOST_TRIPLET=x86_64-w64-mingw32 -else - echo "Unsupported host: $HOST" >&2 - exit 1 -fi + if [[ "$HOST" = win32 ]] + then + HOST_TRIPLET=i686-w64-mingw32 + elif [[ "$HOST" = win64 ]] + then + HOST_TRIPLET=x86_64-w64-mingw32 + else + echo "Unsupported host: $HOST" >&2 + exit 1 + fi +} DEPS_DIR=$(dirname ${BASH_SOURCE[0]}) cd "$DEPS_DIR" diff --git a/app/deps/ffmpeg.sh b/app/deps/ffmpeg.sh index 94fb06d2..20e59375 100755 --- a/app/deps/ffmpeg.sh +++ b/app/deps/ffmpeg.sh @@ -3,6 +3,7 @@ set -ex DEPS_DIR=$(dirname ${BASH_SOURCE[0]}) cd "$DEPS_DIR" . common +process_args "$@" VERSION=7.1 FILENAME=ffmpeg-$VERSION.tar.xz diff --git a/app/deps/libusb.sh b/app/deps/libusb.sh index 77a904b2..ee36d141 100755 --- a/app/deps/libusb.sh +++ b/app/deps/libusb.sh @@ -3,6 +3,7 @@ set -ex DEPS_DIR=$(dirname ${BASH_SOURCE[0]}) cd "$DEPS_DIR" . common +process_args "$@" VERSION=1.0.27 FILENAME=libusb-$VERSION.tar.gz diff --git a/app/deps/sdl.sh b/app/deps/sdl.sh index 1bdd9a4b..d8d0d734 100755 --- a/app/deps/sdl.sh +++ b/app/deps/sdl.sh @@ -3,6 +3,7 @@ set -ex DEPS_DIR=$(dirname ${BASH_SOURCE[0]}) cd "$DEPS_DIR" . common +process_args "$@" VERSION=2.30.9 FILENAME=SDL-$VERSION.tar.gz