mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
Activate MSVC during CMake setup for NMake
This commit is contained in:
parent
fdf0fdbb57
commit
bdd4a814f9
@ -33,7 +33,20 @@ function unixPathAsWindows {
|
||||
cygpath -w $1
|
||||
else
|
||||
echo "$1" | sed "s,^/\([^/]\)/,\\1:/," | sed "s,/,\\\\,g"
|
||||
fi
|
||||
}
|
||||
|
||||
function windowsSystemPathAsUnix {
|
||||
if command -v cygpath >/dev/null 2>&1; then
|
||||
cygpath -u -p $1
|
||||
else
|
||||
IFS=';' read -r -a paths <<< "$1"
|
||||
declare -a convertedPaths
|
||||
for entry in paths; do
|
||||
convertedPaths+=(windowsPathAsUnix $entry)
|
||||
done
|
||||
convertedPath=printf ":%s" ${convertedPaths[@]}
|
||||
echo ${convertedPath:1}
|
||||
fi
|
||||
}
|
||||
|
||||
@ -54,6 +67,8 @@ CONFIGURATION=""
|
||||
TEST_FRAMEWORK=""
|
||||
GOOGLE_INSTALL_ROOT=""
|
||||
|
||||
ACTIVATE_MSVC=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
ARGSTR=$1
|
||||
shift
|
||||
@ -139,7 +154,7 @@ EOF
|
||||
done
|
||||
|
||||
if [ -n "$NMAKE" ]; then
|
||||
command -v nmake -? >/dev/null 2>&1 || { echo "Error: nmake (NMake) is not on the path. Make sure you have the necessary environment variables set for command-line C++ development (for example, by starting from a Developer Command Prompt)."; exit 1; }
|
||||
ACTIVATE_MSVC=true
|
||||
fi
|
||||
|
||||
if [ -z $VERBOSE ]; then
|
||||
@ -385,6 +400,44 @@ echo "Starting prebuild on MSVC${MSVC_DISPLAY_YEAR} WIN${BITS}"
|
||||
echo "==================================="
|
||||
echo
|
||||
|
||||
if ! [ -z $ACTIVATE_MSVC ]; then
|
||||
echo "Activating MSVC in the current shell."
|
||||
command -v vswhere >/dev/null 2>&1 || { echo "Error: vswhere is not on the path."; exit 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 -property installationPath)
|
||||
# capture CMD environment in a shell with MSVC activated
|
||||
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)"
|
||||
else
|
||||
echo "MSVC 2015 and older not yet supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -A cmdEnvChanges
|
||||
for pair in $cmdEnv; do
|
||||
IFS='=' read -r -a separatedPair <<< "${pair}"
|
||||
key="${separatedPair[0]}"
|
||||
value="${separatedPair[1]}"
|
||||
if ! [ ${originalCmdEnv[$key]+_} ] || [ "${originalCmdEnv[$key]}" != "$value" ]; then
|
||||
if [ $key != 'PATH' ] && [ $key != 'path' ] && [ $key != 'Path' ]; then
|
||||
export "$key=$value"
|
||||
else
|
||||
export PATH=$(windowsSystemPathAsUnix $value)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$originalIFS"
|
||||
fi
|
||||
|
||||
# cd OpenMW/AppVeyor-test
|
||||
mkdir -p deps
|
||||
cd deps
|
||||
|
Loading…
Reference in New Issue
Block a user