mirror of
https://github.com/YosysHQ/yosys
synced 2025-05-10 01:05:49 +00:00
Merge 3326d169c0
into aa30589c12
This commit is contained in:
commit
060267b870
2 changed files with 32 additions and 9 deletions
|
@ -552,16 +552,36 @@ void Backend::execute(std::vector<std::string> args, RTLIL::Design *design)
|
||||||
{
|
{
|
||||||
std::ostream *f = NULL;
|
std::ostream *f = NULL;
|
||||||
auto state = pre_execute();
|
auto state = pre_execute();
|
||||||
execute(f, std::string(), args, design);
|
bool restore_log_cmd_error_throw = log_cmd_error_throw;
|
||||||
post_execute(state);
|
log_cmd_error_throw = true;
|
||||||
if (f != &std::cout)
|
try {
|
||||||
delete f;
|
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)
|
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++)
|
for (; argidx < args.size(); argidx++)
|
||||||
{
|
{
|
||||||
std::string arg = args[argidx];
|
std::string arg = args[argidx];
|
||||||
|
@ -571,8 +591,9 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
cmd_error(args, argidx, "Extra filename argument in direct file mode.");
|
cmd_error(args, argidx, "Extra filename argument in direct file mode.");
|
||||||
|
|
||||||
if (arg == "-") {
|
if (arg == "-") {
|
||||||
filename = "<stdout>";
|
filename = "<stdout>";
|
||||||
|
filenames.push_back(filename);
|
||||||
f = &std::cout;
|
f = &std::cout;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -587,6 +608,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));
|
log_cmd_error("Can't open output file `%s' for writing: %s\n", filename.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
yosys_output_files.insert(filename);
|
yosys_output_files.insert(filename);
|
||||||
|
filenames.push_back(filename);
|
||||||
f = gf;
|
f = gf;
|
||||||
#else
|
#else
|
||||||
log_cmd_error("Yosys is compiled without zlib support, unable to write gzip output.\n");
|
log_cmd_error("Yosys is compiled without zlib support, unable to write gzip output.\n");
|
||||||
|
@ -599,18 +621,18 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
|
||||||
delete ff;
|
delete ff;
|
||||||
log_cmd_error("Can't open output file `%s' for writing: %s\n", filename.c_str(), strerror(errno));
|
log_cmd_error("Can't open output file `%s' for writing: %s\n", filename.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
|
filenames.push_back(filename);
|
||||||
f = ff;
|
f = ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (called_with_fp)
|
|
||||||
args.push_back(filename);
|
|
||||||
args[0] = pass_name;
|
args[0] = pass_name;
|
||||||
// cmd_log_args(args);
|
// cmd_log_args(args);
|
||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
filename = "<stdout>";
|
filename = "<stdout>";
|
||||||
f = &std::cout;
|
f = &std::cout;
|
||||||
|
filenames.push_back(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ struct Frontend : Pass
|
||||||
struct Backend : Pass
|
struct Backend : Pass
|
||||||
{
|
{
|
||||||
std::string backend_name;
|
std::string backend_name;
|
||||||
|
std::vector<std::string> filenames;
|
||||||
Backend(std::string name, std::string short_help = "** document me **");
|
Backend(std::string name, std::string short_help = "** document me **");
|
||||||
void run_register() override;
|
void run_register() override;
|
||||||
~Backend() override;
|
~Backend() override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue