From c80f8a28151bdb2710e55da8d8fc8f6a037a6188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 4 Mar 2025 10:57:13 +0200 Subject: [PATCH] msvsdepend: Allow using the script for .S sources too Previously, MSVC would warn that the .S source is unrecognized, and the script would only produce a depenency on the main source file itself. --- tools/msvsdepend.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/msvsdepend.sh b/tools/msvsdepend.sh index 5d267ab7..d3a2db21 100755 --- a/tools/msvsdepend.sh +++ b/tools/msvsdepend.sh @@ -8,11 +8,22 @@ set -f [ -n "$1" ] && [ -n "$3" ] && [ -n "$4" ] || exit 1 # Add flags to only perform syntax checking and output a list of included files +# For sources that aren't C, run preprocessing to NUL instead. + +case "$3" in +*.c) + opts="-W0 -Zs" + ;; +*) + opts="-P -FiNUL" + ;; +esac + # Discard all output other than included files # Convert '\' directory separators to '/' # Remove system includes (hack: check for "/Program Files" string in path) # Add the source file itself as a dependency -deps="$($1 $2 -nologo -showIncludes -W0 -Zs "$3" 2>&1 | +deps="$($1 $2 -nologo -showIncludes $opts "$3" 2>&1 | grep '^Note: including file:' | sed 's/^Note: including file:[[:space:]]*\(.*\)$/\1/; s/\\/\//g' | sed '/\/[Pp]rogram [Ff]iles/d')