Skip to content

Commit

Permalink
build: add externals to build plan.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Aug 24, 2024
1 parent 99273cb commit 2e4b50c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion niar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
Expand Down
3 changes: 3 additions & 0 deletions niar/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions niar/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -149,7 +150,7 @@ def target_by_name(self, name: str) -> Platform:
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}")
Expand Down

0 comments on commit 2e4b50c

Please sign in to comment.