Merge branch 'ninja' into 'master'
Enable Windows Ninja builds See merge request OpenMW/openmw!202 (cherry picked from commit e0b352323226ff11e230f6489e826df332fa681a) c1e673ce Unify path conversion functions fdf0fdbb Fix NMake with MSVC 2019 bdd4a814 Activate MSVC during CMake setup for NMake eae41050 Support sourcing c0d28a0e Warn that MSVC environment will need to be activated bd16ad62 Ninja 7d57e6e2 Support MSVC 2015 3679d329 Check MSVC activated correctly ed4b73b8 Fix post-2015 Visual Studio 4ffa116a Print message when it's necessary instead of when it isn't c6e09461 Add instructions for using VS' non-.sln support d9bb6e63 Activate MSVC later 9ca26358 Create batch script to activate correct MSVC 61df647d Provide scripts to activate selected MSVC in existing shell without kerfufflepull/578/head
parent
b168544445
commit
38daa83ff6
@ -0,0 +1,26 @@
|
||||
& "${env:COMSPEC}" /c ActivateMSVC.bat "&&" set | ForEach-Object {
|
||||
$name, $value = $_ -split '=', 2
|
||||
Set-Content env:\"$name" $value
|
||||
}
|
||||
|
||||
$MissingTools = $false
|
||||
$tools = "cl", "link", "rc", "mt", "awooga"
|
||||
$descriptions = "MSVC Compiler", "MSVC Linker", "MS Windows Resource Compiler", "MS Windows Manifest Tool", "A made up command"
|
||||
for ($i = 0; $i -lt $tools.Length; $i++) {
|
||||
$present = $true
|
||||
try {
|
||||
Get-Command $tools[$i] *>&1 | Out-Null
|
||||
$present = $present -and $?
|
||||
} catch {
|
||||
$present = $false
|
||||
}
|
||||
if (!$present) {
|
||||
Write-Warning "$($tools[$i]) ($($descriptions[$i])) missing."
|
||||
$MissingTools = $true
|
||||
}
|
||||
}
|
||||
|
||||
if ($MissingTools) {
|
||||
Write-Error "Some build tools were unavailable after activating MSVC in the shell. It's likely that your Visual Studio $MSVC_DISPLAY_YEAR installation needs repairing."
|
||||
exit 1
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
echo "Error: Script not sourced."
|
||||
echo "You must source this script for it to work, i.e. "
|
||||
echo "source ./activate_msvc.sh"
|
||||
echo "or"
|
||||
echo ". ./activate_msvc.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command -v unixPathAsWindows >/dev/null 2>&1 || function unixPathAsWindows {
|
||||
if command -v cygpath >/dev/null 2>&1; then
|
||||
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
|
||||
}
|
||||
|
||||
# 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 "$(unixPathAsWindows "$(dirname "${BASH_SOURCE[0]}")")\ActivateMSVC.bat" "&&" set)"
|
||||
|
||||
declare -A cmdEnvChanges
|
||||
for pair in $cmdEnv; do
|
||||
if [ -n "$pair" ]; then
|
||||
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
|
||||
fi
|
||||
done
|
||||
|
||||
MISSINGTOOLS=0
|
||||
|
||||
command -v cl >/dev/null 2>&1 || { echo "Error: cl (MSVC Compiler) missing."; MISSINGTOOLS=1; }
|
||||
command -v link >/dev/null 2>&1 || { echo "Error: link (MSVC Linker) missing."; MISSINGTOOLS=1; }
|
||||
command -v rc >/dev/null 2>&1 || { echo "Error: rc (MS Windows Resource Compiler) missing."; MISSINGTOOLS=1; }
|
||||
command -v mt >/dev/null 2>&1 || { echo "Error: mt (MS Windows Manifest Tool) missing."; MISSINGTOOLS=1; }
|
||||
|
||||
if [ $MISSINGTOOLS -ne 0 ]; then
|
||||
echo "Some build tools were unavailable after activating MSVC in the shell. It's likely that your Visual Studio $MSVC_DISPLAY_YEAR installation needs repairing."
|
||||
return 1
|
||||
fi
|
||||
|
||||
IFS="$originalIFS"
|
Loading…
Reference in New Issue