From: Larry Doolittle Date: Mon, 22 Apr 2019 22:42:31 +0000 (-0700) Subject: build/xilinx/vivado: only try Xilinx setup if vivado is not already in the path X-Git-Tag: 24jan2021_ls180~1306^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fda18fd6ef20459eacd61365fe7840c599ccc77b;p=litex.git build/xilinx/vivado: only try Xilinx setup if vivado is not already in the path Only affects the non-Windows code path. Uses python distutils, already used elsewhere. --- diff --git a/litex/build/xilinx/vivado.py b/litex/build/xilinx/vivado.py index 09a19411..eac6c6b7 100644 --- a/litex/build/xilinx/vivado.py +++ b/litex/build/xilinx/vivado.py @@ -5,6 +5,7 @@ import os import subprocess import sys import math +from distutils import spawn from migen.fhdl.structure import _Fragment @@ -65,20 +66,23 @@ def _run_vivado(build_name, vivado_path, source, ver=None): else: build_script_contents = "# Autogenerated by Migen\nset -e\n" - # 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.") + # No reason to search for vivado if it's already in our $PATH + # https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python + if not spawn.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 = [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 += "source " + settings + "\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".sh" tools.write_to_file(build_script_file, build_script_contents)