#!/bin/bash # This configures the environment for running MSVC. It uses vswhere, the # registry, and a little knowledge of how MSVC is laid out.
if ! hash vswhere 2>/dev/null; then echo"Can't find vswhere on the path, aborting" 1>&2
exit 1 fi
if ! hash reg 2>/dev/null; then echo"Can't find reg on the path, aborting" 1>&2
exit 1 fi
# Turn a unix-y path into a windows one.
fixpath() { if hash cygpath 2>/dev/null; then
cygpath --unix "$1" else# haxx echo"$1" | sed -e 's,\\,/,g;s,^\(.\):,/\L\1,;s,/$,,' fi
}
# Query the registry. This takes $1 and tags that on the end of several # different paths, looking for a value called $2 at that location. # e.g., # regquery Microsoft\Microsoft SDKs\Windows\v10.0 ProductVersion # looks for a REG_SZ value called ProductVersion at # HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 # HKLU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 # etc...
regquery() {
search=("HKLM\\SOFTWARE\\Wow6432Node" \ "HKCU\\SOFTWARE\\Wow6432Node" \ "HKLM\\SOFTWARE" \ "HKCU\\SOFTWARE") for i in "${search[@]}"; do
r=$(reg query "${i}\\${1}" -v "$2" | sed -e 's/ *'"$2"' *REG_SZ *//;t;d') if [ -n "$r" ]; then echo"$r"
return 0 fi done
return 1
}
# Attempt to setup paths if vswhere returns something and VSPATH isn't set. # Otherwise, assume that the env is setup. if [[ -n "$vsinstall" && -z "$VSPATH" ]]; then
case "$target_arch" in
ia32) m=x86 ;;
x64) m="$target_arch" ;;
*) echo"No support for target '$target_arch' with MSVC." 1>&2
exit 1
esac
if [ "$m" == "x86" ]; then
PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/Hostx64/x64"
PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/Hostx64/x86" fi
PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/Host${m}/${m}"
PATH="${PATH}:${UniversalCRTSdkDir}/bin/${UCRTVersion}/${m}"
PATH="${PATH}:${WIN32_REDIST_DIR}" export PATH
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.