summaryrefslogtreecommitdiff
path: root/frontends/vhdl2verilog
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-10-12 12:11:57 +0200
committerClifford Wolf <clifford@clifford.at>2014-10-12 12:11:57 +0200
commit0b9282a779867459fe5babfff300795c343c46ea (patch)
tree58cd6e254eeeaf2bd812306835dce98baea2a66e /frontends/vhdl2verilog
parent9b4d171e37aa23adbdbad1ca1e983e4bf35604f9 (diff)
Added make_temp_{file,dir}() and remove_directory() APIs
Diffstat (limited to 'frontends/vhdl2verilog')
-rw-r--r--frontends/vhdl2verilog/vhdl2verilog.cc26
1 files changed, 8 insertions, 18 deletions
diff --git a/frontends/vhdl2verilog/vhdl2verilog.cc b/frontends/vhdl2verilog/vhdl2verilog.cc
index 3895ecfd..39b4f149 100644
--- a/frontends/vhdl2verilog/vhdl2verilog.cc
+++ b/frontends/vhdl2verilog/vhdl2verilog.cc
@@ -120,15 +120,8 @@ struct Vhdl2verilogPass : public Pass {
if (top_entity.empty())
log_cmd_error("Missing -top option.\n");
-#ifdef _WIN32
- #warning Fixme: The vhdl2veriog command has not been ported to win32.
- log_cmd_error("The vhdl2veriog command has not been ported to win32.\n");
-#else
- char tempdir_name[] = "/tmp/yosys-vhdl2verilog-XXXXXX";
- char *p = mkdtemp(tempdir_name);
- log("Using temp directory %s.\n", tempdir_name);
- if (p == NULL)
- log_error("For some reason mkdtemp() failed!\n");
+ std::string tempdir_name = make_temp_dir("/tmp/yosys-vhdl2verilog-XXXXXX");
+ log("Using temp directory %s.\n", tempdir_name.c_str());
if (!out_file.empty() && out_file[0] != '/') {
char pwd[PATH_MAX];
@@ -139,7 +132,7 @@ struct Vhdl2verilogPass : public Pass {
out_file = pwd + ("/" + out_file);
}
- FILE *f = fopen(stringf("%s/files.list", tempdir_name).c_str(), "wt");
+ FILE *f = fopen(stringf("%s/files.list", tempdir_name.c_str()).c_str(), "wt");
while (argidx < args.size()) {
std::string file = args[argidx++];
if (file.empty())
@@ -160,7 +153,7 @@ struct Vhdl2verilogPass : public Pass {
std::string command = "exec 2>&1; ";
if (!vhdl2verilog_dir.empty())
command += stringf("cd '%s'; . ./setup_env.sh; ", vhdl2verilog_dir.c_str());
- command += stringf("cd '%s'; vhdl2verilog -out '%s' -filelist files.list -top '%s'%s", tempdir_name,
+ command += stringf("cd '%s'; vhdl2verilog -out '%s' -filelist files.list -top '%s'%s", tempdir_name.c_str(),
out_file.empty() ? "vhdl2verilog_output.v" : out_file.c_str(), top_entity.c_str(), extra_opts.c_str());
log("Running '%s'..\n", command.c_str());
@@ -171,18 +164,15 @@ struct Vhdl2verilogPass : public Pass {
if (out_file.empty()) {
std::ifstream ff;
- ff.open(stringf("%s/vhdl2verilog_output.v", tempdir_name).c_str());
+ ff.open(stringf("%s/vhdl2verilog_output.v", tempdir_name.c_str()).c_str());
if (ff.fail())
log_error("Can't open vhdl2verilog output file `vhdl2verilog_output.v'.\n");
- Frontend::frontend_call(design, &ff, stringf("%s/vhdl2verilog_output.v", tempdir_name), "verilog");
+ Frontend::frontend_call(design, &ff, stringf("%s/vhdl2verilog_output.v", tempdir_name.c_str()), "verilog");
}
- log_header("Removing temp directory `%s':\n", tempdir_name);
- if (run_command(stringf("rm -rf '%s'", tempdir_name).c_str()) != 0)
- log_error("Execution of \"rm -rf '%s'\" failed!\n", tempdir_name);
-
+ log_header("Removing temp directory `%s':\n", tempdir_name.c_str());
+ remove_directory(tempdir_name);
log_pop();
-#endif
}
} Vhdl2verilogPass;