From 6370acd9685184eff8698320c35278afe33c8f7b Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Fri, 19 Jun 2015 00:30:22 +0200 Subject: [PATCH] Xilinx Platforms now use cmd.exe on Windows instead of bash to run scripts (remove MSYS dependency) --- mibuild/xilinx/common.py | 8 +++++++- mibuild/xilinx/ise.py | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/mibuild/xilinx/common.py b/mibuild/xilinx/common.py index 8182ab23..207711ef 100644 --- a/mibuild/xilinx/common.py +++ b/mibuild/xilinx/common.py @@ -1,4 +1,5 @@ import os +import sys from distutils.version import StrictVersion from migen.fhdl.std import * @@ -25,8 +26,13 @@ def settings(path, ver=None, sub=None): if tools.arch_bits() == 32: search.reverse() + if sys.platform == "win32" or sys.platform == "cygwin": + script_ext = "bat" + else: + script_ext = "sh" + for b in search: - settings = os.path.join(full, "settings{0}.sh".format(b)) + settings = os.path.join(full, "settings{0}.{1}".format(b, script_ext)) if os.path.exists(settings): return settings diff --git a/mibuild/xilinx/ise.py b/mibuild/xilinx/ise.py index 7f46abcb..08b4f3eb 100644 --- a/mibuild/xilinx/ise.py +++ b/mibuild/xilinx/ise.py @@ -98,11 +98,18 @@ synth_xilinx -arch {arch} -top top -edif {build_name}.edif""".format(arch=arch, def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt, bitgen_opt, ise_commands, map_opt, par_opt, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": - source = False - build_script_contents = "# Autogenerated by mibuild\nset -e\n" - if source: - settings = common.settings(ise_path, ver, "ISE_DS") - build_script_contents += "source " + settings + "\n" + source_cmd = "call " + script_ext = ".bat" + shell = ["cmd", "/c"] + build_script_contents = "@echo off\nrem Autogenerated by mibuild\n" + else: + source_cmd = "source " + script_ext = ".sh" + shell = ["bash"] + build_script_contents = "# Autogenerated by mibuild\nset -e\n" + + settings = common.settings(ise_path, ver, "ISE_DS") + build_script_contents += source_cmd + settings + "\n" if mode == "edif": ext = "edif" else: @@ -121,10 +128,10 @@ bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit ngdbuild_opt=ngdbuild_opt, bitgen_opt=bitgen_opt, ext=ext, 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, force_unix=True) - - r = subprocess.call(["bash", build_script_file]) + build_script_file = "build_" + build_name + script_ext + tools.write_to_file(build_script_file, build_script_contents, force_unix=False) + command = shell + [build_script_file] + r = subprocess.call(command) if r != 0: raise OSError("Subprocess failed") @@ -140,9 +147,21 @@ class XilinxISEToolchain: self.ngdbuild_opt = "" self.bitgen_opt = "-g LCK_cycle:6 -g Binary:Yes -w" self.ise_commands = "" + if sys.platform == "win32": + self.default_ise_path = "C:\\Xilinx" + elif sys.platform == "cygwin": + self.default_ise_path = "/cygdrive/c/Xilinx" + else: + self.default_ise_path = "/opt/Xilinx" + def build(self, platform, fragment, build_dir="build", build_name="top", - ise_path="/opt/Xilinx", source=True, run=True, mode="xst"): + ise_path=None, source=True, run=True, mode="xst"): + # Default path differs depending on the platform Python is run. + # Use None as default input argument to figure out the default path. + if ise_path is None: + ise_path = self.default_ise_path + tools.mkdir_noerror(build_dir) os.chdir(build_dir) -- 2.30.2