From bf59a28f80fc321b139772804d52e441194040f7 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 9 Jun 2013 00:07:26 +0200 Subject: [PATCH] Look for yosys-abc and yosys-svgviewer where the main exe is --- kernel/driver.cc | 17 +++++++++++++++++ kernel/register.h | 5 ++++- passes/abc/abc.cc | 2 +- passes/cmds/show.cc | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/kernel/driver.cc b/kernel/driver.cc index b43df868d..c24b293fc 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "kernel/rtlil.h" @@ -343,6 +344,22 @@ struct TclPass : public Pass { } TclPass; #endif +std::string rewrite_yosys_exe(std::string exe) +{ + char buffer[1024]; + ssize_t buflen = readlink("/proc/self/exe", buffer, sizeof(buffer)-1); + + if (buflen < 0) + return exe; + + buffer[buflen] = 0; + std::string newexe = stringf("%s/%s", dirname(buffer), exe.c_str()); + if (access(newexe.c_str(), X_OK) == 0) + return newexe; + + return exe; +} + int main(int argc, char **argv) { std::string frontend_command = "auto"; diff --git a/kernel/register.h b/kernel/register.h index 5bd8216c7..849549acc 100644 --- a/kernel/register.h +++ b/kernel/register.h @@ -32,6 +32,9 @@ extern Tcl_Interp *yosys_get_tcl_interp(); extern RTLIL::Design *yosys_get_tcl_design(); #endif +// implemented in driver.cc +std::string rewrite_yosys_exe(std::string exe); + struct Pass { std::string pass_name, short_help; @@ -83,7 +86,7 @@ struct Backend : Pass static void backend_call(RTLIL::Design *design, FILE *f, std::string filename, std::vector args); }; -// implemented in kernel/select.cc +// implemented in passes/cmds/select.cc extern void handle_extra_select_args(Pass *pass, std::vector args, size_t argidx, size_t args_size, RTLIL::Design *design); namespace REGISTER_INTERN { diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index 3c6700147..5ceaeb48f 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -665,7 +665,7 @@ struct AbcPass : public Pass { log_header("Executing ABC pass (technology mapping using ABC).\n"); log_push(); - std::string exe_file = "yosys-abc"; + std::string exe_file = rewrite_yosys_exe("yosys-abc"); std::string script_file, liberty_file; bool cleanup = true; diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index c66320b3e..4ed4a95cb 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -672,7 +672,7 @@ struct ShowPass : public Pass { log_cmd_error("Shell command failed!\n"); } else if (format.empty()) { - cmd = stringf("fuser -s '%s' || yosys-svgviewer '%s' &", out_file.c_str(), out_file.c_str()); + cmd = stringf("fuser -s '%s' || '%s' '%s' &", out_file.c_str(), rewrite_yosys_exe("yosys-svgviewer").c_str(), out_file.c_str()); log("Exec: %s\n", cmd.c_str()); if (system(cmd.c_str()) != 0) log_cmd_error("Shell command failed!\n"); -- 2.30.2