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