3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-15 15:25:28 +00:00
This commit is contained in:
Emil J 2025-03-21 09:45:51 +13:00 committed by GitHub
commit 644097de09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 26 deletions

View file

@ -545,6 +545,25 @@ std::string escape_filename_spaces(const std::string& filename)
return out;
}
#ifdef _WIN32
const char* const OS_PATH_SEP = "/\\";
#else
const char* const OS_PATH_SEP = "/";
#endif
std::string name_from_file_path(std::string path) {
size_t sep_pos = path.find_last_of(OS_PATH_SEP);
if (sep_pos != std::string::npos)
return path.substr(sep_pos + 1);
else
return path;
}
// Includes OS_PATH_SEP at the end if present
std::string parent_from_file_path(std::string path) {
return path.substr(0, path.find_last_of(OS_PATH_SEP)+1);
}
bool already_setup = false;
void yosys_setup()

View file

@ -318,6 +318,8 @@ bool is_absolute_path(std::string filename);
void remove_directory(std::string dirname);
bool create_directory(const std::string& dirname);
std::string escape_filename_spaces(const std::string& filename);
std::string name_from_file_path(std::string path);
std::string parent_from_file_path(std::string path);
template<typename T> int GetSize(const T &obj) { return obj.size(); }
inline int GetSize(RTLIL::Wire *wire);