Xilinx Platforms now use cmd.exe on Windows instead of bash to run scripts
authorWilliam D. Jones <thor0505@comcast.net>
Thu, 18 Jun 2015 22:30:22 +0000 (00:30 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 18 Jun 2015 22:30:22 +0000 (00:30 +0200)
(remove MSYS dependency)

mibuild/xilinx/common.py
mibuild/xilinx/ise.py

index 8182ab23f7bf851331ef5a74063bab153824c203..207711efa6064e9641cb975b682d4686b321c314 100644 (file)
@@ -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
 
index 7f46abcb5a51787544c8feb6d5d9467212925b1b..08b4f3ebef78399646b9aaf1bd296b96dc412626 100644 (file)
@@ -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)