From: Tim 'mithro' Ansell Date: Sun, 15 Oct 2017 15:24:29 +0000 (+1100) Subject: build/xilinx: Fixing settings finding. X-Git-Tag: 24jan2021_ls180~1799^2~4 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e07bd71b16932a504b7435a96901a3b0eb5a99cd;p=litex.git build/xilinx: Fixing settings finding. * Better error messages. * Search correct directories; - XXX/Vivado/ - XXX//ISE_DS/ --- diff --git a/litex/build/xilinx/common.py b/litex/build/xilinx/common.py index c747945b..170e67e2 100644 --- a/litex/build/xilinx/common.py +++ b/litex/build/xilinx/common.py @@ -31,33 +31,49 @@ if _have_colorama: ] -def settings(path, ver=None, sub=None): - if ver is None: - vers = list(tools.versions(path)) - if not vers: - raise OSError("no version directory for Xilinx tools found in " - + path) - ver = max(vers) - - full = os.path.join(path, str(ver)) - if sub: - full = os.path.join(full, sub) +def settings(path, name=None, ver=None, first=None): + if first == "version": + if not ver: + vers = tools.versions(path) + ver = max(vers) + + full = os.path.join(path, str(ver), name) + + elif first == "name": + path = os.path.join(path, name) + + if not ver: + vers = tools.versions(path) + ver = max(vers) + + full = os.path.join(path, str(ver)) + + if not vers: + raise OSError( + "no version directory for Xilinx tools found in {}".format( + path)) search = [64, 32] if tools.arch_bits() == 32: - search.reverse() + search = [32] if sys.platform == "win32" or sys.platform == "cygwin": script_ext = "bat" else: script_ext = "sh" + searched_in = [] for b in search: settings = os.path.join(full, "settings{0}.{1}".format(b, script_ext)) if os.path.exists(settings): return settings + searched_in.append(settings) - raise OSError("no Xilinx tools settings file found") + raise OSError( + "no Xilinx tools settings file found.\n" + "Looked in:\n" + " " + + "\n ".join(searched_in)) class XilinxMultiRegImpl(MultiRegImpl): diff --git a/litex/build/xilinx/ise.py b/litex/build/xilinx/ise.py index 0356f964..171fbef0 100644 --- a/litex/build/xilinx/ise.py +++ b/litex/build/xilinx/ise.py @@ -96,7 +96,7 @@ def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt, build_script_contents = "# Autogenerated by LiteX\nset -e\n" fail_stmt = "" if source: - settings = common.settings(ise_path, ver, "ISE_DS") + settings = common.settings(ise_path, "ISE_DS", ver, first="version") build_script_contents += source_cmd + settings + "\n" ext = "ngc" diff --git a/litex/build/xilinx/vivado.py b/litex/build/xilinx/vivado.py index 8051e167..8511a5c5 100644 --- a/litex/build/xilinx/vivado.py +++ b/litex/build/xilinx/vivado.py @@ -59,7 +59,7 @@ 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) + settings = common.settings(vivado_path, "Vivado", ver, first="name") build_script_contents += "source " + settings + "\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".sh" @@ -172,11 +172,11 @@ class XilinxVivadoToolchain: toolchain_path=None, source=True, run=True, **kwargs): if toolchain_path is None: if sys.platform == "win32": - toolchain_path = "C:\\Xilinx\\Vivado" + toolchain_path = "C:\\Xilinx" elif sys.platform == "cygwin": - toolchain_path = "/cygdrive/c/Xilinx/Vivado" + toolchain_path = "/cygdrive/c/Xilinx" else: - toolchain_path = "/opt/Xilinx/Vivado" + toolchain_path = "/opt/Xilinx" os.makedirs(build_dir, exist_ok=True) cwd = os.getcwd() os.chdir(build_dir)