4
4
# ################################################################################################ #
5
5
# Microsoft C Compiler Environment Detection Script #
6
6
# ################################################################################################ #
7
- # Copyright (c) 2016, 2017, 2018, 2019, 2020 MetaStack Solutions Ltd. #
7
+ # Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021 MetaStack Solutions Ltd. #
8
8
# ################################################################################################ #
9
9
# Author: David Allsopp #
10
10
# 16-Feb-2016 #
27
27
# of this software, even if advised of the possibility of such damage. #
28
28
# ################################################################################################ #
29
29
30
- VERSION=0.4.1
30
+ VERSION=0.6.0
31
31
32
32
# debug [level=2] message
33
33
debug ()
@@ -204,13 +204,6 @@ SCAN_ENV=0
204
204
# Various PATH messing around means it's sensible to know where tools are now
205
205
WHICH=$( which which)
206
206
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
-
214
207
# Parse command-line. At the moment, the short option which usefully combines with anything is -d,
215
208
# so for the time being, combining short options is not permitted, as the loop becomes even less
216
209
# clear with getopts. GNU getopt isn't installed by default on Cygwin...
@@ -337,7 +330,7 @@ if [[ $MODE -eq 1 ]] ; then
337
330
MSVS_PREFERENCE=
338
331
SCAN_ENV=1
339
332
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'
341
334
fi
342
335
343
336
MSVS_PREFERENCE=${MSVS_PREFERENCE// ;/ }
@@ -480,6 +473,9 @@ COMPILERS=(
480
473
[" VS16.*" ]=' (
481
474
["NAME"]="Visual Studio 2019"
482
475
["VSWHERE"]="1")'
476
+ [" VS17.*" ]=' (
477
+ ["NAME"]="Visual Studio 2022"
478
+ ["VSWHERE"]="1")'
483
479
[" SDK5.2" ]=' (
484
480
["NAME"]="Windows Server 2003 SP1 SDK"
485
481
["VC_VER"]="8.0"
@@ -733,7 +729,7 @@ if [[ -x $VSWHERE ]] ; then
733
729
warning " vcvarsall.bat not found for $INSTANCE "
734
730
fi ;;
735
731
esac
736
- done < <( " $VSWHERE " -all -nologo | tr -d ' \r' )
732
+ done < <( " $VSWHERE " -all -products ' * ' - nologo | tr -d ' \r' )
737
733
fi
738
734
739
735
if [[ $DEBUG -gt 1 ]] ; then
@@ -920,6 +916,8 @@ for i in "${TEST[@]}" ; do
920
916
if [[ $DEBUG -gt 3 ]] ; then
921
917
printf " Scanning %s... " " $( basename " $SCRIPT " ) $ARCH_SWITCHES $SCRIPT_SWITCHES " >&2
922
918
fi
919
+ # Setting MSYS2_ARG_CONV_EXCL to * inhibits attempts to convert the flags to COMSPEC as
920
+ # command line parameters.
923
921
num=0
924
922
while IFS= read -r line; do
925
923
case $num in
@@ -933,7 +931,8 @@ for i in "${TEST[@]}" ; do
933
931
(( num++ ))
934
932
done < <( INCLUDE=' ' LIB=' ' PATH=" ?msvs-detect?:$DIR :$PATH " ORIGINALPATH=' ' \
935
933
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)
937
936
if [[ $DEBUG -gt 3 ]] ; then
938
937
echo done>&2
939
938
fi
@@ -977,8 +976,12 @@ for i in "${TEST[@]}" ; do
977
976
TEST_cl=${TEST_cl,,}
978
977
TEST_cl=${TEST_cl/ bin\/ * _/ bin\/ }
979
978
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
982
985
debug " $i -$arch is a strong candidate for the Environment C compiler"
983
986
if [[ -n ${ENV_COMPILER+x} ]] ; then
984
987
if [[ -z ${ENV_COMPILER} ]] ; then
0 commit comments