mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
clang-format remaining sources. No functional change.
This commit is contained in:
+36
-30
@@ -35,8 +35,7 @@ class CMakeEmitter {
|
||||
// STATIC FUNCTIONS
|
||||
|
||||
// Concatenate all strings in 'strs' with ' ' between them.
|
||||
template<typename List>
|
||||
static string cmake_list(const List& strs) {
|
||||
template <typename List> static string cmake_list(const List& strs) {
|
||||
string s;
|
||||
if (strs.begin() != strs.end()) {
|
||||
s.append("\"");
|
||||
@@ -56,16 +55,14 @@ class CMakeEmitter {
|
||||
// "BOOL", "FILEPATH", "PATH", "STRING" or "INTERNAL" for a CACHE variable
|
||||
// See https://cmake.org/cmake/help/latest/command/set.html
|
||||
static void cmake_set_raw(std::ofstream& of, const string& name, const string& raw_value,
|
||||
const string& cache_type = "", const string& docstring = "") {
|
||||
const string& cache_type = "", const string& docstring = "") {
|
||||
of << "set(" << name << " " << raw_value;
|
||||
if (!cache_type.empty()) {
|
||||
of << " CACHE " << cache_type << " \"" << docstring << "\"";
|
||||
}
|
||||
if (!cache_type.empty()) { of << " CACHE " << cache_type << " \"" << docstring << "\""; }
|
||||
of << ")\n";
|
||||
}
|
||||
|
||||
static void cmake_set(std::ofstream& of, const string& name, const string& value,
|
||||
const string& cache_type = "", const string& docstring = "") {
|
||||
const string& cache_type = "", const string& docstring = "") {
|
||||
string raw_value = "\"" + value + "\"";
|
||||
cmake_set_raw(of, name, raw_value, cache_type, docstring);
|
||||
}
|
||||
@@ -80,22 +77,24 @@ class CMakeEmitter {
|
||||
}
|
||||
|
||||
static void emitOverallCMake() {
|
||||
const vl_unique_ptr<std::ofstream>
|
||||
of (V3File::new_ofstream(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+".cmake"));
|
||||
const vl_unique_ptr<std::ofstream> of(
|
||||
V3File::new_ofstream(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".cmake"));
|
||||
string name = v3Global.opt.prefix();
|
||||
|
||||
*of << "# Verilated -*- CMake -*-\n";
|
||||
*of << "# DESCR" "IPTION: Verilator output: CMake include script with class lists\n";
|
||||
*of << "# DESCR"
|
||||
"IPTION: Verilator output: CMake include script with class lists\n";
|
||||
*of << "#\n";
|
||||
*of << "# This CMake script lists generated Verilated files, for including in higher level CMake scripts.\n";
|
||||
*of << "# This CMake script lists generated Verilated files, for "
|
||||
"including in higher level CMake scripts.\n";
|
||||
*of << "# This file is meant to be consumed by the verilate() function,\n";
|
||||
*of << "# which becomes available after executing `find_package(verilator).\n";
|
||||
|
||||
*of << "\n### Constants...\n";
|
||||
cmake_set(*of, "PERL", deslash(V3Options::getenvPERL()),
|
||||
"FILEPATH", "Perl executable (from $PERL)");
|
||||
cmake_set(*of, "VERILATOR_ROOT", deslash(V3Options::getenvVERILATOR_ROOT()),
|
||||
"PATH", "Path to Verilator kit (from $VERILATOR_ROOT)");
|
||||
cmake_set(*of, "PERL", deslash(V3Options::getenvPERL()), "FILEPATH",
|
||||
"Perl executable (from $PERL)");
|
||||
cmake_set(*of, "VERILATOR_ROOT", deslash(V3Options::getenvVERILATOR_ROOT()), "PATH",
|
||||
"Path to Verilator kit (from $VERILATOR_ROOT)");
|
||||
|
||||
*of << "\n### Compiler flags...\n";
|
||||
|
||||
@@ -110,13 +109,19 @@ class CMakeEmitter {
|
||||
*of << "# SystemC output mode? 0/1 (from --sc)\n";
|
||||
cmake_set_raw(*of, name + "_SC", v3Global.opt.systemC() ? "1" : "0");
|
||||
*of << "# Coverage output mode? 0/1 (from --coverage)\n";
|
||||
cmake_set_raw(*of, name + "_COVERAGE", v3Global.opt.coverage()?"1":"0");
|
||||
cmake_set_raw(*of, name + "_COVERAGE", v3Global.opt.coverage() ? "1" : "0");
|
||||
*of << "# Threaded output mode? 0/1/N threads (from --threads)\n";
|
||||
cmake_set_raw(*of, name + "_THREADS", cvtToStr(v3Global.opt.threads()));
|
||||
*of << "# VCD Tracing output mode? 0/1 (from --trace)\n";
|
||||
cmake_set_raw(*of, name + "_TRACE_VCD", (v3Global.opt.trace() && (v3Global.opt.traceFormat() == TraceFormat::VCD))?"1":"0");
|
||||
cmake_set_raw(*of, name + "_TRACE_VCD",
|
||||
(v3Global.opt.trace() && (v3Global.opt.traceFormat() == TraceFormat::VCD))
|
||||
? "1"
|
||||
: "0");
|
||||
*of << "# FST Tracing output mode? 0/1 (from --fst-trace)\n";
|
||||
cmake_set_raw(*of, name + "_TRACE_FST", (v3Global.opt.trace() && (v3Global.opt.traceFormat() != TraceFormat::VCD)) ? "1":"0");
|
||||
cmake_set_raw(*of, name + "_TRACE_FST",
|
||||
(v3Global.opt.trace() && (v3Global.opt.traceFormat() != TraceFormat::VCD))
|
||||
? "1"
|
||||
: "0");
|
||||
|
||||
*of << "\n### Sources...\n";
|
||||
std::vector<string> classes_fast, classes_slow, support_fast, support_slow, global;
|
||||
@@ -141,7 +146,7 @@ class CMakeEmitter {
|
||||
}
|
||||
|
||||
global.push_back("${VERILATOR_ROOT}/include/verilated.cpp");
|
||||
if (v3Global.dpi()) {
|
||||
if (v3Global.dpi()) { //
|
||||
global.push_back("${VERILATOR_ROOT}/include/verilated_dpi.cpp");
|
||||
}
|
||||
if (v3Global.opt.vpi()) {
|
||||
@@ -154,21 +159,22 @@ class CMakeEmitter {
|
||||
global.push_back("${VERILATOR_ROOT}/include/verilated_cov.cpp");
|
||||
}
|
||||
if (v3Global.opt.trace()) {
|
||||
global.push_back("${VERILATOR_ROOT}/include/"
|
||||
+ v3Global.opt.traceSourceBase() + "_c.cpp");
|
||||
global.push_back("${VERILATOR_ROOT}/include/" + v3Global.opt.traceSourceBase()
|
||||
+ "_c.cpp");
|
||||
if (v3Global.opt.systemC()) {
|
||||
if (v3Global.opt.traceFormat() != TraceFormat::VCD) {
|
||||
v3error("Unsupported: This trace format is not supported in SystemC, use VCD format.");
|
||||
v3error("Unsupported: This trace format is not supported in SystemC, "
|
||||
"use VCD format.");
|
||||
}
|
||||
global.push_back("${VERILATOR_ROOT}/include/"
|
||||
+ v3Global.opt.traceSourceLang() + ".cpp");
|
||||
global.push_back("${VERILATOR_ROOT}/include/" + v3Global.opt.traceSourceLang()
|
||||
+ ".cpp");
|
||||
}
|
||||
}
|
||||
if (v3Global.opt.mtasks()) {
|
||||
global.push_back("${VERILATOR_ROOT}/include/verilated_threads.cpp");
|
||||
}
|
||||
if (!v3Global.opt.protectLib().empty()) {
|
||||
global.push_back(v3Global.opt.makeDir()+"/"+v3Global.opt.protectLib()+".cpp");
|
||||
global.push_back(v3Global.opt.makeDir() + "/" + v3Global.opt.protectLib() + ".cpp");
|
||||
}
|
||||
|
||||
*of << "# Global classes, need linked once per executable\n";
|
||||
@@ -177,7 +183,8 @@ class CMakeEmitter {
|
||||
cmake_set_raw(*of, name + "_CLASSES_SLOW", deslash(cmake_list(classes_slow)));
|
||||
*of << "# Generated module classes, fast-path, compile with highest optimization\n";
|
||||
cmake_set_raw(*of, name + "_CLASSES_FAST", deslash(cmake_list(classes_fast)));
|
||||
*of << "# Generated support classes, non-fast-path, compile with low/medium optimization\n";
|
||||
*of << "# Generated support classes, non-fast-path, compile with "
|
||||
"low/medium optimization\n";
|
||||
cmake_set_raw(*of, name + "_SUPPORT_SLOW", deslash(cmake_list(support_slow)));
|
||||
*of << "# Generated support classes, fast-path, compile with highest optimization\n";
|
||||
cmake_set_raw(*of, name + "_SUPPORT_FAST", deslash(cmake_list(support_fast)));
|
||||
@@ -188,14 +195,13 @@ class CMakeEmitter {
|
||||
*of << "# User .cpp files (from .cpp's on Verilator command line)\n";
|
||||
cmake_set_raw(*of, name + "_USER_CLASSES", deslash(cmake_list(v3Global.opt.cppFiles())));
|
||||
}
|
||||
|
||||
public:
|
||||
explicit CMakeEmitter() {
|
||||
emitOverallCMake();
|
||||
}
|
||||
explicit CMakeEmitter() { emitOverallCMake(); }
|
||||
virtual ~CMakeEmitter() {}
|
||||
};
|
||||
|
||||
void V3EmitCMake::emit() {
|
||||
UINFO(2,__FUNCTION__<<": "<<endl);
|
||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
CMakeEmitter emitter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user