mirror of
https://github.com/notwa/rc
synced 2024-06-30 19:07:11 -07:00
support newer versions of MSVC
also fix cygwin path-handling
This commit is contained in:
parent
4368771e02
commit
c7f26c3120
54
sh/compile
54
sh/compile
|
@ -48,37 +48,51 @@ compile() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# detect and setup MSVC.
|
|
||||||
local clarch
|
|
||||||
local arch
|
|
||||||
[ "$MSYSTEM" = MINGW64 ] && clarch="/amd64" || clarch=""
|
|
||||||
[ "$MSYSTEM" = MINGW64 ] && arch="x64" || arch="x86"
|
|
||||||
printf "%s\n" "/c/Program Files (x86)/Microsoft Visual Studio "*(On/N[1]) | read vc
|
|
||||||
vc="$vc/VC"
|
|
||||||
if [ -d "$vc/bin$clarch" ] && [ -e "${vc}/bin$clarch/$cl" ]; then
|
|
||||||
cl="${vc}/bin$clarch/cl"
|
|
||||||
vc="$vc"
|
|
||||||
|
|
||||||
local winkit
|
local winkit
|
||||||
printf "%s\n" "/c/Program Files (x86)/Windows Kits/"*(on/N[1]) | read -r winkit
|
printf "%s\n" "/c/Program Files (x86)/Windows Kits/"*(on/N[1]) | read -r winkit
|
||||||
[ -n "$winkit" ] || { echo "failed glob; missing winkit" >&2; return 1 }
|
[ -n "$winkit" ] || { echo "failed glob; missing winkit" >&2; return 1 }
|
||||||
printf "%s\n" "$winkit/Lib/"*(On/N[1]) | read -r winkit
|
printf "%s\n" "$winkit/Lib/"*(On/N[1]) | read -r winkit
|
||||||
[ -n "$winkit" ] || { echo "failed glob; missing winkit" >&2; return 1 }
|
[ -n "$winkit" ] || { echo "failed glob; missing winkit" >&2; return 1 }
|
||||||
|
|
||||||
|
# detect MSVC.
|
||||||
|
local clarch
|
||||||
|
local arch
|
||||||
|
local msvc_dig_deep
|
||||||
|
[ "$MSYSTEM" = MINGW64 ] && clarch="/amd64" || clarch=""
|
||||||
|
[ "$MSYSTEM" = MINGW64 ] && arch="x64" || arch="x86"
|
||||||
|
if [ -d "/c/Program Files (x86)/Microsoft Visual Studio" ]; then # 2017+
|
||||||
|
printf "%s\n" "/c/Program Files (x86)/Microsoft Visual Studio/20"*(On/N[1]) | read vc
|
||||||
|
printf "%s\n" "$vc"/*/VC | read vc
|
||||||
|
printf "%s\n" "$vc/Tools/MSVC/"*(On/N[1]) | read vc
|
||||||
|
msvc_dig_deep="yes"
|
||||||
|
else # older versions
|
||||||
|
printf "%s\n" "/c/Program Files (x86)/Microsoft Visual Studio "*(On/N[1]) | read vc
|
||||||
|
vc="$vc/VC"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# setup MSVC.
|
||||||
|
if [ -n "$msvc_dig_deep" ] && [ -e "$vc/bin/Host$arch/$arch/cl" ]; then
|
||||||
|
cl="$vc/bin/Host$arch/$arch/cl"
|
||||||
|
export PATH="$PATH:$vc/bin/Host$arch/$arch"
|
||||||
|
export LIB="$(cygpath -w "$vc/lib/$arch")"
|
||||||
|
export LIBPATH="$(cygpath -w "$vc/lib/$arch")"
|
||||||
|
elif [ -d "$vc/bin$clarch" ] && [ -e "$vc/bin$clarch/$cl" ]; then
|
||||||
|
cl="$vc/bin$clarch/cl"
|
||||||
export PATH="$PATH:$vc/bin$clarch"
|
export PATH="$PATH:$vc/bin$clarch"
|
||||||
export INCLUDE="$vc/INCLUDE;$vc/ATLMFC/INCLUDE;${winkit/Lib/Include}/ucrt"
|
export LIB="$(cygpath -w "$vc/LIB$clarch")"
|
||||||
export LIB="$vc/LIB$clarch;$vc/ATLMFC/LIB$clarch;$winkit/um/$arch;$winkit/ucrt/$arch"
|
export LIBPATH="$(cygpath -w "$vc/LIB$clarch")"
|
||||||
export LIBPATH="$vc/LIB$clarch;$vc/ATLMFC/LIB$clarch"
|
fi
|
||||||
|
|
||||||
|
# finish up.
|
||||||
|
if [ -n "$cl" ]; then
|
||||||
|
export INCLUDE="$(cygpath -w "$vc/INCLUDE")"
|
||||||
|
export INCLUDE="$INCLUDE;$(cygpath -w "${winkit/Lib/Include}/ucrt")"
|
||||||
|
export LIB="$LIB;$(cygpath -w "$winkit/um/$arch")"
|
||||||
|
export LIB="$LIB;$(cygpath -w "$winkit/ucrt/$arch")"
|
||||||
|
|
||||||
for d in "${(@s/;/)INCLUDE}"; do
|
for d in "${(@s/;/)INCLUDE}"; do
|
||||||
clang_flags+=(-I"$d")
|
clang_flags+=(-I"$d")
|
||||||
done
|
done
|
||||||
|
|
||||||
# convert msys2 paths to windows paths.
|
|
||||||
export INCLUDE="${${INCLUDE//\/c\//C:\\}//\//\\}"
|
|
||||||
export LIB="${${LIB//\/c\//C:\\}//\//\\}"
|
|
||||||
export LIBPATH="${${LIBPATH//\/c\//C:\\}//\//\\}"
|
|
||||||
|
|
||||||
# ignore MSVC's non-standard deprecation warnings.
|
# ignore MSVC's non-standard deprecation warnings.
|
||||||
clang_flags+=(-D_CRT_SECURE_NO_WARNINGS)
|
clang_flags+=(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user