mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Create batch script to activate correct MSVC
This commit is contained in:
parent
d9bb6e63c6
commit
9ca26358bc
@ -872,7 +872,8 @@ fi
|
|||||||
for DLL in $RUNTIME_DLLS; do
|
for DLL in $RUNTIME_DLLS; do
|
||||||
TARGET="$(basename "$DLL")"
|
TARGET="$(basename "$DLL")"
|
||||||
if [[ "$DLL" == *":"* ]]; then
|
if [[ "$DLL" == *":"* ]]; then
|
||||||
IFS=':'; SPLIT=( ${DLL} ); unset IFS
|
originalIFS="$IFS"
|
||||||
|
IFS=':'; SPLIT=( ${DLL} ); IFS=$originalIFS
|
||||||
DLL=${SPLIT[0]}
|
DLL=${SPLIT[0]}
|
||||||
TARGET=${SPLIT[1]}
|
TARGET=${SPLIT[1]}
|
||||||
fi
|
fi
|
||||||
@ -900,19 +901,9 @@ if ! [ -z $ACTIVATE_MSVC ]; then
|
|||||||
echo "Activating MSVC in the current shell."
|
echo "Activating MSVC in the current shell."
|
||||||
command -v vswhere >/dev/null 2>&1 || { echo "Error: vswhere is not on the path."; wrappedExit 1; }
|
command -v vswhere >/dev/null 2>&1 || { echo "Error: vswhere is not on the path."; wrappedExit 1; }
|
||||||
|
|
||||||
# capture CMD environment so we know what's been changed
|
|
||||||
declare -A originalCmdEnv
|
|
||||||
originalIFS="$IFS"
|
|
||||||
IFS=$'\n\r'
|
|
||||||
for pair in $(cmd //c "set"); do
|
|
||||||
IFS='=' read -r -a separatedPair <<< "${pair}"
|
|
||||||
originalCmdEnv["${separatedPair[0]}"]="${separatedPair[1]}"
|
|
||||||
done
|
|
||||||
|
|
||||||
MSVC_INSTALLATION_PATH=$(vswhere -legacy -version "[$MSVC_VER,$(awk "BEGIN { print $MSVC_REAL_VER + 1; exit }"))" -property installationPath)
|
MSVC_INSTALLATION_PATH=$(vswhere -legacy -version "[$MSVC_VER,$(awk "BEGIN { print $MSVC_REAL_VER + 1; exit }"))" -property installationPath)
|
||||||
# capture CMD environment in a shell with MSVC activated
|
|
||||||
if [ $MSVC_REAL_VER -ge 15 ]; then
|
if [ $MSVC_REAL_VER -ge 15 ]; then
|
||||||
cmdEnv="$(cmd //c "${MSVC_INSTALLATION_PATH}\Common7\Tools\VsDevCmd.bat" -no_logo -arch=$([ $BITS -eq 64 ] && echo "amd64" || echo "x86") -host_arch=$([ $(uname -m) == 'x86_64' ] && echo "amd64" || echo "x86") "&&" set)"
|
echo "@\"${MSVC_INSTALLATION_PATH}\Common7\Tools\VsDevCmd.bat\" -no_logo -arch=$([ $BITS -eq 64 ] && echo "amd64" || echo "x86") -host_arch=$([ $(uname -m) == 'x86_64' ] && echo "amd64" || echo "x86")" > ActivateMSVC.bat
|
||||||
else
|
else
|
||||||
if [ $(uname -m) == 'x86_64' ]; then
|
if [ $(uname -m) == 'x86_64' ]; then
|
||||||
if [ $BITS -eq 64 ]; then
|
if [ $BITS -eq 64 ]; then
|
||||||
@ -927,19 +918,33 @@ if ! [ -z $ACTIVATE_MSVC ]; then
|
|||||||
compiler=x86
|
compiler=x86
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cmdEnv="$(cmd //c "${MSVC_INSTALLATION_PATH}\VC\vcvarsall.bat" $compiler "&&" set)"
|
echo "@\"${MSVC_INSTALLATION_PATH}\VC\vcvarsall.bat\" $compiler" > ActivateMSVC.bat
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# capture CMD environment so we know what's been changed
|
||||||
|
declare -A originalCmdEnv
|
||||||
|
originalIFS="$IFS"
|
||||||
|
IFS=$'\n\r'
|
||||||
|
for pair in $(cmd //c "set"); do
|
||||||
|
IFS='=' read -r -a separatedPair <<< "${pair}"
|
||||||
|
originalCmdEnv["${separatedPair[0]}"]="${separatedPair[1]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# capture CMD environment in a shell with MSVC activated
|
||||||
|
cmdEnv="$(cmd //c ActivateMSVC.bat "&&" set)"
|
||||||
|
|
||||||
declare -A cmdEnvChanges
|
declare -A cmdEnvChanges
|
||||||
for pair in $cmdEnv; do
|
for pair in $cmdEnv; do
|
||||||
IFS='=' read -r -a separatedPair <<< "${pair}"
|
if [ -n "$pair" ]; then
|
||||||
key="${separatedPair[0]}"
|
IFS='=' read -r -a separatedPair <<< "${pair}"
|
||||||
value="${separatedPair[1]}"
|
key="${separatedPair[0]}"
|
||||||
if ! [ ${originalCmdEnv[$key]+_} ] || [ "${originalCmdEnv[$key]}" != "$value" ]; then
|
value="${separatedPair[1]}"
|
||||||
if [ $key != 'PATH' ] && [ $key != 'path' ] && [ $key != 'Path' ]; then
|
if ! [ ${originalCmdEnv[$key]+_} ] || [ "${originalCmdEnv[$key]}" != "$value" ]; then
|
||||||
export "$key=$value"
|
if [ $key != 'PATH' ] && [ $key != 'path' ] && [ $key != 'Path' ]; then
|
||||||
else
|
export "$key=$value"
|
||||||
export PATH=$(windowsSystemPathAsUnix $value)
|
else
|
||||||
|
export PATH=$(windowsSystemPathAsUnix $value)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user