3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-11 03:33:36 +00:00
This commit is contained in:
Muthu Annamalai (முத்து அண்ணாமலை) 2025-04-01 10:07:14 +00:00 committed by GitHub
commit d1bc47de80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 9 deletions

View file

@ -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);
}
}

View file

@ -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;