From 8c03cb049156a5f6b6519ca1d59b258141385fed Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 14 Apr 2014 17:19:53 +0200 Subject: [PATCH] mibuild: force shell script generation to unix format (will be executed with cygwin's bash on windows) --- mibuild/altera_quartus.py | 2 +- mibuild/tools.py | 7 +++++-- mibuild/xilinx_ise.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mibuild/altera_quartus.py b/mibuild/altera_quartus.py index d2265b08..36d76c37 100644 --- a/mibuild/altera_quartus.py +++ b/mibuild/altera_quartus.py @@ -73,7 +73,7 @@ quartus_sta {build_name}.qpf """.format(build_name=build_name) build_script_file = "build_" + build_name + ".sh" - tools.write_to_file(build_script_file, build_script_contents) + tools.write_to_file(build_script_file, build_script_contents, force_unix=True) r = subprocess.call(["bash", build_script_file]) if r != 0: diff --git a/mibuild/tools.py b/mibuild/tools.py index 1c2493e4..35efca74 100644 --- a/mibuild/tools.py +++ b/mibuild/tools.py @@ -14,7 +14,10 @@ def language_by_filename(name): return "vhdl" return None -def write_to_file(filename, contents): - f = open(filename, "w") +def write_to_file(filename, contents, force_unix=False): + newline = None + if force_unix: + newline = "\n" + f = open(filename, "w", newline=newline) f.write(contents) f.close() diff --git a/mibuild/xilinx_ise.py b/mibuild/xilinx_ise.py index 8bab531a..8018a1fe 100644 --- a/mibuild/xilinx_ise.py +++ b/mibuild/xilinx_ise.py @@ -157,7 +157,7 @@ bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit par_opt=par_opt, map_opt=map_opt) build_script_contents += ise_commands.format(build_name=build_name) build_script_file = "build_" + build_name + ".sh" - tools.write_to_file(build_script_file, build_script_contents) + tools.write_to_file(build_script_file, build_script_contents, force_unix=True) r = subprocess.call(["bash", build_script_file]) if r != 0: -- 2.30.2