From 2e4b50cce19f2063b80de29d0da38550e2a9db9b Mon Sep 17 00:00:00 2001 From: Asherah Connor Date: Sat, 24 Aug 2024 17:13:34 +0300 Subject: [PATCH] build: add externals to build plan. --- niar/__init__.py | 2 +- niar/build.py | 3 +++ niar/project.py | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/niar/__init__.py b/niar/__init__.py index f1888ec..aa239e1 100644 --- a/niar/__init__.py +++ b/niar/__init__.py @@ -17,7 +17,7 @@ def cli(np: Project): "build", help="build the design, and optionally program it" ), ) - if hasattr(np, "cxxrtl_targets"): + if np.cxxrtl_targets: cxxrtl.add_arguments( np, subparsers.add_parser("cxxrtl", help="run the C++ simulator tests") ) diff --git a/niar/build.py b/niar/build.py index 3cdfb06..1918459 100644 --- a/niar/build.py +++ b/niar/build.py @@ -62,6 +62,9 @@ def main(np: Project, args): "yosys_opts": "-g", } prepare_kwargs.update(getattr(platform, "prepare_kwargs", {})) + for p in np.externals: + with open(np.path(p), 'rb') as f: + platform.add_file(p, f) plan = platform.prepare(design, np.name, **prepare_kwargs) il_fn = f"{np.name}.il" diff --git a/niar/project.py b/niar/project.py index 50920f0..ff84eea 100644 --- a/niar/project.py +++ b/niar/project.py @@ -82,7 +82,8 @@ class Project: name: str top: type[Elaboratable] targets: list[type[Platform]] - cxxrtl_targets: Optional[list[type[CxxrtlPlatform]]] + cxxrtl_targets: list[type[CxxrtlPlatform]] = [] + externals: list[str] = [] origin: Path @@ -149,7 +150,7 @@ class Project: raise KeyError(f"unknown target {name!r}") def cxxrtl_target_by_name(self, name: str) -> CxxrtlPlatform: - for t in self.cxxrtl_targets or []: + for t in self.cxxrtl_targets: if t.__name__ == name: return t() raise KeyError(f"unknown CXXRTL target {name!r}")