diff options
author | lateralusX <lateralusx.github@gmail.com> | 2019-05-02 18:25:27 +0300 |
---|---|---|
committer | lateralusX <lateralusx.github@gmail.com> | 2019-05-03 16:14:21 +0300 |
commit | 568813b93bdd3f5f000bc4bdbc88e71f8158d9ca (patch) | |
tree | a5c3bfee92be91cb58e2986f98c0f7cfbcdff60b /msvc/mono-sgen-msvc.sh | |
parent | 488e15e8ab3245bd6faca4f8388f3844d3066314 (diff) |
Add support for cygwin and WSL in helper build scripts.
Diffstat (limited to 'msvc/mono-sgen-msvc.sh')
-rwxr-xr-x | msvc/mono-sgen-msvc.sh | 33 |
1 files changed, 31 insertions, 2 deletions
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 |