build/xilinx: Fixing settings finding.
* Better error messages. * Search correct directories; - XXX/Vivado/<version> - XXX/<version>/ISE_DS/
This commit is contained in:
parent
db6c88bbef
commit
e07bd71b16
|
@ -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)
|
||||
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))
|
||||
if sub:
|
||||
full = os.path.join(full, sub)
|
||||
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):
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue