Search for user -y paths before default current directory.
This commit is contained in:
parent
b337acebcc
commit
85a37ea53f
2
Changes
2
Changes
|
|
@ -8,6 +8,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||||
|
|
||||||
*** Add sc_bv attribute to force bit vectors, bug402. [by Stefan Wallentowitz]
|
*** Add sc_bv attribute to force bit vectors, bug402. [by Stefan Wallentowitz]
|
||||||
|
|
||||||
|
**** Search for user -y paths before default current directory. [Ruben Diez]
|
||||||
|
|
||||||
**** Fix reporting not found modules if generate-off, bug403. [Jeremy Bennett]
|
**** Fix reporting not found modules if generate-off, bug403. [Jeremy Bennett]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -569,10 +569,7 @@ Displays this message and program version and exits.
|
||||||
|
|
||||||
=item -II<dir>
|
=item -II<dir>
|
||||||
|
|
||||||
Add the directory to the list of directories that should be searched for
|
See -y.
|
||||||
include directories or libraries. Same as +incdir and -y; +incdir and -y
|
|
||||||
are fairly standard across Verilog tools while -I is an alias for GCC
|
|
||||||
compatibility.
|
|
||||||
|
|
||||||
=item --if-depth I<value>
|
=item --if-depth I<value>
|
||||||
|
|
||||||
|
|
@ -581,10 +578,7 @@ defaults to 0 which disables this warning.
|
||||||
|
|
||||||
=item +incdir+I<dir>
|
=item +incdir+I<dir>
|
||||||
|
|
||||||
Add the directory to the list of directories that should be searched for
|
See -y.
|
||||||
include directories or libraries. Same as -I and -y; +incdir and -y
|
|
||||||
are fairly standard across Verilog tools while -I is an alias for GCC
|
|
||||||
compatibility.
|
|
||||||
|
|
||||||
=item --inhibit-sim
|
=item --inhibit-sim
|
||||||
|
|
||||||
|
|
@ -973,9 +967,14 @@ enable rerunning with that same seed so you can reproduce bugs.
|
||||||
=item -y I<dir>
|
=item -y I<dir>
|
||||||
|
|
||||||
Add the directory to the list of directories that should be searched for
|
Add the directory to the list of directories that should be searched for
|
||||||
include directories or libraries. Same as +incdir and -I; +incdir and +y
|
include files or libraries. The three flags -y, +incdir and -I have
|
||||||
are fairly standard across Verilog tools while -I is an alias for GCC
|
similar effect; +incdir and +y are fairly standard across Verilog tools while -I
|
||||||
compatibility.
|
is an alias for GCC compatibility.
|
||||||
|
|
||||||
|
Verilator defaults to the current directory ("-y .") and any specified
|
||||||
|
--Mdir, though these default paths are used after any user specified
|
||||||
|
directories. This allows "-y `pwd`" to be used if absolute filenames are
|
||||||
|
desired for error messages instead of relative filenames.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,17 +51,29 @@ struct V3OptionsImp {
|
||||||
|
|
||||||
// STATE
|
// STATE
|
||||||
list<string> m_allArgs; // List of every argument encountered
|
list<string> m_allArgs; // List of every argument encountered
|
||||||
list<string> m_incDirs; // Include directories (ordered)
|
list<string> m_incDirUsers; // Include directories (ordered)
|
||||||
set<string> m_incDirSet; // Include directories (for removing duplicates)
|
set<string> m_incDirUserSet; // Include directories (for removing duplicates)
|
||||||
|
list<string> m_incDirFallbacks; // Include directories (ordered)
|
||||||
|
set<string> m_incDirFallbackSet; // Include directories (for removing duplicates)
|
||||||
list<string> m_libExts; // Library extensions (ordered)
|
list<string> m_libExts; // Library extensions (ordered)
|
||||||
set<string> m_libExtSet; // Library extensions (for removing duplicates)
|
set<string> m_libExtSet; // Library extensions (for removing duplicates)
|
||||||
DirMap m_dirMap; // Directory listing
|
DirMap m_dirMap; // Directory listing
|
||||||
|
|
||||||
// ACCESSOR METHODS
|
// ACCESSOR METHODS
|
||||||
void addIncDir(const string& incdir) {
|
void addIncDirUser(const string& incdir) {
|
||||||
if (m_incDirSet.find(incdir) == m_incDirSet.end()) {
|
if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) {
|
||||||
m_incDirSet.insert(incdir);
|
m_incDirUserSet.insert(incdir);
|
||||||
m_incDirs.push_back(incdir);
|
m_incDirUsers.push_back(incdir);
|
||||||
|
m_incDirFallbacks.remove(incdir); // User has priority over Fallback
|
||||||
|
m_incDirFallbackSet.erase(incdir); // User has priority over Fallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void addIncDirFallback(const string& incdir) {
|
||||||
|
if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) { // User has priority over Fallback
|
||||||
|
if (m_incDirFallbackSet.find(incdir) == m_incDirFallbackSet.end()) {
|
||||||
|
m_incDirFallbackSet.insert(incdir);
|
||||||
|
m_incDirFallbacks.push_back(incdir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void addLibExt(const string& libext) {
|
void addLibExt(const string& libext) {
|
||||||
|
|
@ -73,8 +85,11 @@ struct V3OptionsImp {
|
||||||
V3OptionsImp() {}
|
V3OptionsImp() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
void V3Options::addIncDir(const string& incdir) {
|
void V3Options::addIncDirUser(const string& incdir) {
|
||||||
m_impp->addIncDir(incdir);
|
m_impp->addIncDirUser(incdir);
|
||||||
|
}
|
||||||
|
void V3Options::addIncDirFallback(const string& incdir) {
|
||||||
|
m_impp->addIncDirFallback(incdir);
|
||||||
}
|
}
|
||||||
void V3Options::addLibExt(const string& libext) {
|
void V3Options::addLibExt(const string& libext) {
|
||||||
m_impp->addLibExt(libext);
|
m_impp->addLibExt(libext);
|
||||||
|
|
@ -288,21 +303,33 @@ string V3Options::fileExists (const string& filename) {
|
||||||
return filenameOut;
|
return filenameOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string V3Options::filePathCheckOneDir(const string& modname, const string& dirname) {
|
||||||
|
for (list<string>::iterator extIter=m_impp->m_libExts.begin(); extIter!=m_impp->m_libExts.end(); ++extIter) {
|
||||||
|
string fn = filenameFromDirBase(dirname, modname+*extIter);
|
||||||
|
string exists = fileExists(fn);
|
||||||
|
if (exists!="") {
|
||||||
|
// Strip ./, it just looks ugly
|
||||||
|
if (exists.substr(0,2)=="./") exists.erase(0,2);
|
||||||
|
return exists;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
string V3Options::filePath (FileLine* fl, const string& modname,
|
string V3Options::filePath (FileLine* fl, const string& modname,
|
||||||
const string& errmsg) { // Error prefix or "" to suppress error
|
const string& errmsg) { // Error prefix or "" to suppress error
|
||||||
// Find a filename to read the specified module name,
|
// Find a filename to read the specified module name,
|
||||||
// using the incdir and libext's.
|
// using the incdir and libext's.
|
||||||
// Return "" if not found.
|
// Return "" if not found.
|
||||||
for (list<string>::iterator dirIter=m_impp->m_incDirs.begin(); dirIter!=m_impp->m_incDirs.end(); ++dirIter) {
|
for (list<string>::iterator dirIter=m_impp->m_incDirUsers.begin();
|
||||||
for (list<string>::iterator extIter=m_impp->m_libExts.begin(); extIter!=m_impp->m_libExts.end(); ++extIter) {
|
dirIter!=m_impp->m_incDirUsers.end(); ++dirIter) {
|
||||||
string fn = filenameFromDirBase(*dirIter,modname+*extIter);
|
string exists = filePathCheckOneDir(modname, *dirIter);
|
||||||
string exists = fileExists(fn);
|
if (exists!="") return exists;
|
||||||
if (exists!="") {
|
}
|
||||||
// Strip ./, it just looks ugly
|
for (list<string>::iterator dirIter=m_impp->m_incDirFallbacks.begin();
|
||||||
if (exists.substr(0,2)=="./") exists.erase(0,2);
|
dirIter!=m_impp->m_incDirFallbacks.end(); ++dirIter) {
|
||||||
return exists;
|
string exists = filePathCheckOneDir(modname, *dirIter);
|
||||||
}
|
if (exists!="") return exists;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn and return not found
|
// Warn and return not found
|
||||||
|
|
@ -317,15 +344,22 @@ void V3Options::filePathLookedMsg(FileLine* fl, const string& modname) {
|
||||||
static bool shown_notfound_msg = false;
|
static bool shown_notfound_msg = false;
|
||||||
if (!shown_notfound_msg) {
|
if (!shown_notfound_msg) {
|
||||||
shown_notfound_msg = true;
|
shown_notfound_msg = true;
|
||||||
if (m_impp->m_incDirs.empty()) {
|
if (m_impp->m_incDirUsers.empty()) {
|
||||||
fl->v3error("This may be because there's no search path specified with -I<dir>."<<endl);
|
fl->v3error("This may be because there's no search path specified with -I<dir>."<<endl);
|
||||||
} else {
|
}
|
||||||
fl->v3error("Looked in:"<<endl);
|
fl->v3error("Looked in:"<<endl);
|
||||||
for (list<string>::iterator dirIter=m_impp->m_incDirs.begin(); dirIter!=m_impp->m_incDirs.end(); ++dirIter) {
|
for (list<string>::iterator dirIter=m_impp->m_incDirUsers.begin();
|
||||||
for (list<string>::iterator extIter=m_impp->m_libExts.begin(); extIter!=m_impp->m_libExts.end(); ++extIter) {
|
dirIter!=m_impp->m_incDirUsers.end(); ++dirIter) {
|
||||||
string fn = filenameFromDirBase(*dirIter,modname+*extIter);
|
for (list<string>::iterator extIter=m_impp->m_libExts.begin(); extIter!=m_impp->m_libExts.end(); ++extIter) {
|
||||||
fl->v3error(" "<<fn<<endl);
|
string fn = filenameFromDirBase(*dirIter,modname+*extIter);
|
||||||
}
|
fl->v3error(" "<<fn<<endl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (list<string>::iterator dirIter=m_impp->m_incDirFallbacks.begin();
|
||||||
|
dirIter!=m_impp->m_incDirFallbacks.end(); ++dirIter) {
|
||||||
|
for (list<string>::iterator extIter=m_impp->m_libExts.begin(); extIter!=m_impp->m_libExts.end(); ++extIter) {
|
||||||
|
string fn = filenameFromDirBase(*dirIter,modname+*extIter);
|
||||||
|
fl->v3error(" "<<fn<<endl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -573,7 +607,7 @@ void V3Options::parseOpts (FileLine* fl, int argc, char** argv) {
|
||||||
if (modPrefix()=="") m_modPrefix = prefix();
|
if (modPrefix()=="") m_modPrefix = prefix();
|
||||||
|
|
||||||
// Find files in makedir
|
// Find files in makedir
|
||||||
addIncDir(makeDir());
|
addIncDirFallback(makeDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
@ -611,7 +645,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||||
addDefine (string (sw+strlen("+define+")));
|
addDefine (string (sw+strlen("+define+")));
|
||||||
}
|
}
|
||||||
else if ( !strncmp (sw, "+incdir+", 8)) {
|
else if ( !strncmp (sw, "+incdir+", 8)) {
|
||||||
addIncDir (parseFileArg(optdir, string (sw+strlen("+incdir+"))));
|
addIncDirUser (parseFileArg(optdir, string (sw+strlen("+incdir+"))));
|
||||||
}
|
}
|
||||||
else if ( !strncmp (sw, "+libext+", 8)) {
|
else if ( !strncmp (sw, "+libext+", 8)) {
|
||||||
string exts = string(sw+strlen("+libext+"));
|
string exts = string(sw+strlen("+libext+"));
|
||||||
|
|
@ -734,7 +768,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||||
m_errorLimit = atoi(argv[i]);
|
m_errorLimit = atoi(argv[i]);
|
||||||
}
|
}
|
||||||
else if ( !strncmp (sw, "-I", 2)) {
|
else if ( !strncmp (sw, "-I", 2)) {
|
||||||
addIncDir (parseFileArg(optdir, string (sw+strlen("-I"))));
|
addIncDirUser (parseFileArg(optdir, string (sw+strlen("-I"))));
|
||||||
}
|
}
|
||||||
else if ( !strcmp (sw, "-if-depth") && (i+1)<argc ) {
|
else if ( !strcmp (sw, "-if-depth") && (i+1)<argc ) {
|
||||||
shift;
|
shift;
|
||||||
|
|
@ -759,7 +793,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||||
}
|
}
|
||||||
else if ( !strcmp (sw, "-Mdir") && (i+1)<argc ) {
|
else if ( !strcmp (sw, "-Mdir") && (i+1)<argc ) {
|
||||||
shift; m_makeDir = argv[i];
|
shift; m_makeDir = argv[i];
|
||||||
addIncDir (string (m_makeDir)); // Need to find generated files there too
|
addIncDirFallback (string (m_makeDir)); // Need to find generated files there too
|
||||||
}
|
}
|
||||||
else if ( !strcmp (sw, "-o") && (i+1)<argc ) {
|
else if ( !strcmp (sw, "-o") && (i+1)<argc ) {
|
||||||
shift; m_exeName = argv[i];
|
shift; m_exeName = argv[i];
|
||||||
|
|
@ -925,7 +959,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !strcmp (sw, "-y") && (i+1)<argc ) {
|
else if ( !strcmp (sw, "-y") && (i+1)<argc ) {
|
||||||
shift; addIncDir (parseFileArg(optdir,string (argv[i])));
|
shift; addIncDirUser (parseFileArg(optdir,string (argv[i])));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fl->v3fatal ("Invalid Option: "<<argv[i]);
|
fl->v3fatal ("Invalid Option: "<<argv[i]);
|
||||||
|
|
@ -1140,7 +1174,7 @@ V3Options::V3Options() {
|
||||||
addLibExt(".v");
|
addLibExt(".v");
|
||||||
addLibExt(".sv");
|
addLibExt(".sv");
|
||||||
// Default -I
|
// Default -I
|
||||||
addIncDir("."); // Looks better than {long_cwd_path}/...
|
addIncDirFallback("."); // Looks better than {long_cwd_path}/...
|
||||||
}
|
}
|
||||||
|
|
||||||
V3Options::~V3Options() {
|
V3Options::~V3Options() {
|
||||||
|
|
|
||||||
|
|
@ -178,10 +178,11 @@ class V3Options {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// METHODS
|
// METHODS
|
||||||
void addArg(const string& incdir);
|
void addArg(const string& flag);
|
||||||
void addDefine(const string& defline);
|
void addDefine(const string& defline);
|
||||||
void addFuture(const string& flag);
|
void addFuture(const string& flag);
|
||||||
void addIncDir(const string& incdir);
|
void addIncDirUser(const string& incdir); // User requested
|
||||||
|
void addIncDirFallback(const string& incdir); // Low priority if not found otherwise
|
||||||
void addLibExt(const string& libext);
|
void addLibExt(const string& libext);
|
||||||
void optimize(int level);
|
void optimize(int level);
|
||||||
void showVersion(bool verbose);
|
void showVersion(bool verbose);
|
||||||
|
|
@ -189,6 +190,7 @@ class V3Options {
|
||||||
bool onoff(const char* sw, const char* arg, bool& flag);
|
bool onoff(const char* sw, const char* arg, bool& flag);
|
||||||
bool suffixed(const char* sw, const char* arg);
|
bool suffixed(const char* sw, const char* arg);
|
||||||
string parseFileArg(const string& optdir, const string& relfilename);
|
string parseFileArg(const string& optdir, const string& relfilename);
|
||||||
|
string filePathCheckOneDir(const string& modname, const string& dirname);
|
||||||
|
|
||||||
static bool wildmatchi(const char* s, const char* p);
|
static bool wildmatchi(const char* s, const char* p);
|
||||||
static string getenvStr(const string& envvar, const string& defaultValue);
|
static string getenvStr(const string& envvar, const string& defaultValue);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ compile (
|
||||||
fails=>$Self->{v3},
|
fails=>$Self->{v3},
|
||||||
nc=>0, # Need to get it not to give the prompt
|
nc=>0, # Need to get it not to give the prompt
|
||||||
expect=>
|
expect=>
|
||||||
'%Error: Specified --top-module \'a\' isn.t at the top level, it.s under another cell.
|
'%Error: Specified --top-module \'a\' isn.t at the top level, it.s under another cell \'a_top\'
|
||||||
%Error: Exiting due to.*',
|
%Error: Exiting due to.*',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ compile (
|
||||||
expect=>
|
expect=>
|
||||||
'%Error: t/t_gen_missing.v:\d+: Cannot find file containing module: foo_not_needed
|
'%Error: t/t_gen_missing.v:\d+: Cannot find file containing module: foo_not_needed
|
||||||
%Error: t/t_gen_missing.v:\d+: Looked in:
|
%Error: t/t_gen_missing.v:\d+: Looked in:
|
||||||
%Error: t/t_gen_missing.v:\d+: foo_not_needed
|
%Error: t/t_gen_missing.v:\d+: t/foo_not_needed
|
||||||
%Error: t/t_gen_missing.v:\d+: foo_not_needed.v
|
%Error: t/t_gen_missing.v:\d+: t/foo_not_needed.v
|
||||||
%Error: t/t_gen_missing.v:\d+: foo_not_needed.sv
|
%Error: t/t_gen_missing.v:\d+: t/foo_not_needed.sv
|
||||||
.*%Error: Exiting due to.*',
|
.*%Error: Exiting due to.*',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue