std::ifstream f;
f.open(mem_filename.c_str());
+ yosys_input_files.insert(mem_filename);
if (f.fail())
log_error("Can not open file `%s` for %s at %s:%d.\n", mem_filename.c_str(), str.c_str(), filename.c_str(), linenum);
if (!ff.fail()) break;
}
}
- if (ff.fail())
+ if (ff.fail()) {
output_code.push_back("`file_notfound " + fn);
- else
+ } else {
input_file(ff, fixed_fn);
+ yosys_input_files.insert(fixed_fn);
+ }
continue;
}
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;
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");
}
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)
{
}
}
break;
+ case 'E':
+ depsfile = optarg;
+ break;
default:
fprintf(stderr, "Run '%s -h' for help.\n", argv[0]);
exit(1);
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);
}
std::ifstream *ff = new std::ifstream;
ff->open(filename.c_str());
+ yosys_input_files.insert(filename);
if (ff->fail())
delete ff;
else
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));
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;
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));
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;
}
if (args[argidx] == "-dump" && argidx+1 < args.size()) {
config.dump_file.open(args[++argidx], std::ofstream::trunc);
+ yosys_output_files.insert(args[argidx]);
continue;
}
break;
log_cmd_error("Option -read can not be combined with a selection expression.\n");
std::ifstream f(read_file);
+ yosys_input_files.insert(read_file);
if (f.fail())
log_error("Can't open '%s' for reading: %s\n", read_file.c_str(), strerror(errno));
FILE *f = NULL;
if (!write_file.empty()) {
f = fopen(write_file.c_str(), "w");
+ yosys_output_files.insert(write_file);
if (f == NULL)
log_error("Can't open '%s' for writing: %s\n", write_file.c_str(), strerror(errno));
}
bool flag_enum = false;
bool flag_abbreviate = true;
bool flag_notitle = false;
+ bool custom_prefix = false;
RTLIL::IdString colorattr;
size_t argidx;
}
if (arg == "-prefix" && argidx+1 < args.size()) {
prefix = args[++argidx];
+ custom_prefix = true;
continue;
}
if (arg == "-color" && argidx+2 < args.size()) {
for (auto filename : libfiles) {
std::ifstream f;
f.open(filename.c_str());
+ yosys_input_files.insert(filename);
if (f.fail())
log_error("Can't open lib file `%s'.\n", filename.c_str());
RTLIL::Design *lib = new RTLIL::Design;
log("Writing dot description to `%s'.\n", dot_file.c_str());
FILE *f = fopen(dot_file.c_str(), "w");
+ if (custom_prefix)
+ yosys_output_files.insert(dot_file);
if (f == NULL) {
for (auto lib : libs)
delete lib;
{
std::ifstream f;
f.open(liberty_file.c_str());
+ yosys_input_files.insert(liberty_file);
if (f.fail())
log_cmd_error("Can't open liberty file `%s': %s\n", liberty_file.c_str(), strerror(errno));
LibertyParser libparser(f);
if ((args[argidx] == "-o" || args[argidx] == "-a") && argidx+1 < args.size()) {
const char *open_mode = args[argidx] == "-o" ? "w" : "a+";
FILE *f = fopen(args[++argidx].c_str(), open_mode);
+ yosys_input_files.insert(args[argidx]);
if (f == NULL) {
for (auto cf : files_to_close)
fclose(cf);
extra_args(f, filename, args, argidx);
FILE *of = fopen(output_filename.c_str(), append_mode ? "a" : "w");
+ yosys_output_files.insert(output_filename);
char buffer[64 * 1024];
int bytes;
std::ifstream f;
rewrite_filename(fn);
f.open(fn.c_str());
+ yosys_input_files.insert(fn);
if (f.fail())
log_cmd_error("Can't open map file `%s'\n", fn.c_str());
Frontend::frontend_call(map, &f, fn, (fn.size() > 3 && fn.substr(fn.size()-3) == ".il") ? "ilang" : verilog_frontend);