From 568813b93bdd3f5f000bc4bdbc88e71f8158d9ca Mon Sep 17 00:00:00 2001 From: lateralusX Date: Thu, 2 May 2019 17:25:27 +0200 Subject: Add support for cygwin and WSL in helper build scripts. --- msvc/mono-sgen-msvc.sh | 33 +++++++++++++++++++++++++++++++-- msvc/run-msbuild.sh | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 4 deletions(-) (limited to 'msvc') diff --git a/msvc/mono-sgen-msvc.sh b/msvc/mono-sgen-msvc.sh index 03757366d09..29331667376 100755 --- a/msvc/mono-sgen-msvc.sh +++ b/msvc/mono-sgen-msvc.sh @@ -11,11 +11,40 @@ # Optimization, only run full build environment when running mono-sgen.exe as AOT compiler. # If not, just run mono-sgen.exe with supplied arguments. +function win32_format_path { + local formatted_path=$1 + local host_win32_wsl=0 + local host_win32_cygwin=0 + + host_uname="$(uname -a)" + case "$host_uname" in + *Microsoft*) + host_win32_wsl=1 + ;; + CYGWIN*) + host_win32_cygwin=1 + ;; + esac + + if [[ $host_win32_wsl = 1 ]] && [[ $1 == "/mnt/"* ]]; then + formatted_path="$(wslpath -a -w "$1")" + elif [[ $host_win32_cygwin = 1 ]] && [[ $1 == "/cygdrive/"* ]]; then + formatted_path="$(cygpath -a -w "$1")" + fi + + echo "$formatted_path" +} + MONO_SGEN_MSVC_SCRIPT_PATH=$(cd "$(dirname "$0")"; pwd) if [[ "$@" != *"--aot="* ]]; then "$MONO_SGEN_MSVC_SCRIPT_PATH/mono-sgen.exe" "$@" else - MONO_SGEN_MSVC_SCRIPT_PATH=$(cygpath -w "$MONO_SGEN_MSVC_SCRIPT_PATH/mono-sgen-msvc.bat") - "$WINDIR/System32/cmd.exe" /c "$MONO_SGEN_MSVC_SCRIPT_PATH" "$@" + MONO_SGEN_MSVC_SCRIPT_PATH=$(win32_format_path "$MONO_SGEN_MSVC_SCRIPT_PATH/mono-sgen-msvc.bat") + + WINDOWS_CMD=$(which cmd.exe) + if [ ! -f $WINDOWS_CMD ]; then + WINDOWS_CMD=$WINDIR/System32/cmd.exe + fi + "$WINDOWS_CMD" /c "$MONO_SGEN_MSVC_SCRIPT_PATH" "$@" fi diff --git a/msvc/run-msbuild.sh b/msvc/run-msbuild.sh index 7de93f0d9f4..d90d8ac1615 100755 --- a/msvc/run-msbuild.sh +++ b/msvc/run-msbuild.sh @@ -8,7 +8,36 @@ # $4 Additional arguments passed to msbuild, needs to be quoted if multiple. #------------------------------------------------------- +function win32_format_path { + local formatted_path=$1 + local host_win32_wsl=0 + local host_win32_cygwin=0 + + host_uname="$(uname -a)" + case "$host_uname" in + *Microsoft*) + host_win32_wsl=1 + ;; + CYGWIN*) + host_win32_cygwin=1 + ;; + esac + + if [[ $host_win32_wsl = 1 ]] && [[ $1 == "/mnt/"* ]]; then + formatted_path="$(wslpath -a -w "$1")" + elif [[ $host_win32_cygwin = 1 ]] && [[ $1 == "/cygdrive/"* ]]; then + formatted_path="$(cygpath -a -w "$1")" + fi + + echo "$formatted_path" +} + RUN_MSBUILD_SCRIPT_PATH=$(cd "$(dirname "$0")"; pwd) -RUN_MSBUILD_SCRIPT_PATH=$(cygpath -w "$RUN_MSBUILD_SCRIPT_PATH/run-msbuild.bat") +RUN_MSBUILD_SCRIPT_PATH=$(win32_format_path "$RUN_MSBUILD_SCRIPT_PATH/run-msbuild.bat") + +WINDOWS_CMD=$(which cmd.exe) +if [ ! -f $WINDOWS_CMD ]; then + WINDOWS_CMD=$WINDIR/System32/cmd.exe +fi -"$WINDIR/System32/cmd.exe" /c "$RUN_MSBUILD_SCRIPT_PATH" "$@" +"$WINDOWS_CMD" /c "$RUN_MSBUILD_SCRIPT_PATH" "$@" -- cgit v1.2.3