mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Add -CFLAGS, -LDFLAGS, <file>.a, <file>.o, and <file>.so options.
This commit is contained in:
+16
-1
@@ -151,8 +151,23 @@ public:
|
||||
of.puts("# Module prefix (from --prefix)\n");
|
||||
of.puts(string("VM_MODPREFIX = ")+v3Global.opt.modPrefix()+"\n");
|
||||
|
||||
V3StringSet dirs;
|
||||
of.puts("# User CFLAGS (from -CFLAGS on Verilator command line)\n");
|
||||
of.puts("VM_USER_CFLAGS = \\\n");
|
||||
for (V3StringSet::const_iterator it = v3Global.opt.cFlags().begin();
|
||||
it != v3Global.opt.cFlags().end(); ++it) {
|
||||
of.puts("\t"+*it+" \\\n");
|
||||
}
|
||||
of.puts("\n");
|
||||
|
||||
of.puts("# User LDLIBS (from -LDFLAGS on Verilator command line)\n");
|
||||
of.puts("VM_USER_LDLIBS = \\\n");
|
||||
for (V3StringSet::const_iterator it = v3Global.opt.ldLibs().begin();
|
||||
it != v3Global.opt.ldLibs().end(); ++it) {
|
||||
of.puts("\t"+*it+" \\\n");
|
||||
}
|
||||
of.puts("\n");
|
||||
|
||||
V3StringSet dirs;
|
||||
of.puts("# User .cpp files (from .cpp's on Verilator command line)\n");
|
||||
of.puts("VM_USER_CLASSES = \\\n");
|
||||
for (V3StringSet::const_iterator it = v3Global.opt.cppFiles().begin();
|
||||
|
||||
+34
-5
@@ -97,6 +97,16 @@ void V3Options::addCppFile(const string& filename) {
|
||||
m_cppFiles.insert(filename);
|
||||
}
|
||||
}
|
||||
void V3Options::addCFlags(const string& filename) {
|
||||
if (m_cFlags.find(filename) == m_cFlags.end()) {
|
||||
m_cFlags.insert(filename);
|
||||
}
|
||||
}
|
||||
void V3Options::addLdLibs(const string& filename) {
|
||||
if (m_ldLibs.find(filename) == m_ldLibs.end()) {
|
||||
m_ldLibs.insert(filename);
|
||||
}
|
||||
}
|
||||
void V3Options::addFuture(const string& flag) {
|
||||
if (m_futures.find(flag) == m_futures.end()) {
|
||||
m_futures.insert(flag);
|
||||
@@ -538,6 +548,11 @@ bool V3Options::onoff(const char* sw, const char* arg, bool& flag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool V3Options::suffixed(const char* sw, const char* arg) {
|
||||
if (strlen(arg) > strlen(sw)) return false;
|
||||
return (0==strcmp(sw+strlen(sw)-strlen(arg), arg));
|
||||
}
|
||||
|
||||
void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) {
|
||||
// Parse parameters
|
||||
// Note argc and argv DO NOT INCLUDE the filename in [0]!!!
|
||||
@@ -717,12 +732,20 @@ void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
// Parameterized switches
|
||||
else if ( !strcmp (sw, "-CFLAGS") && (i+1)<argc ) {
|
||||
shift;
|
||||
addCFlags(argv[i]);
|
||||
}
|
||||
else if ( !strncmp (sw, "-D", 2)) {
|
||||
addDefine (string (sw+strlen("-D")));
|
||||
}
|
||||
else if ( !strncmp (sw, "-I", 2)) {
|
||||
addIncDir (string (sw+strlen("-I")));
|
||||
}
|
||||
else if ( !strcmp (sw, "-LDFLAGS") && (i+1)<argc ) {
|
||||
shift;
|
||||
addLdLibs(argv[i]);
|
||||
}
|
||||
else if ( !strcmp (sw, "-Mdir") && (i+1)<argc ) {
|
||||
shift; m_makeDir = argv[i];
|
||||
addIncDir (string (m_makeDir)); // Need to find generated files there too
|
||||
@@ -829,12 +852,18 @@ void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) {
|
||||
else {
|
||||
// Filename
|
||||
string filename = filenameSubstitute(argv[i]);
|
||||
if (filename.find(".cpp") != string::npos
|
||||
|| filename.find(".cxx") != string::npos
|
||||
|| filename.find(".cc") != string::npos
|
||||
|| filename.find(".sp") != string::npos) {
|
||||
if (suffixed(filename.c_str(), ".cpp")
|
||||
|| suffixed(filename.c_str(), ".cxx")
|
||||
|| suffixed(filename.c_str(), ".cc")
|
||||
|| suffixed(filename.c_str(), ".sp")) {
|
||||
V3Options::addCppFile(filename);
|
||||
} else {
|
||||
}
|
||||
else if (suffixed(filename.c_str(), ".a")
|
||||
|| suffixed(filename.c_str(), ".o")
|
||||
|| suffixed(filename.c_str(), ".so")) {
|
||||
V3Options::addLdLibs(filename);
|
||||
}
|
||||
else {
|
||||
V3Options::addVFile(filename);
|
||||
}
|
||||
shift;
|
||||
|
||||
@@ -86,6 +86,8 @@ class V3Options {
|
||||
V3OptionsImp* m_impp; // Slow hidden options
|
||||
|
||||
V3StringSet m_cppFiles; // argument: C++ files to link against
|
||||
V3StringSet m_cFlags; // argument: user CFLAGS
|
||||
V3StringSet m_ldLibs; // argument: user LDFLAGS
|
||||
V3StringSet m_futures; // argument: -Wfuture- list
|
||||
V3StringSet m_libraryFiles; // argument: Verilog -v files
|
||||
V3StringList m_vFiles; // argument: Verilog files to read
|
||||
@@ -176,6 +178,7 @@ class V3Options {
|
||||
void showVersion(bool verbose);
|
||||
void coverage(bool flag) { m_coverageLine = m_coverageToggle = m_coverageUser = flag; }
|
||||
bool onoff(const char* sw, const char* arg, bool& flag);
|
||||
bool suffixed(const char* sw, const char* arg);
|
||||
|
||||
static bool wildmatchi(const char* s, const char* p);
|
||||
static string getenvStr(const string& envvar, const string& defaultValue);
|
||||
@@ -192,6 +195,8 @@ class V3Options {
|
||||
|
||||
// METHODS
|
||||
void addCppFile(const string& filename);
|
||||
void addCFlags(const string& filename);
|
||||
void addLdLibs(const string& filename);
|
||||
void addLibraryFile(const string& filename);
|
||||
void addVFile(const string& filename);
|
||||
|
||||
@@ -254,6 +259,8 @@ class V3Options {
|
||||
string xAssign() const { return m_xAssign; }
|
||||
|
||||
const V3StringSet& cppFiles() const { return m_cppFiles; }
|
||||
const V3StringSet& cFlags() const { return m_cFlags; }
|
||||
const V3StringSet& ldLibs() const { return m_ldLibs; }
|
||||
const V3StringSet& libraryFiles() const { return m_libraryFiles; }
|
||||
const V3StringList& vFiles() const { return m_vFiles; }
|
||||
const V3LangCode& language() const { return m_language; }
|
||||
|
||||
Reference in New Issue
Block a user