mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Internals: Remove duplicate filenameNonExt. No functional change.
This commit is contained in:
parent
8c3b754bac
commit
74ae879c2f
@ -209,7 +209,7 @@ public:
|
||||
of.puts("VM_USER_CLASSES = \\\n");
|
||||
const V3StringSet& cppFiles = v3Global.opt.cppFiles();
|
||||
for (const auto& cppfile : cppFiles) {
|
||||
of.puts("\t" + V3Os::filenameNonExt(cppfile) + " \\\n");
|
||||
of.puts("\t" + V3Os::filenameNonDirExt(cppfile) + " \\\n");
|
||||
const string dir = V3Os::filenameDir(cppfile);
|
||||
dirs.insert(dir);
|
||||
}
|
||||
@ -237,7 +237,7 @@ public:
|
||||
}
|
||||
|
||||
for (const string& cppfile : cppFiles) {
|
||||
const string basename = V3Os::filenameNonExt(cppfile);
|
||||
const string basename = V3Os::filenameNonDirExt(cppfile);
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
of.puts(basename + ".o: " + cppfile + "\n");
|
||||
of.puts("\t$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<\n");
|
||||
|
@ -1025,10 +1025,9 @@ void V3Options::parseOpts(FileLine* fl, int argc, char** argv) VL_MT_DISABLED {
|
||||
}
|
||||
|
||||
// Default prefix to the filename
|
||||
if (prefix() == "" && topModule() != "")
|
||||
m_prefix = string{"V"} + AstNode::encodeName(topModule());
|
||||
if (prefix() == "" && topModule() != "") m_prefix = "V"s + AstNode::encodeName(topModule());
|
||||
if (prefix() == "" && vFilesList.size() >= 1)
|
||||
m_prefix = string{"V"} + AstNode::encodeName(V3Os::filenameNonExt(*(vFilesList.begin())));
|
||||
m_prefix = "V"s + AstNode::encodeName(V3Os::filenameNonDirExt(*(vFilesList.begin())));
|
||||
if (modPrefix() == "") m_modPrefix = prefix();
|
||||
|
||||
// Find files in makedir
|
||||
|
21
src/V3Os.cpp
21
src/V3Os.cpp
@ -165,6 +165,17 @@ string V3Os::filenameDir(const string& filename) VL_PURE {
|
||||
}
|
||||
}
|
||||
|
||||
string V3Os::filenameExt(const string& filename) VL_PURE {
|
||||
string base = filenameNonDir(filename);
|
||||
string::size_type pos;
|
||||
if ((pos = base.find('.')) != string::npos) {
|
||||
base.erase(0, pos);
|
||||
return base;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
string V3Os::filenameNonDir(const string& filename) VL_PURE {
|
||||
// std::filesystem::path::filename
|
||||
auto it = filename.rbegin();
|
||||
@ -174,17 +185,13 @@ string V3Os::filenameNonDir(const string& filename) VL_PURE {
|
||||
return string{it.base(), filename.end()};
|
||||
}
|
||||
|
||||
string V3Os::filenameNonExt(const string& filename) VL_PURE {
|
||||
string V3Os::filenameNonDirExt(const string& filename) VL_PURE {
|
||||
string base = filenameNonDir(filename);
|
||||
string::size_type pos;
|
||||
if ((pos = base.find('.')) != string::npos) base.erase(pos);
|
||||
return base;
|
||||
}
|
||||
|
||||
string V3Os::filenameNonDirExt(const string& filename) VL_PURE {
|
||||
return filenameNonExt(filenameNonDir(filename));
|
||||
}
|
||||
|
||||
string V3Os::filenameSubstitute(const string& filename) {
|
||||
string result;
|
||||
// cppcheck-has-bug-suppress unusedLabel
|
||||
@ -441,5 +448,9 @@ void V3Os::selfTest() {
|
||||
UASSERT_SELFTEST(string, filenameCleanup("aaa/bbb/ccc/"), "aaa/bbb/ccc");
|
||||
UASSERT_SELFTEST(string, filenameCleanup("./aaa/bbb/ccc/"), "aaa/bbb/ccc");
|
||||
UASSERT_SELFTEST(string, filenameCleanup("../aaa/bbb/ccc/"), "../aaa/bbb/ccc");
|
||||
UASSERT_SELFTEST(string, filenameDir("a.a/b.b/f.e"), "a.a/b.b");
|
||||
UASSERT_SELFTEST(string, filenameExt("a.a/b.b/f"), "");
|
||||
UASSERT_SELFTEST(string, filenameExt("a.a/b.b/f.e"), ".e");
|
||||
UASSERT_SELFTEST(string, filenameNonDirExt("a.a/b.b/f.e"), "f");
|
||||
#endif
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ public:
|
||||
};
|
||||
///< @return file path without repeated separators and ./ prefix
|
||||
static string filenameCleanup(const string& filename) VL_PURE;
|
||||
///< @return extension (.) part of filename
|
||||
static string filenameExt(const string& filename) VL_PURE;
|
||||
///< @return non-directory part of filename
|
||||
static string filenameNonDir(const string& filename) VL_PURE;
|
||||
///< @return non-extensioned (no .) part of filename
|
||||
static string filenameNonExt(const string& filename) VL_PURE;
|
||||
///< @return basename of filename
|
||||
static string filenameNonDirExt(const string& filename) VL_PURE;
|
||||
///< @return directory part of filename
|
||||
|
@ -287,7 +287,7 @@ void V3ParseImp::preprocDumps(std::ostream& os, bool forInputs) {
|
||||
void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool inLibrary,
|
||||
const string& errmsg) { // "" for no error, make fake node
|
||||
const string nondirname = V3Os::filenameNonDir(modfilename);
|
||||
const string modname = V3Os::filenameNonExt(modfilename);
|
||||
const string modname = V3Os::filenameNonDirExt(modfilename);
|
||||
|
||||
UINFO(2, __FUNCTION__ << ": " << modname << (inLibrary ? " [LIB]" : "") << endl);
|
||||
m_lexFileline = new FileLine{fileline};
|
||||
|
Loading…
Reference in New Issue
Block a user