aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/driver.cc27
-rw-r--r--kernel/register.cc2
-rw-r--r--kernel/yosys.cc6
-rw-r--r--kernel/yosys.h3
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;