mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-11 03:33:36 +00:00
Merge 3326d169c0
into c08f72b806
This commit is contained in:
commit
d1bc47de80
|
@ -554,16 +554,36 @@ void Backend::execute(std::vector<std::string> args, RTLIL::Design *design)
|
|||
{
|
||||
std::ostream *f = NULL;
|
||||
auto state = pre_execute();
|
||||
execute(f, std::string(), args, design);
|
||||
post_execute(state);
|
||||
if (f != &std::cout)
|
||||
delete f;
|
||||
bool restore_log_cmd_error_throw = log_cmd_error_throw;
|
||||
log_cmd_error_throw = true;
|
||||
try {
|
||||
execute(f, std::string(), args, design);
|
||||
post_execute(state);
|
||||
} catch(log_cmd_error_exception& _) {
|
||||
if (f && (f != &std::cout)) {
|
||||
delete f;
|
||||
f = NULL;
|
||||
|
||||
for(auto& itr : filenames) {
|
||||
if ( itr == "<stdout>" ) continue;
|
||||
int code = std::remove(itr.c_str());
|
||||
if ( code )
|
||||
log("\t Failed to deleted file %s - with exitcode %d\n",itr.c_str(),code);
|
||||
}
|
||||
}
|
||||
log_cmd_error_throw = restore_log_cmd_error_throw;
|
||||
if ( log_cmd_error_throw )
|
||||
throw log_cmd_error_exception();
|
||||
}
|
||||
|
||||
log_cmd_error_throw = restore_log_cmd_error_throw;
|
||||
if (f && (f != &std::cout)) {
|
||||
delete f;
|
||||
}
|
||||
}
|
||||
|
||||
void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx, bool bin_output)
|
||||
{
|
||||
bool called_with_fp = f != NULL;
|
||||
|
||||
for (; argidx < args.size(); argidx++)
|
||||
{
|
||||
std::string arg = args[argidx];
|
||||
|
@ -573,8 +593,9 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
|
|||
if (f != NULL)
|
||||
cmd_error(args, argidx, "Extra filename argument in direct file mode.");
|
||||
|
||||
if (arg == "-") {
|
||||
if (arg == "-") {
|
||||
filename = "<stdout>";
|
||||
filenames.push_back(filename);
|
||||
f = &std::cout;
|
||||
continue;
|
||||
}
|
||||
|
@ -589,6 +610,7 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
|
|||
log_cmd_error("Can't open output file `%s' for writing: %s\n", filename.c_str(), strerror(errno));
|
||||
}
|
||||
yosys_output_files.insert(filename);
|
||||
filenames.push_back(filename);
|
||||
f = gf;
|
||||
#else
|
||||
log_cmd_error("Yosys is compiled without zlib support, unable to write gzip output.\n");
|
||||
|
@ -601,18 +623,18 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
|
|||
delete ff;
|
||||
log_cmd_error("Can't open output file `%s' for writing: %s\n", filename.c_str(), strerror(errno));
|
||||
}
|
||||
filenames.push_back(filename);
|
||||
f = ff;
|
||||
}
|
||||
}
|
||||
|
||||
if (called_with_fp)
|
||||
args.push_back(filename);
|
||||
args[0] = pass_name;
|
||||
// cmd_log_args(args);
|
||||
|
||||
if (f == NULL) {
|
||||
filename = "<stdout>";
|
||||
f = &std::cout;
|
||||
filenames.push_back(filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ struct Frontend : Pass
|
|||
struct Backend : Pass
|
||||
{
|
||||
std::string backend_name;
|
||||
std::vector<std::string> filenames;
|
||||
Backend(std::string name, std::string short_help = "** document me **");
|
||||
void run_register() override;
|
||||
~Backend() override;
|
||||
|
|
Loading…
Reference in a new issue