diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/driver.cc | 15 | ||||
-rw-r--r-- | kernel/log.cc | 17 | ||||
-rw-r--r-- | kernel/log.h | 24 | ||||
-rw-r--r-- | kernel/register.cc | 12 | ||||
-rw-r--r-- | kernel/register.h | 1 | ||||
-rw-r--r-- | kernel/yosys.cc | 4 |
6 files changed, 49 insertions, 24 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc index 398c89e03..5f0959776 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -413,22 +413,13 @@ int main(int argc, char **argv) scriptfile_tcl = true; break; case 'W': - log_warn_regexes.push_back(std::regex(optarg, - std::regex_constants::nosubs | - std::regex_constants::optimize | - std::regex_constants::egrep)); + log_warn_regexes.push_back(YS_REGEX_COMPILE(optarg)); break; case 'w': - log_nowarn_regexes.push_back(std::regex(optarg, - std::regex_constants::nosubs | - std::regex_constants::optimize | - std::regex_constants::egrep)); + log_nowarn_regexes.push_back(YS_REGEX_COMPILE(optarg)); break; case 'e': - log_werror_regexes.push_back(std::regex(optarg, - std::regex_constants::nosubs | - std::regex_constants::optimize | - std::regex_constants::egrep)); + log_werror_regexes.push_back(YS_REGEX_COMPILE(optarg)); break; case 'D': vlog_defines.push_back(optarg); diff --git a/kernel/log.cc b/kernel/log.cc index 72181ebe8..d84a4381e 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -41,8 +41,8 @@ YOSYS_NAMESPACE_BEGIN std::vector<FILE*> log_files; std::vector<std::ostream*> log_streams; std::map<std::string, std::set<std::string>> log_hdump; -std::vector<std::regex> log_warn_regexes, log_nowarn_regexes, log_werror_regexes; -std::vector<std::pair<std::regex,LogExpectedItem>> log_expect_log, log_expect_warning, log_expect_error; +std::vector<YS_REGEX_TYPE> log_warn_regexes, log_nowarn_regexes, log_werror_regexes; +std::vector<std::pair<YS_REGEX_TYPE,LogExpectedItem>> log_expect_log, log_expect_warning, log_expect_error; std::set<std::string> log_warnings, log_experimentals, log_experimentals_ignored; int log_warnings_count = 0; int log_warnings_count_noexpect = 0; @@ -177,11 +177,11 @@ void logv(const char *format, va_list ap) if (!linebuffer.empty() && linebuffer.back() == '\n') { for (auto &re : log_warn_regexes) - if (std::regex_search(linebuffer, re)) + if (YS_REGEX_NS::regex_search(linebuffer, re)) log_warning("Found log message matching -W regex:\n%s", str.c_str()); for (auto &item : log_expect_log) - if (std::regex_search(linebuffer, item.first)) + if (YS_REGEX_NS::regex_search(linebuffer, item.first)) item.second.current_count++; linebuffer.clear(); @@ -238,7 +238,7 @@ static void logv_warning_with_prefix(const char *prefix, bool suppressed = false; for (auto &re : log_nowarn_regexes) - if (std::regex_search(message, re)) + if (YS_REGEX_NS::regex_search(message, re)) suppressed = true; if (suppressed) @@ -251,12 +251,12 @@ static void logv_warning_with_prefix(const char *prefix, log_make_debug = 0; for (auto &re : log_werror_regexes) - if (std::regex_search(message, re)) + if (YS_REGEX_NS::regex_search(message, re)) log_error("%s", message.c_str()); bool warning_match = false; for (auto &item : log_expect_warning) - if (std::regex_search(message, item.first)) { + if (YS_REGEX_NS::regex_search(message, item.first)) { item.second.current_count++; warning_match = true; } @@ -349,7 +349,7 @@ static void logv_error_with_prefix(const char *prefix, log_error_atexit(); for (auto &item : log_expect_error) - if (std::regex_search(log_last_error, item.first)) + if (YS_REGEX_NS::regex_search(log_last_error, item.first)) item.second.current_count++; if (check_expected_logs) @@ -695,7 +695,6 @@ void log_check_expected() log_warn_regexes.clear(); log("Expected error pattern '%s' found !!!\n", item.second.pattern.c_str()); #ifdef EMSCRIPTEN - log_files = backup_log_files; throw 0; #elif defined(_MSC_VER) _exit(0); diff --git a/kernel/log.h b/kernel/log.h index 603938f4c..cd0e8185c 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -23,7 +23,25 @@ #define LOG_H #include <time.h> -#include <regex> + +// In GCC 4.8 std::regex is not working correctlty, in order to make features +// using regular expressions to work replacement regex library is used +#if defined(__GNUC__) && !defined( __clang__) && ( __GNUC__ == 4 && __GNUC_MINOR__ <= 8) + #include <boost/xpressive/xpressive.hpp> + #define YS_REGEX_TYPE boost::xpressive::sregex + #define YS_REGEX_NS boost::xpressive + #define YS_REGEX_COMPILE(param) boost::xpressive::sregex::compile(param, \ + boost::xpressive::regex_constants::nosubs | \ + boost::xpressive::regex_constants::optimize) +# else + #include <regex> + #define YS_REGEX_TYPE std::regex + #define YS_REGEX_NS std + #define YS_REGEX_COMPILE(param) std::regex(param, \ + std::regex_constants::nosubs | \ + std::regex_constants::optimize | \ + std::regex_constants::egrep) +#endif #ifndef _WIN32 # include <sys/time.h> @@ -49,7 +67,7 @@ struct log_cmd_error_exception { }; extern std::vector<FILE*> log_files; extern std::vector<std::ostream*> log_streams; extern std::map<std::string, std::set<std::string>> log_hdump; -extern std::vector<std::regex> log_warn_regexes, log_nowarn_regexes, log_werror_regexes; +extern std::vector<YS_REGEX_TYPE> log_warn_regexes, log_nowarn_regexes, log_werror_regexes; extern std::set<std::string> log_warnings, log_experimentals, log_experimentals_ignored; extern int log_warnings_count; extern int log_warnings_count_noexpect; @@ -151,7 +169,7 @@ struct LogExpectedItem std::string pattern; }; -extern std::vector<std::pair<std::regex,LogExpectedItem>> log_expect_log, log_expect_warning, log_expect_error; +extern std::vector<std::pair<YS_REGEX_TYPE,LogExpectedItem>> log_expect_log, log_expect_warning, log_expect_error; void log_check_expected(); const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true); diff --git a/kernel/register.cc b/kernel/register.cc index e59d59654..af8c1b8e8 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -400,6 +400,18 @@ void ScriptPass::run(std::string command, std::string info) } } +void ScriptPass::run_nocheck(std::string command, std::string info) +{ + if (active_design == nullptr) { + if (info.empty()) + log(" %s\n", command.c_str()); + else + log(" %s %s\n", command.c_str(), info.c_str()); + } else { + Pass::call(active_design, command); + } +} + void ScriptPass::run_script(RTLIL::Design *design, std::string run_from, std::string run_to) { help_mode = false; diff --git a/kernel/register.h b/kernel/register.h index 4622845b6..3d89386b7 100644 --- a/kernel/register.h +++ b/kernel/register.h @@ -84,6 +84,7 @@ struct ScriptPass : Pass bool check_label(std::string label, std::string info = std::string()); void run(std::string command, std::string info = std::string()); + void run_nocheck(std::string command, std::string info = std::string()); void run_script(RTLIL::Design *design, std::string run_from = std::string(), std::string run_to = std::string()); void help_script(); }; diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 8190d8902..7694fc9b6 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -341,7 +341,11 @@ int run_command(const std::string &command, std::function<void(const std::string if (!process_line) return system(command.c_str()); +#ifdef EMSCRIPTEN + FILE *f = nullptr; +#else FILE *f = popen(command.c_str(), "r"); +#endif if (f == nullptr) return -1; |