Commit caab4146 authored by Sebastien Bourdeauducq's avatar Sebastien Bourdeauducq
Browse files

build: remove tool version detection and sourcing of vendor script

* poor design that often gets in the way
* not consistently supported in MiSoC
* not consistently or completely implemented across platforms and tools

We now simply assume that all required vendor tools are in PATH.
parent 5c5486ba
......@@ -91,7 +91,7 @@ def _build_files(device, sources, vincpaths, named_sc, named_pc, build_name):
tools.write_to_file("{}.qsf".format(build_name), "\n".join(lines))
def _run_quartus(build_name, quartus_path, create_rbf):
def _run_quartus(build_name, create_rbf):
build_script_contents = """# Autogenerated by Migen
set -e
......@@ -121,9 +121,7 @@ fi
class AlteraQuartusToolchain:
def build(self, platform, fragment, build_dir="build", build_name="top",
toolchain_path=None, run=True, **kwargs):
if toolchain_path is None:
toolchain_path="/opt/Altera"
run=True, **kwargs):
cwd = os.getcwd()
os.makedirs(build_dir, exist_ok=True)
os.chdir(build_dir)
......@@ -144,7 +142,7 @@ class AlteraQuartusToolchain:
named_pc,
build_name)
if run:
_run_quartus(build_name, toolchain_path, platform.create_rbf)
_run_quartus(build_name, platform.create_rbf)
os.chdir(cwd)
......
......@@ -14,24 +14,6 @@ from migen.build import tools
from migen.build.lattice import common
def _get_bindir(path, ver=None):
if ver is None:
# _x64 suffix means StrictVersion will fail.
vers = list(tools.versions(path, strict=False))
if not vers:
raise OSError("no version directory for Diamond tools found in "
+ path)
ver = max(vers)
# Lattice does not provide 32-bit binaries anymore.
if sys.platform in ("win32", "cygwin"):
bin_suffix = "nt64"
else:
bin_suffix = "lin64"
return os.path.join(path, str(ver), "bin", bin_suffix)
def _produces_jedec(device):
return device.startswith("LCMX")
......@@ -86,7 +68,7 @@ def _build_files(device, sources, vincpaths, build_name):
tools.write_to_file(build_name + ".tcl", "\n".join(tcl))
def _build_script(build_name, device, toolchain_path, source, ver=None):
def _build_script(build_name, device, toolchain_path):
if sys.platform in ("win32", "cygwin"):
script_ext = ".bat"
build_script_contents = "@echo off\nrem Autogenerated by Migen\n\n"
......@@ -98,15 +80,6 @@ def _build_script(build_name, device, toolchain_path, source, ver=None):
copy_stmt = "cp"
fail_stmt = ""
if source:
bindir = _get_bindir(toolchain_path, ver)
if sys.platform in ("win32", "cygwin"):
build_script_contents += "set PATH={};%PATH%\n".format(bindir)
else:
build_script_contents += "bindir={}\n".format(bindir)
build_script_contents += ". ${{bindir}}/diamond_env{fail_stmt}\n".format(
fail_stmt=fail_stmt)
build_script_contents += "pnmainc {tcl_script}{fail_stmt}\n".format(
tcl_script=build_name + ".tcl",
fail_stmt=fail_stmt)
......
import os
import struct
from distutils.version import StrictVersion, LooseVersion
import re
import subprocess
import sys
......@@ -24,24 +23,6 @@ def write_to_file(filename, contents, force_unix=False):
f.write(contents)
def arch_bits():
return struct.calcsize("P")*8
def versions(path, strict=True):
for n in os.listdir(path):
full = os.path.join(path, n)
if not os.path.isdir(full):
continue
try:
if strict:
yield StrictVersion(n)
else:
yield LooseVersion(n)
except ValueError:
continue
def sub_rules(line, rules, max_matches=1):
for pattern, color in rules:
line, matches = re.subn(pattern, color, line, max_matches)
......
......@@ -31,35 +31,6 @@ 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)
search = [64, 32]
if tools.arch_bits() == 32:
search.reverse()
if sys.platform == "win32" or sys.platform == "cygwin":
script_ext = "bat"
else:
script_ext = "sh"
for b in search:
settings = os.path.join(full, "settings{0}.{1}".format(b, script_ext))
if os.path.exists(settings):
return settings
raise OSError("no Xilinx tools settings file found")
class XilinxMultiRegImpl(MultiRegImpl):
def __init__(self, *args, **kwargs):
MultiRegImpl.__init__(self, *args, **kwargs)
......
......@@ -50,7 +50,7 @@ def _build_xdc(named_sc, named_pc):
return r
def _run_vivado(build_name, vivado_path, source, ver=None):
def _run_vivado(build_name):
if sys.platform == "win32" or sys.platform == "cygwin":
build_script_contents = "REM Autogenerated by Migen\n"
build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
......@@ -59,8 +59,6 @@ def _run_vivado(build_name, vivado_path, source, ver=None):
command = build_script_file
else:
build_script_contents = "# Autogenerated by Migen\nset -e\n"
settings = common.settings(vivado_path, ver)
build_script_contents += "source " + settings + "\n"
build_script_contents += "export LC_ALL=C\n" # work around "locale::facet::_S_create_c_locale name not valid"
build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n"
build_script_file = "build_" + build_name + ".sh"
......@@ -190,9 +188,7 @@ class XilinxVivadoToolchain:
)
def build(self, platform, fragment, build_dir="build", build_name="top",
toolchain_path=None, source=True, run=True, **kwargs):
if toolchain_path is None:
toolchain_path = "/opt/Xilinx/Vivado"
run=True, **kwargs):
os.makedirs(build_dir, exist_ok=True)
cwd = os.getcwd()
os.chdir(build_dir)
......@@ -212,7 +208,7 @@ class XilinxVivadoToolchain:
self._build_batch(platform, sources, edifs, ips, build_name)
tools.write_to_file(build_name + ".xdc", _build_xdc(named_sc, named_pc))
if run:
_run_vivado(build_name, toolchain_path, source)
_run_vivado(build_name)
os.chdir(cwd)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment