Improved build api.
This commit is contained in:
parent
9c9db6c36b
commit
f134c5752b
2 changed files with 5 additions and 5 deletions
|
@ -3,7 +3,7 @@ import logging
|
||||||
import dataclasses as dt
|
import dataclasses as dt
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, TextIO, Union
|
from typing import Callable, Literal, TextIO, Union
|
||||||
|
|
||||||
from . import shell, rules, model, ninja, const, cli
|
from . import shell, rules, model, ninja, const, cli
|
||||||
|
|
||||||
|
@ -300,17 +300,16 @@ def gen(out: TextIO, scope: TargetScope):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
scope: TargetScope,
|
scope: TargetScope,
|
||||||
components: Union[list[model.Component], model.Component, None] = None,
|
components: Union[list[model.Component], model.Component, Literal["all"]] = "all",
|
||||||
) -> list[ProductScope]:
|
) -> list[ProductScope]:
|
||||||
all = False
|
all = False
|
||||||
shell.mkdir(scope.target.builddir)
|
shell.mkdir(scope.target.builddir)
|
||||||
ninjaPath = os.path.join(scope.target.builddir, "build.ninja")
|
ninjaPath = os.path.join(scope.target.builddir, "build.ninja")
|
||||||
|
|
||||||
# if not os.path.exists(ninjaPath):
|
|
||||||
with open(ninjaPath, "w") as f:
|
with open(ninjaPath, "w") as f:
|
||||||
gen(f, scope)
|
gen(f, scope)
|
||||||
|
|
||||||
if components is None:
|
if components == "all":
|
||||||
all = True
|
all = True
|
||||||
components = list(scope.registry.iterEnabled(scope.target))
|
components = list(scope.registry.iterEnabled(scope.target))
|
||||||
|
|
||||||
|
@ -348,7 +347,7 @@ def _(args: cli.Args):
|
||||||
component = None
|
component = None
|
||||||
if componentSpec is not None:
|
if componentSpec is not None:
|
||||||
component = scope.registry.lookup(componentSpec, model.Component)
|
component = scope.registry.lookup(componentSpec, model.Component)
|
||||||
build(scope, component)[0]
|
build(scope, component if component is not None else "all")[0]
|
||||||
|
|
||||||
|
|
||||||
@cli.command("r", "builder/run", "Run a component")
|
@cli.command("r", "builder/run", "Run a component")
|
||||||
|
|
|
@ -15,6 +15,7 @@ def load(path: str):
|
||||||
|
|
||||||
if not spec or not spec.loader:
|
if not spec or not spec.loader:
|
||||||
_logger.error(f"Failed to load plugin {path}")
|
_logger.error(f"Failed to load plugin {path}")
|
||||||
|
return
|
||||||
|
|
||||||
module = importlib.module_from_spec(spec)
|
module = importlib.module_from_spec(spec)
|
||||||
sys.modules["plugin"] = module
|
sys.modules["plugin"] = module
|
||||||
|
|
Loading…
Add table
Reference in a new issue