Fixed detection of absolute paths in ABC for win32
authorClifford Wolf <clifford@clifford.at>
Sun, 22 Mar 2015 10:03:56 +0000 (11:03 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 22 Mar 2015 10:03:56 +0000 (11:03 +0100)
kernel/yosys.cc
kernel/yosys.h
passes/abc/abc.cc

index b54836621f02b34b27d0685f99e775cfe6922574..884b2c59bf8434d6fd3ae715f1f5fbcb9ba558c7 100644 (file)
@@ -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
index 467d2074f36e460069a92c8e9afc70499a15aa07..231dd4de6793799cdbf1d8be7480d9e79e573d1f 100644 (file)
@@ -210,6 +210,7 @@ int run_command(const std::string &command, std::function<void(const std::string
 std::string make_temp_file(std::string template_str = "/tmp/yosys_XXXXXX");
 std::string make_temp_dir(std::string template_str = "/tmp/yosys_XXXXXX");
 bool check_file_exists(std::string filename, bool is_exec = false);
+bool is_absolute_path(std::string filename);
 void remove_directory(std::string dirname);
 
 template<typename T> int GetSize(const T &obj) { return obj.size(); }
index 69da710f261d0816291bb3a1fbd4dafcade1276f..8cd0211c109b36bd5732b2c07a50febcc98a629d 100644 (file)
@@ -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;
                        }