diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-01-07 16:36:13 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-01-07 16:36:13 +0100 |
commit | a96c775a7301645b27486a5e663c75fca460f577 (patch) | |
tree | 18ab72d9bcf1fe0da59e993f71dc2ccf09f21066 /kernel | |
parent | 446ccf1f05b2b36db9161bf4ab050778a1cbaee6 (diff) | |
download | yosys-a96c775a7301645b27486a5e663c75fca460f577.tar.gz yosys-a96c775a7301645b27486a5e663c75fca460f577.tar.bz2 yosys-a96c775a7301645b27486a5e663c75fca460f577.zip |
Add support for "yosys -E"
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/driver.cc | 27 | ||||
-rw-r--r-- | kernel/register.cc | 2 | ||||
-rw-r--r-- | kernel/yosys.cc | 6 | ||||
-rw-r--r-- | kernel/yosys.h | 3 |
4 files changed, 36 insertions, 2 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc index c5e31d718..f49f6023b 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -160,6 +160,7 @@ int main(int argc, char **argv) std::vector<std::string> plugin_filenames; std::string output_filename = ""; std::string scriptfile = ""; + std::string depsfile = ""; bool scriptfile_tcl = false; bool got_output_filename = false; bool print_banner = true; @@ -256,6 +257,9 @@ int main(int argc, char **argv) printf(" if a warning message matches the regex, it is printes as regular\n"); printf(" message instead.\n"); printf("\n"); + printf(" -E <depsfile>\n"); + printf(" write a Makefile dependencies file with in- and output file names\n"); + printf("\n"); printf(" -V\n"); printf(" print version information and exit\n"); printf("\n"); @@ -276,7 +280,7 @@ int main(int argc, char **argv) } int opt; - while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:D:")) != -1) + while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:D:E:")) != -1) { switch (opt) { @@ -392,6 +396,9 @@ int main(int argc, char **argv) } } break; + case 'E': + depsfile = optarg; + break; default: fprintf(stderr, "Run '%s -h' for help.\n", argv[0]); exit(1); @@ -442,6 +449,24 @@ int main(int argc, char **argv) if (!backend_command.empty()) run_backend(output_filename, backend_command); + if (!depsfile.empty()) + { + FILE *f = fopen(depsfile.c_str(), "wt"); + if (f == nullptr) + log_error("Can't open dependencies file for writing: %s\n", strerror(errno)); + bool first = true; + for (auto fn : yosys_output_files) { + fprintf(f, "%s%s", first ? "" : " ", fn.c_str()); + first = false; + } + fprintf(f, ":"); + for (auto fn : yosys_input_files) { + if (yosys_output_files.count(fn) == 0) + fprintf(f, " %s", fn.c_str()); + } + fprintf(f, "\n"); + } + if (print_stats) { std::string hash = log_hasher->final().substr(0, 10); diff --git a/kernel/register.cc b/kernel/register.cc index 983577682..e30414f44 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -428,6 +428,7 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s } std::ifstream *ff = new std::ifstream; ff->open(filename.c_str()); + yosys_input_files.insert(filename); if (ff->fail()) delete ff; else @@ -543,6 +544,7 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st filename = arg; std::ofstream *ff = new std::ofstream; ff->open(filename.c_str(), std::ofstream::trunc); + yosys_output_files.insert(filename); if (ff->fail()) { delete ff; log_cmd_error("Can't open output file `%s' for writing: %s\n", filename.c_str(), strerror(errno)); diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 34665a0ad..987ebcdce 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -64,6 +64,8 @@ CellTypes yosys_celltypes; Tcl_Interp *yosys_tcl_interp = NULL; #endif +std::set<std::string> yosys_input_files, yosys_output_files; + bool memhasher_active = false; uint32_t memhasher_rng = 123456; std::vector<void*> memhasher_store; @@ -831,8 +833,10 @@ void run_frontend(std::string filename, std::string command, std::string *backen FILE *f = stdin; - if (filename != "-") + if (filename != "-") { f = fopen(filename.c_str(), "r"); + yosys_input_files.insert(filename); + } if (f == NULL) log_error("Can't open script file `%s' for reading: %s\n", filename.c_str(), strerror(errno)); diff --git a/kernel/yosys.h b/kernel/yosys.h index 5ec681b32..14cbcd610 100644 --- a/kernel/yosys.h +++ b/kernel/yosys.h @@ -305,6 +305,9 @@ void run_frontend(std::string filename, std::string command, RTLIL::Design *desi void run_backend(std::string filename, std::string command, RTLIL::Design *design = nullptr); void shell(RTLIL::Design *design); +// journal of all input and output files read (for "yosys -E") +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; |