mirror of
https://git.sr.ht/~kivikakk/niar
synced 2024-12-22 22:42:25 +00:00
Compare commits
No commits in common. "944321f5d9c924aa64936b99b134591bdc760e79" and "56234604d0914245e7a7d4504a042820adae9b1b" have entirely different histories.
944321f5d9
...
56234604d0
|
@ -5,7 +5,7 @@ import subprocess
|
||||||
|
|
||||||
from .logging import logger
|
from .logging import logger
|
||||||
|
|
||||||
__all__ = ["CompilationUnit", "CommandRunner", "CommandFailedError"]
|
__all__ = ["CompilationUnit", "CommandRunner"]
|
||||||
|
|
||||||
|
|
||||||
class CompilationUnit:
|
class CompilationUnit:
|
||||||
|
@ -76,8 +76,6 @@ class CompilationUnit:
|
||||||
with open(inf, "rb") as f:
|
with open(inf, "rb") as f:
|
||||||
r[str(inf)] = f.read()
|
r[str(inf)] = f.read()
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
class CommandRunner:
|
class CommandRunner:
|
||||||
cus: list[CompilationUnit]
|
cus: list[CompilationUnit]
|
||||||
|
|
||||||
|
@ -123,16 +121,14 @@ class CommandRunner:
|
||||||
|
|
||||||
failed = []
|
failed = []
|
||||||
for cu, proc in runnables:
|
for cu, proc in runnables:
|
||||||
if proc is not None:
|
if proc is not None and proc.wait() != 0:
|
||||||
status = proc.wait()
|
failed.append(cu)
|
||||||
if status != 0:
|
|
||||||
failed.append((cu, status))
|
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
logger.error("the following process(es) failed:")
|
logger.error("the following process(es) failed:")
|
||||||
for (cu, status) in failed:
|
for cu in failed:
|
||||||
logger.error(f" {formatted(cu)} (status={status})")
|
logger.error(f" {formatted(cu)}")
|
||||||
raise CommandFailedError(f"failed {step} step")
|
raise RuntimeError(f"failed {step} step")
|
||||||
|
|
||||||
for cu, _ in runnables:
|
for cu, _ in runnables:
|
||||||
cu.mark_up_to_date()
|
cu.mark_up_to_date()
|
||||||
|
@ -148,10 +144,6 @@ class CommandRunner:
|
||||||
logger.info(f"{action} {formatted(cu)}")
|
logger.info(f"{action} {formatted(cu)}")
|
||||||
|
|
||||||
|
|
||||||
class CommandFailedError(RuntimeError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def formatted(cu):
|
def formatted(cu):
|
||||||
if inspect.isfunction(cu.cmd):
|
if inspect.isfunction(cu.cmd):
|
||||||
return cu.cmd.__name__
|
return cu.cmd.__name__
|
||||||
|
|
|
@ -12,7 +12,7 @@ from amaranth._toolchain.yosys import find_yosys
|
||||||
from amaranth.back import rtlil
|
from amaranth.back import rtlil
|
||||||
|
|
||||||
from .build import construct_top
|
from .build import construct_top
|
||||||
from .cmdrunner import CommandRunner, CommandFailedError
|
from .cmdrunner import CommandRunner
|
||||||
from .logging import logtime, logger
|
from .logging import logtime, logger
|
||||||
from .project import Project
|
from .project import Project
|
||||||
|
|
||||||
|
@ -251,11 +251,7 @@ def main(np: Project, args):
|
||||||
infs=cc_o_paths + list(np.path("cxxrtl").glob("**/*.zig")),
|
infs=cc_o_paths + list(np.path("cxxrtl").glob("**/*.zig")),
|
||||||
outf=outf,
|
outf=outf,
|
||||||
chdir="cxxrtl")
|
chdir="cxxrtl")
|
||||||
try:
|
cr.run()
|
||||||
cr.run()
|
|
||||||
except CommandFailedError:
|
|
||||||
logger.log(logging.INFO, "aborting on CommandFailedError")
|
|
||||||
return
|
|
||||||
shutil.copy(outf, exe_o_path)
|
shutil.copy(outf, exe_o_path)
|
||||||
else:
|
else:
|
||||||
cmd = [
|
cmd = [
|
||||||
|
@ -270,11 +266,7 @@ def main(np: Project, args):
|
||||||
cr.add_process(cmd,
|
cr.add_process(cmd,
|
||||||
infs=cc_o_paths,
|
infs=cc_o_paths,
|
||||||
outf=exe_o_path)
|
outf=exe_o_path)
|
||||||
try:
|
cr.run()
|
||||||
cr.run()
|
|
||||||
except CommandFailedError:
|
|
||||||
logger.log(logging.INFO, "aborting on CommandFailedError")
|
|
||||||
return
|
|
||||||
|
|
||||||
if not args.compile:
|
if not args.compile:
|
||||||
cmd = [exe_o_path]
|
cmd = [exe_o_path]
|
||||||
|
@ -286,8 +278,6 @@ def main(np: Project, args):
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print(file=sys.stderr)
|
print(file=sys.stderr)
|
||||||
logger.log(logging.INFO, "aborting on KeyboardInterrupt")
|
logger.log(logging.INFO, "aborting on KeyboardInterrupt")
|
||||||
except CommandFailedError:
|
|
||||||
logger.log(logging.INFO, "aborting on CommandFailedError")
|
|
||||||
|
|
||||||
|
|
||||||
def _make_yosys_relative(path):
|
def _make_yosys_relative(path):
|
||||||
|
|
Loading…
Reference in a new issue