vivado just needs to be in the path for the programmer as well
authorVamsi K Vytla <vkvytla@lbl.gov>
Fri, 20 Sep 2019 03:35:55 +0000 (20:35 -0700)
committerVamsi K Vytla <vkvytla@lbl.gov>
Fri, 20 Sep 2019 03:35:55 +0000 (20:35 -0700)
litex/build/xilinx/programmer.py

index 4582bc82291b1e0d405f3e6ad75fbf5b93af776d..c4784f0bdf8fb376e44416867c78e51eeaee7eb1 100644 (file)
@@ -7,6 +7,7 @@
 import os
 import sys
 import subprocess
+from distutils.spawn import find_executable
 
 from litex.build.generic_programmer import GenericProgrammer
 from litex.build.xilinx import common
@@ -116,22 +117,25 @@ quit
 
 
 def _run_vivado(path, ver, cmds):
+    vivado_cmd = "echo 0"
     if sys.platform == "win32" or sys.platform == "cygwin":
         vivado_cmd = "vivado -mode tcl"
     else:
-        # For backwards compatibility with ISE paths, also
-        # look for a version in a subdirectory named "Vivado"
-        # under the current directory.
-        paths_to_try = [path, os.path.join(path, "Vivado")]
-        for p in paths_to_try:
-            try:
-                settings = common.settings(p, ver)
-            except OSError:
-                continue
-            break
-        else:
-            raise OSError("Unable to locate Vivado directory or settings.")
-        vivado_cmd = "bash -c \"source " + settings + "&& vivado -mode tcl\""
+        if not find_executable("vivado"):
+            # For backwards compatibility with ISE paths, also
+            # look for a version in a subdirectory named "Vivado"
+            # under the current directory.
+            paths_to_try = [path, os.path.join(path, "Vivado")]
+            for p in paths_to_try:
+                try:
+                    settings = common.settings(p, ver)
+                except OSError:
+                    continue
+                break
+            else:
+                raise OSError("Unable to locate Vivado directory or settings.")
+            vivado_cmd += "source " + settings
+        vivado_cmd += " && vivado -mode tcl"
     with subprocess.Popen(vivado_cmd, stdin=subprocess.PIPE, shell=True) as process:
         process.stdin.write(cmds.encode("ASCII"))
         process.communicate()