#include <readline/history.h>
#include <string.h>
#include <unistd.h>
+#include <libgen.h>
#include <dlfcn.h>
#include "kernel/rtlil.h"
} 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";
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;
static void backend_call(RTLIL::Design *design, FILE *f, std::string filename, std::vector<std::string> args);
};
-// implemented in kernel/select.cc
+// implemented in passes/cmds/select.cc
extern void handle_extra_select_args(Pass *pass, std::vector<std::string> args, size_t argidx, size_t args_size, RTLIL::Design *design);
namespace REGISTER_INTERN {
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;
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");