1
0
Fork 0
mirror of https://git.sr.ht/~kivikakk/niar synced 2024-12-22 12:52:25 +00:00

build: add externals to build plan.

This commit is contained in:
Asherah Connor 2024-08-24 17:13:34 +03:00
parent 99273cb385
commit 2e4b50cce1
3 changed files with 7 additions and 3 deletions

View file

@ -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")
)

View file

@ -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"

View file

@ -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}")