xilinx/vivado: Provide a fallback mechanism for using the same root for Vivado and...
authorWilliam D. Jones <thor0505@comcast.net>
Sat, 3 Mar 2018 02:48:49 +0000 (21:48 -0500)
committerWilliam D. Jones <thor0505@comcast.net>
Sat, 3 Mar 2018 02:48:49 +0000 (21:48 -0500)
litex/build/xilinx/vivado.py

index 034dcc70142887cd2b1aaad3c17414ad2994f4b2..ad3be9ff3b8abe6b20cf35a9b79c68c3217cc4cd 100644 (file)
@@ -63,7 +63,20 @@ def _run_vivado(build_name, vivado_path, source, ver=None):
         command = build_script_file
     else:
         build_script_contents = "# Autogenerated by LiteX\nset -e\n"
-        settings = common.settings(vivado_path, ver)
+
+        # For backwards compatibility with ISE paths, also
+        # look for a version in a subdirectory named "Vivado"
+        # under the current directory.
+        paths_to_try = [vivado_path, os.path.join(vivado_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.")
+
         build_script_contents += "source " + settings + "\n"
         build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
         build_script_file = "build_" + build_name + ".sh"
@@ -182,9 +195,9 @@ class XilinxVivadoToolchain:
             toolchain_path=None, source=True, run=True, **kwargs):
         if toolchain_path is None:
             if sys.platform == "win32":
-                toolchain_path = "C:\\Xilinx"
+                toolchain_path = "C:\\Xilinx\\Vivado"
             elif sys.platform == "cygwin":
-                toolchain_path = "/cygdrive/c/Xilinx"
+                toolchain_path = "/cygdrive/c/Xilinx/Vivado"
             else:
                 toolchain_path = "/opt/Xilinx/Vivado"
         os.makedirs(build_dir, exist_ok=True)