From e79b8d47ab2cca7890ae9f1988d1fb13c7e589a2 Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Thu, 28 Mar 2024 21:58:08 +0800 Subject: [PATCH] allow switching msys2 environment in packaging script (#335) --- packages/msys/build-mingw.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/msys/build-mingw.sh b/packages/msys/build-mingw.sh index 0990dcff..7f85dc4b 100644 --- a/packages/msys/build-mingw.sh +++ b/packages/msys/build-mingw.sh @@ -3,7 +3,14 @@ set -euxo pipefail # Usage: -# packages/msys/build-x64.sh [-c|--clean] [-nd|--no-deps] [-t|--target-dir ] +# packages/msys/build-mingw.sh [-m|--msystem ] [-c|--clean] [-nd|--no-deps] [-t|--target-dir ] +# Options: +# -m, --msystem switch to other MSYS2 environment +# (MINGW32, MINGW64, UCRT64, CLANG32, CLANG64) +# MUST be used before other options +# -c, --clean clean build and package directories +# -nd, --no-deps skip dependency check +# -t, --target-dir set target directory for the packages source version.inc [[ -n "${APP_VERSION_SUFFIX}" ]] && APP_VERSION="${APP_VERSION}${APP_VERSION_SUFFIX}" @@ -13,6 +20,21 @@ if [[ ! -v MSYSTEM ]]; then exit 1 fi +if [[ $# -gt 1 && ($1 == "-m" || $1 == "--msystem") ]]; then + msystem=$2 + shift 2 + case "${msystem}" in + MINGW32|MINGW64|UCRT64|CLANG32|CLANG64) + export MSYSTEM="${msystem}" + exec /bin/bash --login "$0" "$@" + ;; + *) + echo "Invalid MSYSTEM: ${msystem}" + exit 1 + ;; + esac +fi + case "${MSYSTEM}" in MINGW32|CLANG32) # there is no UCRT32 NSIS_ARCH=x86