build/xilinx: Fixing settings finding.

* Better error messages.
 * Search correct directories;
   - XXX/Vivado/<version>
   - XXX/<version>/ISE_DS/
This commit is contained in:
Tim 'mithro' Ansell 2017-10-16 02:24:29 +11:00
parent db6c88bbef
commit e07bd71b16
3 changed files with 33 additions and 17 deletions

View File

@ -31,33 +31,49 @@ if _have_colorama:
] ]
def settings(path, ver=None, sub=None): def settings(path, name=None, ver=None, first=None):
if ver is None: if first == "version":
vers = list(tools.versions(path)) if not ver:
if not vers: vers = tools.versions(path)
raise OSError("no version directory for Xilinx tools found in " ver = max(vers)
+ path)
ver = max(vers)
full = os.path.join(path, str(ver)) full = os.path.join(path, str(ver), name)
if sub:
full = os.path.join(full, sub) 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] search = [64, 32]
if tools.arch_bits() == 32: if tools.arch_bits() == 32:
search.reverse() search = [32]
if sys.platform == "win32" or sys.platform == "cygwin": if sys.platform == "win32" or sys.platform == "cygwin":
script_ext = "bat" script_ext = "bat"
else: else:
script_ext = "sh" script_ext = "sh"
searched_in = []
for b in search: for b in search:
settings = os.path.join(full, "settings{0}.{1}".format(b, script_ext)) settings = os.path.join(full, "settings{0}.{1}".format(b, script_ext))
if os.path.exists(settings): if os.path.exists(settings):
return 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): class XilinxMultiRegImpl(MultiRegImpl):

View File

@ -96,7 +96,7 @@ def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
build_script_contents = "# Autogenerated by LiteX\nset -e\n" build_script_contents = "# Autogenerated by LiteX\nset -e\n"
fail_stmt = "" fail_stmt = ""
if source: 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" build_script_contents += source_cmd + settings + "\n"
ext = "ngc" ext = "ngc"

View File

@ -59,7 +59,7 @@ def _run_vivado(build_name, vivado_path, source, ver=None):
command = build_script_file command = build_script_file
else: else:
build_script_contents = "# Autogenerated by LiteX\nset -e\n" 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 += "source " + settings + "\n"
build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
build_script_file = "build_" + build_name + ".sh" build_script_file = "build_" + build_name + ".sh"
@ -172,11 +172,11 @@ class XilinxVivadoToolchain:
toolchain_path=None, source=True, run=True, **kwargs): toolchain_path=None, source=True, run=True, **kwargs):
if toolchain_path is None: if toolchain_path is None:
if sys.platform == "win32": if sys.platform == "win32":
toolchain_path = "C:\\Xilinx\\Vivado" toolchain_path = "C:\\Xilinx"
elif sys.platform == "cygwin": elif sys.platform == "cygwin":
toolchain_path = "/cygdrive/c/Xilinx/Vivado" toolchain_path = "/cygdrive/c/Xilinx"
else: else:
toolchain_path = "/opt/Xilinx/Vivado" toolchain_path = "/opt/Xilinx"
os.makedirs(build_dir, exist_ok=True) os.makedirs(build_dir, exist_ok=True)
cwd = os.getcwd() cwd = os.getcwd()
os.chdir(build_dir) os.chdir(build_dir)