build: add toolchain check before running build script and improve error reporting.
This commit is contained in:
parent
f8cadc7b04
commit
db836e8e5d
|
@ -10,6 +10,7 @@ import os
|
|||
import subprocess
|
||||
import sys
|
||||
import math
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -156,8 +157,13 @@ def _run_script(script):
|
|||
else:
|
||||
shell = ["bash"]
|
||||
|
||||
if which("quartus_map") is None:
|
||||
msg = "Unable to find Quartus toolchain, please:\n"
|
||||
msg += "- Add Quartus toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if subprocess.call(shell + [script]) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
raise OSError("Error occured during Quartus's script execution.")
|
||||
|
||||
# AlteraQuartusToolchain ---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import os
|
||||
import subprocess
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -115,7 +116,13 @@ class GowinToolchain():
|
|||
|
||||
# Run
|
||||
if run:
|
||||
subprocess.run(["gw_sh", "run.tcl"])
|
||||
if which("gw_sh") is None:
|
||||
msg = "Unable to find Gowin toolchain, please:\n"
|
||||
msg += "- Add Gowin toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if subprocess.call(["gw_sh", "run.tcl"]) != 0:
|
||||
raise OSError("Error occured during Gowin's script execution.")
|
||||
|
||||
os.chdir(cwd)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import sys
|
|||
import math
|
||||
import subprocess
|
||||
import shutil
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -147,8 +148,13 @@ def _run_script(script):
|
|||
else:
|
||||
shell = ["bash"]
|
||||
|
||||
if which("diamondc") is None:
|
||||
msg = "Unable to find Diamond toolchain, please:\n"
|
||||
msg += "- Add Diamond toolchain to your $PATH.\n"
|
||||
raise OSError(msg)
|
||||
|
||||
if subprocess.call(shell + [script]) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
raise OSError("Error occured during Diamond's script execution.")
|
||||
|
||||
def _check_timing(build_name):
|
||||
lines = open("impl/{}_impl.par".format(build_name), "r").readlines()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -132,8 +133,13 @@ def _run_script(script):
|
|||
else:
|
||||
shell = ["bash"]
|
||||
|
||||
if which("yosys") is None or which("nextpnr-ice40") is None:
|
||||
msg = "Unable to find Yosys/Nextpnr toolchain, please:\n"
|
||||
msg += "- Add Yosys/Nextpnr toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if subprocess.call(shell + [script]) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
raise OSError("Error occured during Yosys/Nextpnr's script execution.")
|
||||
|
||||
# LatticeIceStormToolchain -------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import sys
|
|||
import math
|
||||
import subprocess
|
||||
import shutil
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -63,8 +64,13 @@ synth_nexus -top {build_name} -vm {build_name}_yosys.vm
|
|||
|
||||
ys_name = build_name + ".ys"
|
||||
tools.write_to_file(ys_name, ys_contents)
|
||||
r = subprocess.call(["yosys", ys_name])
|
||||
if r != 0:
|
||||
|
||||
if which("yosys") is None:
|
||||
msg = "Unable to find Yosys toolchain, please:\n"
|
||||
msg += "- Add Yosys toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if subprocess.call(["yosys", ys_name]) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
|
||||
# Constraints (.ldc) -------------------------------------------------------------------------------
|
||||
|
@ -195,11 +201,18 @@ def _build_script(build_name, device):
|
|||
def _run_script(script):
|
||||
if sys.platform in ("win32", "cygwin"):
|
||||
shell = ["cmd", "/c"]
|
||||
tool = "pnmainc"
|
||||
else:
|
||||
shell = ["bash"]
|
||||
tool = "radiantc"
|
||||
|
||||
if which(tool) is None:
|
||||
msg = "Unable to find Radiant toolchain, please:\n"
|
||||
msg += "- Add Radiant toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if subprocess.call(shell + [script]) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
raise OSError("Error occured during Radiant's script execution.")
|
||||
|
||||
def _check_timing(build_name):
|
||||
lines = open("impl/{}_impl.par".format(build_name), "r").readlines()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -160,8 +161,13 @@ def _run_script(script):
|
|||
else:
|
||||
shell = ["bash"]
|
||||
|
||||
if which("yosys") is None or which("nextpnr-ecp5") is None:
|
||||
msg = "Unable to find Yosys/Nextpnr toolchain, please:\n"
|
||||
msg += "- Add Yosys/Nextpnr toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if subprocess.call(shell + [script]) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
raise OSError("Error occured during Yosys/Nextpnr's script execution.")
|
||||
|
||||
# LatticeTrellisToolchain --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
from litex import get_data_mod
|
||||
|
@ -226,6 +227,11 @@ class SimVerilatorToolchain:
|
|||
|
||||
# Run
|
||||
if run:
|
||||
if which("verilator") is None:
|
||||
msg = "Unable to find Verilator toolchain, please either:\n"
|
||||
msg += "- Install Verilator.\n"
|
||||
msg += "- Add Verilator toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
_compile_sim(build_name, verbose)
|
||||
run_as_root = False
|
||||
if sim_config.has_module("ethernet"):
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -159,9 +160,16 @@ bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt}
|
|||
build_script_file = "build_" + build_name + script_ext
|
||||
tools.write_to_file(build_script_file, build_script_contents, force_unix=False)
|
||||
command = shell + [build_script_file]
|
||||
r = tools.subprocess_call_filtered(command, common.colors)
|
||||
if r != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
|
||||
if which("ise") is None:
|
||||
msg = "Unable to find or source ISE toolchain, please either:\n"
|
||||
msg += "- Source ISE's settings manually."
|
||||
msg += "- Or set LITEX_ISE_VIVADO environment variant to ISE's settings path.\n"
|
||||
msg += "- Or add ISE toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if tools.subprocess_call_filtered(command, common.colors) != 0:
|
||||
raise OSError("Error occured during ISE's script execution.")
|
||||
|
||||
# XilinxISEToolchain --------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import sys
|
|||
import math
|
||||
from typing import NamedTuple, Union, List
|
||||
import re
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment, wrap, Constant
|
||||
from migen.fhdl.specials import Instance
|
||||
|
@ -94,8 +95,13 @@ class _MakefileGenerator:
|
|||
|
||||
|
||||
def _run_make():
|
||||
if tools.subprocess_call_filtered("make", []) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
if which("symbiflow_synth") is None:
|
||||
msg = "Unable to find Symbiflow toolchain, please:\n"
|
||||
msg += "- Add Symbiflow toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if tools.subprocess_call_filtered(shell + [script], common.colors) != 0:
|
||||
raise OSError("Error occured during Symbiflow's script execution.")
|
||||
|
||||
# SymbiflowToolchain -------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import os
|
|||
import subprocess
|
||||
import sys
|
||||
import math
|
||||
from shutil import which
|
||||
|
||||
from migen.fhdl.structure import _Fragment
|
||||
|
||||
|
@ -89,8 +90,15 @@ def _run_script(script):
|
|||
else:
|
||||
shell = ["bash"]
|
||||
|
||||
if which("vivado") is None:
|
||||
msg = "Unable to find or source Vivado toolchain, please either:\n"
|
||||
msg += "- Source Vivado's settings manually."
|
||||
msg += "- Or set LITEX_ENV_VIVADO environment variant to Vivado's settings path.\n"
|
||||
msg += "- Or add Vivado toolchain to your $PATH."
|
||||
raise OSError(msg)
|
||||
|
||||
if tools.subprocess_call_filtered(shell + [script], common.colors) != 0:
|
||||
raise OSError("Subprocess failed")
|
||||
raise OSError("Error occured during Vivado's script execution.")
|
||||
|
||||
# XilinxVivadoToolchain ----------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue