Merge pull request #150 from YosysHQ/err_warn_count
Print warning and error count at end of execution
This commit is contained in:
commit
cdfd35e6aa
@ -36,6 +36,7 @@
|
||||
#include "jsonparse.h"
|
||||
#include "log.h"
|
||||
#include "timing.h"
|
||||
#include "util.h"
|
||||
#include "version.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
@ -282,6 +283,15 @@ void CommandHandler::conflicting_options(const boost::program_options::variables
|
||||
}
|
||||
}
|
||||
|
||||
void CommandHandler::printFooter()
|
||||
{
|
||||
int warning_count = get_or_default(message_count_by_level, LogLevel::WARNING, 0),
|
||||
error_count = get_or_default(message_count_by_level, LogLevel::ERROR, 0);
|
||||
if (warning_count > 0 || error_count > 0)
|
||||
log_always("%d warning%s, %d error%s\n", warning_count, warning_count == 1 ? "" : "s", error_count,
|
||||
error_count == 1 ? "" : "s");
|
||||
}
|
||||
|
||||
int CommandHandler::exec()
|
||||
{
|
||||
try {
|
||||
@ -300,8 +310,11 @@ int CommandHandler::exec()
|
||||
settings = std::unique_ptr<Settings>(new Settings(ctx.get()));
|
||||
setupContext(ctx.get());
|
||||
setupArchContext(ctx.get());
|
||||
return executeMain(std::move(ctx));
|
||||
int rc = executeMain(std::move(ctx));
|
||||
printFooter();
|
||||
return rc;
|
||||
} catch (log_execution_error_exception) {
|
||||
printFooter();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ class CommandHandler
|
||||
int executeMain(std::unique_ptr<Context> ctx);
|
||||
po::options_description getGeneralOptions();
|
||||
void run_script_hook(const std::string &name);
|
||||
void printFooter();
|
||||
|
||||
protected:
|
||||
po::variables_map vm;
|
||||
|
@ -38,6 +38,7 @@ log_write_type log_write_function = nullptr;
|
||||
std::string log_last_error;
|
||||
void (*log_error_atexit)() = NULL;
|
||||
|
||||
std::unordered_map<LogLevel, int> message_count_by_level;
|
||||
static int log_newline_count = 0;
|
||||
bool had_nonfatal_error = false;
|
||||
|
||||
@ -112,6 +113,7 @@ void logv(const char *format, va_list ap, LogLevel level = LogLevel::LOG)
|
||||
|
||||
void log_with_level(LogLevel level, const char *format, ...)
|
||||
{
|
||||
message_count_by_level[level]++;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv(format, ap, level);
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "nextpnr.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
@ -57,6 +57,7 @@ extern log_write_type log_write_function;
|
||||
extern std::string log_last_error;
|
||||
extern void (*log_error_atexit)();
|
||||
extern bool had_nonfatal_error;
|
||||
extern std::unordered_map<LogLevel, int> message_count_by_level;
|
||||
|
||||
std::string stringf(const char *fmt, ...);
|
||||
std::string vstringf(const char *fmt, va_list ap);
|
||||
|
Loading…
Reference in New Issue
Block a user