Skip to content

Commit 97c703c

Browse files
committed
Update msvs-detect to 0.6.0
1 parent 96689b1 commit 97c703c

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

msvs-detect

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ################################################################################################ #
55
# Microsoft C Compiler Environment Detection Script #
66
# ################################################################################################ #
7-
# Copyright (c) 2016, 2017, 2018, 2019, 2020 MetaStack Solutions Ltd. #
7+
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021 MetaStack Solutions Ltd. #
88
# ################################################################################################ #
99
# Author: David Allsopp #
1010
# 16-Feb-2016 #
@@ -27,7 +27,7 @@
2727
# of this software, even if advised of the possibility of such damage. #
2828
# ################################################################################################ #
2929

30-
VERSION=0.4.1
30+
VERSION=0.6.0
3131

3232
# debug [level=2] message
3333
debug ()
@@ -204,13 +204,6 @@ SCAN_ENV=0
204204
# Various PATH messing around means it's sensible to know where tools are now
205205
WHICH=$(which which)
206206

207-
if [[ $(uname --operating-system 2>/dev/null) = "Msys" ]] ; then
208-
# Prevent MSYS from translating command line switches to paths
209-
SWITCH_PREFIX='//'
210-
else
211-
SWITCH_PREFIX='/'
212-
fi
213-
214207
# Parse command-line. At the moment, the short option which usefully combines with anything is -d,
215208
# so for the time being, combining short options is not permitted, as the loop becomes even less
216209
# clear with getopts. GNU getopt isn't installed by default on Cygwin...
@@ -337,7 +330,7 @@ if [[ $MODE -eq 1 ]] ; then
337330
MSVS_PREFERENCE=
338331
SCAN_ENV=1
339332
elif [[ -z ${MSVS_PREFERENCE+x} ]] ; then
340-
MSVS_PREFERENCE='@;VS16.*;VS15.*;VS14.0;VS12.0;VS11.0;10.0;9.0;8.0;7.1;7.0'
333+
MSVS_PREFERENCE='@;VS17.*;VS16.*;VS15.*;VS14.0;VS12.0;VS11.0;10.0;9.0;8.0;7.1;7.0'
341334
fi
342335

343336
MSVS_PREFERENCE=${MSVS_PREFERENCE//;/ }
@@ -480,6 +473,9 @@ COMPILERS=(
480473
["VS16.*"]='(
481474
["NAME"]="Visual Studio 2019"
482475
["VSWHERE"]="1")'
476+
["VS17.*"]='(
477+
["NAME"]="Visual Studio 2022"
478+
["VSWHERE"]="1")'
483479
["SDK5.2"]='(
484480
["NAME"]="Windows Server 2003 SP1 SDK"
485481
["VC_VER"]="8.0"
@@ -733,7 +729,7 @@ if [[ -x $VSWHERE ]] ; then
733729
warning "vcvarsall.bat not found for $INSTANCE"
734730
fi;;
735731
esac
736-
done < <("$VSWHERE" -all -nologo | tr -d '\r')
732+
done < <("$VSWHERE" -all -products '*' -nologo | tr -d '\r')
737733
fi
738734

739735
if [[ $DEBUG -gt 1 ]] ; then
@@ -920,6 +916,8 @@ for i in "${TEST[@]}" ; do
920916
if [[ $DEBUG -gt 3 ]] ; then
921917
printf "Scanning %s... " "$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES">&2
922918
fi
919+
# Setting MSYS2_ARG_CONV_EXCL to * inhibits attempts to convert the flags to COMSPEC as
920+
# command line parameters.
923921
num=0
924922
while IFS= read -r line; do
925923
case $num in
@@ -933,7 +931,8 @@ for i in "${TEST[@]}" ; do
933931
((num++))
934932
done < <(INCLUDE='' LIB='' PATH="?msvs-detect?:$DIR:$PATH" ORIGINALPATH='' \
935933
EXEC_SCRIPT="$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES" \
936-
$(cygpath "$COMSPEC") ${SWITCH_PREFIX}v:on ${SWITCH_PREFIX}c $COMMAND 2>/dev/null | grep -F XMARKER -A 3 | tr -d '\015' | tail -3)
934+
MSYS2_ARG_CONV_EXCL='*' \
935+
$(cygpath "$COMSPEC") /v:on /c $COMMAND 2>/dev/null | grep -F XMARKER -A 3 | tr -d '\015' | tail -3)
937936
if [[ $DEBUG -gt 3 ]] ; then
938937
echo done>&2
939938
fi
@@ -977,8 +976,12 @@ for i in "${TEST[@]}" ; do
977976
TEST_cl=${TEST_cl,,}
978977
TEST_cl=${TEST_cl/bin\/*_/bin\/}
979978
if [[ $TEST_cl = $ENV_cl ]] ; then
980-
if [[ ${!ENV_INC/"$MSVS_INC"/} != "${!ENV_INC}" && \
981-
${!ENV_LIB/"$MSVS_LIB"/} != "${!ENV_LIB}" ]] ; then
979+
# Create trailing semi-colon versions of the expansions of ENV_ for comparison with MSVS_
980+
ENV_EXPAND_INC="${!ENV_INC%%;};"
981+
ENV_EXPAND_LIB="${!ENV_LIB%%;};"
982+
983+
if [[ ${ENV_EXPAND_INC/"$MSVS_INC"/} != "${ENV_EXPAND_INC}" && \
984+
${ENV_EXPAND_LIB/"$MSVS_LIB"/} != "${ENV_EXPAND_LIB}" ]] ; then
982985
debug "$i-$arch is a strong candidate for the Environment C compiler"
983986
if [[ -n ${ENV_COMPILER+x} ]] ; then
984987
if [[ -z ${ENV_COMPILER} ]] ; then

0 commit comments

Comments
 (0)