Inline mono_object_unbox_internal and mono_object_get_data. (#16856)
[mono-project.git] / msvc / mono-sgen-msvc.sh
bloba7e9ba44e9bd3719f320ac6a9ea75333e614125a
1 #!/bin/bash
3 # Wrapper that can be used as MONO_EXECUTABLE_WRAPPER in mono-wrapper when running MSVC build
4 # mono-sgen.exe. Simplify the setup of VS and MSVC toolchain, primarly when running MSVC build
5 # mono-sgen.exe as AOT compiler, since it needs to locate libraries as well as ClangC2 and linker
6 # from VS MSVC for corresponding architecture.
8 # NOTE, MSVC build mono-sgen.exe AOT compiler currently support 64-bit AMD codegen. mono-sgen-msvc.bat will ony setup
9 # amd64 versions of VS MSVC build environment and corresponding ClangC2 compiler.
11 # Optimization, only run full build environment when running mono-sgen.exe as AOT compiler.
12 # If not, just run mono-sgen.exe with supplied arguments.
14 function win32_format_path {
15 local formatted_path=$1
16 local host_win32_wsl=0
17 local host_win32_cygwin=0
19 host_uname="$(uname -a)"
20 case "$host_uname" in
21 *Microsoft*)
22 host_win32_wsl=1
24 CYGWIN*)
25 host_win32_cygwin=1
27 esac
29 if [[ $host_win32_wsl = 1 ]] && [[ $1 == "/mnt/"* ]]; then
30 formatted_path="$(wslpath -a -w "$1")"
31 elif [[ $host_win32_cygwin = 1 ]] && [[ $1 == "/cygdrive/"* ]]; then
32 formatted_path="$(cygpath -a -w "$1")"
35 echo "$formatted_path"
38 MONO_SGEN_MSVC_SCRIPT_PATH=$(cd "$(dirname "$0")"; pwd)
40 MONO_AS_AOT_COMPILER=0
41 if [[ "$@" =~ .*--aot[^-a-zA-Z0-9].*|.*--aot$ ]]; then
42 MONO_AS_AOT_COMPILER=1
45 if [[ $MONO_AS_AOT_COMPILER = 0 ]]; then
46 "$MONO_SGEN_MSVC_SCRIPT_PATH/mono-sgen.exe" "$@"
47 else
48 MONO_SGEN_MSVC_SCRIPT_PATH=$(win32_format_path "$MONO_SGEN_MSVC_SCRIPT_PATH/mono-sgen-msvc.bat")
50 WINDOWS_CMD=$(which cmd.exe)
51 if [ ! -f $WINDOWS_CMD ]; then
52 WINDOWS_CMD=$WINDIR/System32/cmd.exe
55 export MONO_AS_AOT_COMPILER
56 "$WINDOWS_CMD" /c "$MONO_SGEN_MSVC_SCRIPT_PATH" "$@"