diff options
-rw-r--r-- | src/config.xml | 8 | ||||
-rw-r--r-- | src/doxygen.cpp | 1 | ||||
-rw-r--r-- | src/message.cpp | 32 | ||||
-rw-r--r-- | src/message.h | 1 |
4 files changed, 35 insertions, 7 deletions
diff --git a/src/config.xml b/src/config.xml index 56dacd6..38a18d8 100644 --- a/src/config.xml +++ b/src/config.xml @@ -1336,13 +1336,19 @@ FILE_VERSION_FILTER = "cleartool desc -fmt \%Vn" ]]> </docs> </option> - <option type='bool' id='WARN_AS_ERROR' defval='0'> + <option type='enum' id='WARN_AS_ERROR' defval='NO'> <docs> <![CDATA[ If the \c WARN_AS_ERROR tag is set to \c YES then doxygen will immediately stop when a warning is encountered. + If the \c WARN_AS_ERROR tag is set to \c FAIL_ON_WARNINGS then doxygen will continue + running as if \c WARN_AS_ERROR tag is set to \c NO, but at the end of the doxygen + process doxygen will return with a non-zero status. ]]> </docs> + <value name="NO"/> + <value name="YES" /> + <value name="FAIL_ON_WARNINGS" /> </option> <option type='string' id='WARN_FORMAT' format='string' defval='$file:$line: $text'> <docs> diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 4667cba..e246628 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -11914,6 +11914,7 @@ void generateOutput() QDir thisDir; thisDir.remove(Doxygen::objDBFileName); thisDir.remove(Doxygen::filterDBFileName); + finishWarnExit(); Config::deinit(); QTextCodec::deleteAllCodecs(); delete Doxygen::clangUsrMap; diff --git a/src/message.cpp b/src/message.cpp index e107139..95a7553 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -34,6 +34,14 @@ static const char *error_str = "error: "; static FILE *warnFile = stderr; +enum warn_as_error +{ + WARN_NO, + WARN_YES, + FAIL_ON_WARNINGS, +}; +static warn_as_error warnBehavior = WARN_NO; +static bool warnStat = false; static std::mutex g_mutex; @@ -99,7 +107,11 @@ void initWarningFormat() warnFile = stderr; } - if (Config_getBool(WARN_AS_ERROR)) + QCString warnStr = Config_getEnum(WARN_AS_ERROR).upper(); + if (warnStr =="NO") warnBehavior=WARN_NO; + else if (warnStr =="YES") warnBehavior=WARN_YES; + else if (warnStr =="FAIL_ON_WARNINGS") warnBehavior=FAIL_ON_WARNINGS; + if (warnBehavior == WARN_YES) { warning_str = error_str; } @@ -129,7 +141,6 @@ static void format_warn(const char *file,int line,const char *text) QCString textSubst = text; QCString versionSubst; // substitute markers by actual values - bool warnAsError = Config_getBool(WARN_AS_ERROR); QCString msgText = substitute( substitute( @@ -144,7 +155,7 @@ static void format_warn(const char *file,int line,const char *text) ), "$text",textSubst ); - if (warnAsError) + if (warnBehavior == WARN_YES) { msgText += " (warning treated as error, aborting now)"; } @@ -155,22 +166,23 @@ static void format_warn(const char *file,int line,const char *text) // print resulting message fwrite(msgText.data(),1,msgText.length(),warnFile); } - if (warnAsError) + if (warnBehavior == WARN_YES) { exit(1); } + warnStat = true; } static void handle_warn_as_error() { - static bool warnAsError = Config_getBool(WARN_AS_ERROR); - if (warnAsError) + if (warnBehavior == WARN_YES) { std::unique_lock<std::mutex> lock(g_mutex); QCString msgText = " (warning treated as error, aborting now)\n"; fwrite(msgText.data(),1,msgText.length(),warnFile); exit(1); } + warnStat = true; } static void do_warn(bool enabled, const char *file, int line, const char *prefix, const char *fmt, va_list args) @@ -312,3 +324,11 @@ void printlex(int dbg, bool enter, const char *lexName, const char *fileName) Debug::print(Debug::Lex,0,"%s lexical analyzer: %s\n",enter_txt_uc, qPrint(lexName)); } } + +extern void finishWarnExit() +{ + if (warnStat && warnBehavior == FAIL_ON_WARNINGS) + { + exit(1); + } +} diff --git a/src/message.h b/src/message.h index dd9eeeb..af49632 100644 --- a/src/message.h +++ b/src/message.h @@ -36,6 +36,7 @@ extern void err_full(const char *file,int line,const char *fmt, ...) PRINTFLIKE( extern void term(const char *fmt, ...) PRINTFLIKE(1, 2); void initWarningFormat(); void warn_flush(); +extern void finishWarnExit(); extern void printlex(int dbg, bool enter, const char *lexName, const char *fileName); |