2023-12-10 18:24:05 +00:00
|
|
|
from cutekit import builder, cli, model
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
class Builder:
|
|
|
|
def __init__(self, args: cli.Args, arch: str = "x86_64"):
|
|
|
|
self.__registry = model.Registry.use(args)
|
|
|
|
self.__kernel_scope = builder.TargetScope(
|
2023-12-17 15:32:53 +00:00
|
|
|
self.__registry,
|
|
|
|
self.__registry.lookup(f"kernel-{arch}", model.Target),
|
|
|
|
)
|
|
|
|
|
|
|
|
self.__user_scope = builder.TargetScope(
|
2023-12-10 18:24:05 +00:00
|
|
|
self.__registry,
|
2023-12-15 21:31:52 +00:00
|
|
|
self.__registry.lookup(f"navy-{arch}", model.Target),
|
2023-12-10 18:24:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def build_core(self) -> Path:
|
|
|
|
core_component = self.__registry.lookup("core", model.Component)
|
|
|
|
product = builder.build(self.__kernel_scope, core_component)[0]
|
|
|
|
return Path(product.path).absolute()
|
|
|
|
|
2023-12-17 15:32:53 +00:00
|
|
|
def build_modules(self) -> list[Path]:
|
|
|
|
modules = dict(filter(lambda x: type(x[1]) is model.Component and \
|
|
|
|
x[1].type == model.Kind.EXE and x[0] != "core", self.__registry.manifests.items()))
|
|
|
|
|
|
|
|
products = []
|
|
|
|
for component in modules.values():
|
|
|
|
products.append(Path(builder.build(self.__user_scope, component)[0].path).absolute())
|
|
|
|
|
|
|
|
return products
|
|
|
|
|
2023-12-10 18:24:05 +00:00
|
|
|
@property
|
|
|
|
def arch(self) -> str:
|
|
|
|
return self.__kernel_scope.target.id.split("-")[1]
|