Merge pull request #170 from ldoolitt/master

build/xilinx/vivado: only try Xilinx setup if vivado is not already i…
This commit is contained in:
enjoy-digital 2019-04-23 05:26:54 +02:00 committed by GitHub
commit 3b24b8d5b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 13 deletions

View File

@ -5,6 +5,7 @@ import os
import subprocess import subprocess
import sys import sys
import math import math
from distutils import spawn
from migen.fhdl.structure import _Fragment from migen.fhdl.structure import _Fragment
@ -65,20 +66,23 @@ def _run_vivado(build_name, vivado_path, source, ver=None):
else: else:
build_script_contents = "# Autogenerated by Migen\nset -e\n" build_script_contents = "# Autogenerated by Migen\nset -e\n"
# For backwards compatibility with ISE paths, also # No reason to search for vivado if it's already in our $PATH
# look for a version in a subdirectory named "Vivado" # https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
# under the current directory. if not spawn.find_executable("vivado"):
paths_to_try = [vivado_path, os.path.join(vivado_path, "Vivado")] # For backwards compatibility with ISE paths, also
for p in paths_to_try: # look for a version in a subdirectory named "Vivado"
try: # under the current directory.
settings = common.settings(p, ver) paths_to_try = [vivado_path, os.path.join(vivado_path, "Vivado")]
except OSError: for p in paths_to_try:
continue try:
break settings = common.settings(p, ver)
else: except OSError:
raise OSError("Unable to locate Vivado directory or settings.") 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_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
build_script_file = "build_" + build_name + ".sh" build_script_file = "build_" + build_name + ".sh"
tools.write_to_file(build_script_file, build_script_contents) tools.write_to_file(build_script_file, build_script_contents)