diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-10-27 09:33:26 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-10-27 09:33:26 +0100 |
commit | 73e68fe323408e7ca953bf6e57ff23387696bc3c (patch) | |
tree | b555ba18ae3aaa8194abc99305983d2d5c4b7f79 /kernel | |
parent | bd2c8ec886cc34eac22493620de74b86b7f3628d (diff) | |
download | yosys-73e68fe323408e7ca953bf6e57ff23387696bc3c.tar.gz yosys-73e68fe323408e7ca953bf6e57ff23387696bc3c.tar.bz2 yosys-73e68fe323408e7ca953bf6e57ff23387696bc3c.zip |
Added API and Makefile rules for share/ files
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/driver.cc | 21 | ||||
-rw-r--r-- | kernel/register.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc index 8d8f29e77..d726639c4 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -421,6 +421,27 @@ std::string rewrite_yosys_exe(std::string exe) return exe; } +std::string get_share_file_name(std::string file) +{ + char buffer[1024]; + ssize_t buflen = readlink("/proc/self/exe", buffer, sizeof(buffer)-1); + + if (buflen < 0) + log_error("Can't find file `%s': reading of /proc/self/exe failed!\n", file.c_str()); + + buffer[buflen] = 0; + + std::string newfile_inplace = stringf("%s/share/%s", dirname(buffer), file.c_str()); + if (access(newfile_inplace.c_str(), F_OK) == 0) + return newfile_inplace; + + std::string newfile_system = stringf("%s/../share/yosys/%s", dirname(buffer), file.c_str()); + if (access(newfile_system.c_str(), F_OK) == 0) + return newfile_system; + + log_error("Can't find file `%s': no `%s' and no `%s' found!\n", file.c_str(), newfile_inplace.c_str(), newfile_system.c_str()); +} + int main(int argc, char **argv) { std::string frontend_command = "auto"; diff --git a/kernel/register.h b/kernel/register.h index 5983211d1..f66cbfd30 100644 --- a/kernel/register.h +++ b/kernel/register.h @@ -34,6 +34,7 @@ extern Tcl_Interp *yosys_get_tcl_interp(); // implemented in driver.cc extern RTLIL::Design *yosys_get_design(); std::string rewrite_yosys_exe(std::string exe); +std::string get_share_file_name(std::string file); struct Pass { |