opt_dff: Fix NOT gates wired in reverse.
[yosys.git] / passes / cmds / tee.cc
index 6f80ef72c035ed3147cc55a0e23dd4c33e6fea41..60689fc825ae6af6ed8932d6ac65e20a34e9ad10 100644 (file)
 #include "kernel/rtlil.h"
 #include "kernel/log.h"
 
+USING_YOSYS_NAMESPACE
+PRIVATE_NAMESPACE_BEGIN
+
 struct TeePass : public Pass {
        TeePass() : Pass("tee", "redirect command output to file") { }
-       virtual void help()
+       void help() override
        {
                //   |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
                log("\n");
@@ -34,7 +37,7 @@ struct TeePass : public Pass {
                log("specified logfile(s).\n");
                log("\n");
                log("    -q\n");
-               log("        Do not print output to the normal destination (console and/or log file)\n");
+               log("        Do not print output to the normal destination (console and/or log file).\n");
                log("\n");
                log("    -o logfile\n");
                log("        Write output to this file, truncate if exists.\n");
@@ -42,10 +45,16 @@ struct TeePass : public Pass {
                log("    -a logfile\n");
                log("        Write output to this file, append if exists.\n");
                log("\n");
+               log("    +INT, -INT\n");
+               log("        Add/subtract INT from the -v setting for this command.\n");
+               log("\n");
        }
-       virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
+       void execute(std::vector<std::string> args, RTLIL::Design *design) override
        {
                std::vector<FILE*> backup_log_files, files_to_close;
+               std::vector<std::ostream*> backup_log_streams;
+               int backup_log_verbose_level = log_verbose_level;
+               backup_log_streams = log_streams;
                backup_log_files = log_files;
 
                size_t argidx;
@@ -53,11 +62,13 @@ struct TeePass : public Pass {
                {
                        if (args[argidx] == "-q" && files_to_close.empty()) {
                                log_files.clear();
+                               log_streams.clear();
                                continue;
                        }
                        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);
@@ -67,22 +78,31 @@ struct TeePass : public Pass {
                                files_to_close.push_back(f);
                                continue;
                        }
+                       if (GetSize(args[argidx]) >= 2 && (args[argidx][0] == '-' || args[argidx][0] == '+') && args[argidx][1] >= '0' && args[argidx][1] <= '9') {
+                               log_verbose_level += atoi(args[argidx].c_str());
+                               continue;
+                       }
                        break;
                }
 
                try {
                        std::vector<std::string> new_args(args.begin() + argidx, args.end());
                        Pass::call(design, new_args);
-               } catch (log_cmd_error_expection) {
+               } catch (...) {
                        for (auto cf : files_to_close)
                                fclose(cf);
                        log_files = backup_log_files;
-                       throw log_cmd_error_expection();
+                       log_streams = backup_log_streams;
+                       throw;
                }
 
                for (auto cf : files_to_close)
                        fclose(cf);
+
+               log_verbose_level = backup_log_verbose_level;
                log_files = backup_log_files;
+               log_streams = backup_log_streams;
        }
 } TeePass;
 
+PRIVATE_NAMESPACE_END