From 68bbb15214e0048e4f32e0c38e192eab62dea7bd Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 22 Mar 2015 11:03:56 +0100 Subject: Fixed detection of absolute paths in ABC for win32 --- kernel/yosys.cc | 9 +++++++++ kernel/yosys.h | 1 + passes/abc/abc.cc | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/kernel/yosys.cc b/kernel/yosys.cc index b54836621..884b2c59b 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -376,6 +376,15 @@ bool check_file_exists(std::string filename, bool is_exec) } #endif +bool is_absolute_path(std::string filename) +{ +#ifdef _WIN32 + return filename[0] == '/' || filename[0] == '\\' || (filename[0] != 0 && filename[1] == ':'); +#else + return filename[0] == '/'; +#endif +} + void remove_directory(std::string dirname) { #ifdef _WIN32 diff --git a/kernel/yosys.h b/kernel/yosys.h index 467d2074f..231dd4de6 100644 --- a/kernel/yosys.h +++ b/kernel/yosys.h @@ -210,6 +210,7 @@ int run_command(const std::string &command, std::function int GetSize(const T &obj) { return obj.size(); } diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index 69da710f2..8cd0211c1 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -1216,19 +1216,19 @@ struct AbcPass : public Pass { } if (arg == "-script" && argidx+1 < args.size()) { script_file = args[++argidx]; - if (!script_file.empty() && script_file[0] != '/' && script_file[0] != '+') + if (!script_file.empty() && !is_absolute_path(script_file) && script_file[0] != '+') script_file = std::string(pwd) + "/" + script_file; continue; } if (arg == "-liberty" && argidx+1 < args.size()) { liberty_file = args[++argidx]; - if (!liberty_file.empty() && liberty_file[0] != '/') + if (!liberty_file.empty() && !is_absolute_path(liberty_file)) liberty_file = std::string(pwd) + "/" + liberty_file; continue; } if (arg == "-constr" && argidx+1 < args.size()) { constr_file = args[++argidx]; - if (!constr_file.empty() && constr_file[0] != '/') + if (!constr_file.empty() && !is_absolute_path(constr_file)) constr_file = std::string(pwd) + "/" + constr_file; continue; } -- cgit v1.2.3