From df403965ab044b864080fb125065c44da93ec88c Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 27 Jun 2017 09:29:56 +0200 Subject: [PATCH] ENH: suppress wmkdep 'No such file' warnings in wmake -silent mode --- wmake/rules/General/transform | 6 +++-- wmake/src/wmkdep.l | 44 +++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/wmake/rules/General/transform b/wmake/rules/General/transform index ae247644925..39bb774ca1f 100644 --- a/wmake/rules/General/transform +++ b/wmake/rules/General/transform @@ -1,5 +1,7 @@ #----------------------------*- makefile-gmake -*------------------------------ +WMKDEP_FLAGS := -eWM_PROJECT_DIR -eWM_THIRD_PARTY_DIR + ifneq ("$(WM_QUIET)","") E=@ define QUIET_MESSAGE @@ -7,6 +9,7 @@ ifneq ("$(WM_QUIET)","") endef define VERBOSE_MESSAGE endef + WMKDEP_FLAGS += -q else E= define QUIET_MESSAGE @@ -28,7 +31,6 @@ $(OBJECTS_DIR)/%.dep : % $(call QUIET_MESSAGE,wmkdep,$(<F)) $(call VERBOSE_MESSAGE,Making dependency list for source file,$(<F)) @$(WM_SCRIPTS)/makeTargetDir $@ - @$(WMAKE_BIN)/wmkdep -o$@ -I$(*D) $(LIB_HEADER_DIRS) \ - -eWM_PROJECT_DIR -eWM_THIRD_PARTY_DIR $< + @$(WMAKE_BIN)/wmkdep $(WMKDEP_FLAGS) -o$@ -I$(*D) $(LIB_HEADER_DIRS) $< #------------------------------------------------------------------------------ diff --git a/wmake/src/wmkdep.l b/wmake/src/wmkdep.l index a3a503fb9e9..7e99ff2c640 100644 --- a/wmake/src/wmkdep.l +++ b/wmake/src/wmkdep.l @@ -36,7 +36,7 @@ Description which makes this faster than cpp. Usage - wmkdep [-Idir..] [-iheader...] [-eENV...] [-ofile] filename + wmkdep [-Idir..] [-iheader...] [-eENV...] [-oFile] [-q] filename \*---------------------------------------------------------------------------*/ /* With cpp: @@ -264,6 +264,7 @@ static void print_fileName(const char* fileName) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int optQuiet = 0; int nDirectories = 0; char** directories = NULL; char* sourceFile = NULL; @@ -314,18 +315,23 @@ int main(int argc, char* argv[]) fputs ( "\nUsage: " EXENAME - " [-Idir...] [-iheader...] [-eENV...]" - " [-ofile] filename\n\n" + " [-Idir...] [-iheader...] [-eENV...] [-oFile] [-q]" + " filename\n\n" " -Idir Directories to be searched for headers.\n" " -iheader Headers to be ignored.\n" " -eENV Environment variable path substitutions.\n" - " -ofile Write output to file.\n" + " -oFile Write output to File.\n" + " -q Suppress 'No such file' warnings.\n" "\nDependency list generator, similar to 'cpp -M'\n\n", stderr ); return 0; break; + case 'q': /* Option: -q (quiet) */ + ++optQuiet; + break; + case 'I': /* Option: -Idir */ ++nDirectories; break; @@ -390,7 +396,7 @@ int main(int argc, char* argv[]) } else if (!strncmp(argv[i], "-o", 2)) { - /* Option: -ofile */ + /* Option: -oFile */ if (optLen > 2) { outputFile = (argv[i] + 2); @@ -414,6 +420,7 @@ int main(int argc, char* argv[]) EXENAME ": could not open file '%s' for output: %s\n", outputFile, strerror(errno) ); + fflush(stderr); return 1; } @@ -427,6 +434,7 @@ int main(int argc, char* argv[]) yylex(); fputs("\n\n", stdout); + fflush(stdout); for (i = nDirectories-1; i >= 0; --i) { @@ -438,9 +446,6 @@ int main(int argc, char* argv[]) free_hashTable(visitedFiles); free_envTable(); - fflush(stdout); - fflush(stderr); - return 0; } @@ -553,20 +558,23 @@ void nextFile(const char* fileName) } } - fprintf - ( - stderr, - EXENAME ": could not open file '%s' for source file '%s'", - fileName, sourceFile - ); - if (nDirectories) + if (!optQuiet) { - fprintf(stderr, ": %s", strerror(errno)); + fprintf + ( + stderr, + EXENAME ": could not open file '%s' for source file '%s'", + fileName, sourceFile + ); + if (nDirectories) + { + fprintf(stderr, ": %s", strerror(errno)); + } + fputs("\n", stderr); + fflush(stderr); } - fputs("\n", stderr); fflush(stdout); - fflush(stderr); /* Only report the first occurrence */ lookUp(visitedFiles, fileName); -- GitLab