3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-09 04:31:25 +00:00

Merge pull request #5086 from YosysHQ/emil/driver-no-version

driver: add --no-version to suppress writing Yosys version
This commit is contained in:
Emil J 2025-05-08 16:28:25 +02:00 committed by GitHub
commit bfbbb8cf98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 40 additions and 26 deletions

View file

@ -252,6 +252,7 @@ int main(int argc, char **argv)
options.add_options("logging")
("Q", "suppress printing of banner (copyright, disclaimer, version)")
("T", "suppress printing of footer (log hash, version, timing statistics)")
("no-version", "suppress writing out Yosys version anywhere excluding -V, --version")
("q,quiet", "quiet operation. Only write warnings and error messages to console. " \
"Use this option twice to also quiet warning messages")
("v,verbose", "print log headers up to <level> to the console. " \
@ -318,6 +319,7 @@ int main(int argc, char **argv)
if (result.count("A")) call_abort = true;
if (result.count("Q")) print_banner = false;
if (result.count("T")) print_stats = false;
if (result.count("no-version")) yosys_write_versions = false;
if (result.count("V")) {
std::cout << yosys_version_str << std::endl;
exit(0);
@ -691,7 +693,7 @@ int main(int argc, char **argv)
stats_divider.c_str(), ru_buffer.ru_utime.tv_sec + 1e-6 * ru_buffer.ru_utime.tv_usec,
ru_buffer.ru_stime.tv_sec + 1e-6 * ru_buffer.ru_stime.tv_usec, meminfo.c_str());
#endif
log("%s\n", yosys_version_str);
log("%s\n", yosys_maybe_version());
int64_t total_ns = 0;
std::set<tuple<int64_t, int, std::string>> timedat;
@ -731,7 +733,7 @@ int main(int argc, char **argv)
log_error("Can't open performance log file for writing: %s\n", strerror(errno));
fprintf(f, "{\n");
fprintf(f, " \"generator\": \"%s\",\n", yosys_version_str);
fprintf(f, " \"generator\": \"%s\",\n", yosys_maybe_version());
fprintf(f, " \"total_ns\": %" PRIu64 ",\n", total_ns);
fprintf(f, " \"passes\": {");

View file

@ -860,7 +860,7 @@ struct HelpPass : public Pass {
// init json
json.begin_object();
json.entry("version", "Yosys internal cells");
json.entry("generator", yosys_version_str);
json.entry("generator", yosys_maybe_version());
dict<string, vector<string>> groups;
dict<string, pair<SimHelper, CellType>> cells;

View file

@ -81,6 +81,14 @@ YOSYS_NAMESPACE_BEGIN
int autoidx = 1;
int yosys_xtrace = 0;
bool yosys_write_versions = true;
const char* yosys_maybe_version() {
if (yosys_write_versions)
return yosys_version_str;
else
return "Yosys";
}
RTLIL::Design *yosys_design = NULL;
CellTypes yosys_celltypes;
@ -144,7 +152,7 @@ void yosys_banner()
log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf <claire@yosyshq.com> |\n");
log(" | Distributed under an ISC-like license, type \"license\" to see terms |\n");
log(" \\----------------------------------------------------------------------------/\n");
log(" %s\n", yosys_version_str);
log(" %s\n", yosys_maybe_version());
}
#if !defined(YOSYS_DISABLE_SPAWN)

View file

@ -81,6 +81,7 @@ extern std::set<std::string> yosys_input_files, yosys_output_files;
// from kernel/version_*.o (cc source generated from Makefile)
extern const char *yosys_version_str;
const char* yosys_maybe_version();
// from passes/cmds/design.cc
extern std::map<std::string, RTLIL::Design*> saved_designs;

View file

@ -274,6 +274,7 @@ inline int GetSize(RTLIL::Wire *wire);
extern int autoidx;
extern int yosys_xtrace;
extern bool yosys_write_versions;
RTLIL::IdString new_id(std::string file, int line, std::string func);
RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std::string suffix);