From eb3d66864f5116e852bf763bfb3f02783df1b7ac Mon Sep 17 00:00:00 2001 From: Gabriel Gouvine Date: Thu, 28 Mar 2024 16:10:02 +0000 Subject: [PATCH] Always provide run_command and raise an error if YOSYS_DISABLE_SPAWN --- kernel/fstdata.cc | 2 -- kernel/register.cc | 4 ---- kernel/yosys.cc | 6 ++++-- libs/ezsat/ezcommand.cc | 4 ---- passes/cmds/show.cc | 12 +++--------- passes/cmds/viz.cc | 12 +++--------- 6 files changed, 10 insertions(+), 30 deletions(-) diff --git a/kernel/fstdata.cc b/kernel/fstdata.cc index 65ae3426cd6..069b51428e4 100644 --- a/kernel/fstdata.cc +++ b/kernel/fstdata.cc @@ -29,7 +29,6 @@ static std::string file_base_name(std::string const & path) FstData::FstData(std::string filename) : ctx(nullptr) { - #if !defined(YOSYS_DISABLE_SPAWN) std::string filename_trim = file_base_name(filename); if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".vcd") == 0) { filename_trim.erase(filename_trim.size()-4); @@ -40,7 +39,6 @@ FstData::FstData(std::string filename) : ctx(nullptr) log_cmd_error("Shell command failed!\n"); filename = tmp_file; } - #endif const std::vector g_units = { "s", "ms", "us", "ns", "ps", "fs", "as", "zs" }; ctx = (fstReaderContext *)fstReaderOpen(filename.c_str()); if (!ctx) diff --git a/kernel/register.cc b/kernel/register.cc index 80bc44901b2..b559d58c03c 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -239,7 +239,6 @@ void Pass::call(RTLIL::Design *design, std::string command) return; if (tok[0] == '!') { -#if !defined(YOSYS_DISABLE_SPAWN) cmd_buf = command.substr(command.find('!') + 1); while (!cmd_buf.empty() && (cmd_buf.back() == ' ' || cmd_buf.back() == '\t' || cmd_buf.back() == '\r' || cmd_buf.back() == '\n')) @@ -249,9 +248,6 @@ void Pass::call(RTLIL::Design *design, std::string command) if (retCode != 0) log_cmd_error("Shell command returned error code %d.\n", retCode); return; -#else - log_cmd_error("Shell is not available.\n"); -#endif } while (!tok.empty()) { diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 57433d0d9c1..407edc0f9b0 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -290,9 +290,9 @@ bool patmatch(const char *pattern, const char *string) return false; } -#if !defined(YOSYS_DISABLE_SPAWN) int run_command(const std::string &command, std::function process_line) { +#if !defined(YOSYS_DISABLE_SPAWN) if (!process_line) return system(command.c_str()); @@ -318,8 +318,10 @@ int run_command(const std::string &command, std::function &modelExpressions, std::vector &modelValues, const std::vector &assumptions) { -#if !defined(YOSYS_DISABLE_SPAWN) const std::string tempdir_name = Yosys::make_temp_dir(Yosys::get_base_tmpdir() + "/yosys-sat-XXXXXX"); const std::string cnf_filename = Yosys::stringf("%s/problem.cnf", tempdir_name.c_str()); const std::string sat_command = Yosys::stringf("%s %s", command.c_str(), cnf_filename.c_str()); @@ -82,7 +81,4 @@ bool ezSATCommand::solver(const std::vector &modelExpressions, std::vector< modelValues[i] = (values.at(idx - 1) == refvalue); } return true; -#else - Yosys::log_error("SAT solver command not available in this build!\n"); -#endif } \ No newline at end of file diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index 82b5c6bcf35..cb73dd3c9eb 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -758,7 +758,7 @@ struct ShowPass : public Pass { std::vector> color_selections; std::vector> label_selections; -#if defined(_WIN32) || defined(YOSYS_DISABLE_SPAWN) +#if defined(_WIN32) std::string format = "dot"; std::string prefix = "show"; #else @@ -931,15 +931,10 @@ struct ShowPass : public Pass { std::string cmd = stringf(DOT_CMD, format.c_str(), dot_file.c_str(), out_file.c_str(), out_file.c_str(), out_file.c_str()); #undef DOT_CMD log("Exec: %s\n", cmd.c_str()); - #if !defined(YOSYS_DISABLE_SPAWN) - if (run_command(cmd) != 0) - log_cmd_error("Shell command failed!\n"); - #endif + if (run_command(cmd) != 0) + log_cmd_error("Shell command failed!\n"); } - #if defined(YOSYS_DISABLE_SPAWN) - log_assert(viewer_exe.empty() && !format.empty()); - #else if (viewer_exe != "none") { if (!viewer_exe.empty()) { #ifdef _WIN32 @@ -965,7 +960,6 @@ struct ShowPass : public Pass { log_cmd_error("Shell command failed!\n"); } } - #endif if (flag_pause) { #ifdef YOSYS_ENABLE_READLINE diff --git a/passes/cmds/viz.cc b/passes/cmds/viz.cc index 3655f3f491b..67c369eae4f 100644 --- a/passes/cmds/viz.cc +++ b/passes/cmds/viz.cc @@ -892,7 +892,7 @@ struct VizPass : public Pass { log_header(design, "Generating Graphviz representation of design.\n"); log_push(); -#if defined(_WIN32) || defined(YOSYS_DISABLE_SPAWN) +#if defined(_WIN32) std::string format = "dot"; std::string prefix = "show"; #else @@ -1023,15 +1023,10 @@ struct VizPass : public Pass { std::string cmd = stringf(DOT_CMD, format.c_str(), dot_file.c_str(), out_file.c_str(), out_file.c_str(), out_file.c_str()); #undef DOT_CMD log("Exec: %s\n", cmd.c_str()); - #if !defined(YOSYS_DISABLE_SPAWN) - if (run_command(cmd) != 0) - log_cmd_error("Shell command failed!\n"); - #endif + if (run_command(cmd) != 0) + log_cmd_error("Shell command failed!\n"); } - #if defined(YOSYS_DISABLE_SPAWN) - log_assert(viewer_exe.empty() && !format.empty()); - #else if (!viewer_exe.empty()) { #ifdef _WIN32 // system()/cmd.exe does not understand single quotes nor @@ -1055,7 +1050,6 @@ struct VizPass : public Pass { if (run_command(cmd) != 0) log_cmd_error("Shell command failed!\n"); } - #endif if (flag_pause) { #ifdef YOSYS_ENABLE_READLINE