Skip to content

Commit 2e4b50c

Browse files
committed
build: add externals to build plan.
1 parent 99273cb commit 2e4b50c

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

niar/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def cli(np: Project):
1717
"build", help="build the design, and optionally program it"
1818
),
1919
)
20-
if hasattr(np, "cxxrtl_targets"):
20+
if np.cxxrtl_targets:
2121
cxxrtl.add_arguments(
2222
np, subparsers.add_parser("cxxrtl", help="run the C++ simulator tests")
2323
)

niar/build.py

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def main(np: Project, args):
6262
"yosys_opts": "-g",
6363
}
6464
prepare_kwargs.update(getattr(platform, "prepare_kwargs", {}))
65+
for p in np.externals:
66+
with open(np.path(p), 'rb') as f:
67+
platform.add_file(p, f)
6568
plan = platform.prepare(design, np.name, **prepare_kwargs)
6669

6770
il_fn = f"{np.name}.il"

niar/project.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class Project:
8282
name: str
8383
top: type[Elaboratable]
8484
targets: list[type[Platform]]
85-
cxxrtl_targets: Optional[list[type[CxxrtlPlatform]]]
85+
cxxrtl_targets: list[type[CxxrtlPlatform]] = []
86+
externals: list[str] = []
8687

8788
origin: Path
8889

@@ -149,7 +150,7 @@ def target_by_name(self, name: str) -> Platform:
149150
raise KeyError(f"unknown target {name!r}")
150151

151152
def cxxrtl_target_by_name(self, name: str) -> CxxrtlPlatform:
152-
for t in self.cxxrtl_targets or []:
153+
for t in self.cxxrtl_targets:
153154
if t.__name__ == name:
154155
return t()
155156
raise KeyError(f"unknown CXXRTL target {name!r}")

0 commit comments

Comments
 (0)