mirror of https://github.com/YosysHQ/yosys.git
cxxrtl: Use the base name of the interface file for the include directive
Prior to this fix, the `CxxrtlBackend` used the entire path for the include directive when a separated interface file is generated (via the `-header` option). This commit updates the code to use the base name of the interface file. Since the C++11 standard is used by default, we cannot take advantage of the `std::filesystem` to get the basename.
This commit is contained in:
parent
3ea6bca23e
commit
dbff694e3d
|
@ -628,6 +628,22 @@ std::string escape_cxx_string(const std::string &input)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string basename(const std::string &filepath)
|
||||||
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
|
const std::string dir_seps = "/";
|
||||||
|
#else
|
||||||
|
const std::string dir_seps = "\\/";
|
||||||
|
#endif
|
||||||
|
size_t sep_pos = filepath.find_last_of(dir_seps);
|
||||||
|
if (sep_pos != std::string::npos && sep_pos + 1 < filepath.length()) {
|
||||||
|
return filepath.substr(sep_pos + 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return filepath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
std::string get_hdl_name(T *object)
|
std::string get_hdl_name(T *object)
|
||||||
{
|
{
|
||||||
|
@ -2571,7 +2587,7 @@ struct CxxrtlWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (split_intf)
|
if (split_intf)
|
||||||
f << "#include \"" << intf_filename << "\"\n";
|
f << "#include \"" << basename(intf_filename) << "\"\n";
|
||||||
else
|
else
|
||||||
f << "#include <cxxrtl/cxxrtl.h>\n";
|
f << "#include <cxxrtl/cxxrtl.h>\n";
|
||||||
if (has_prints)
|
if (has_prints)
|
||||||
|
|
Loading…
Reference in New Issue