feat: allow plugins to inject custom props

This commit is contained in:
Jordan ⌨️ 2023-02-09 11:44:12 +01:00
parent e620d8e1cf
commit dcde816298
2 changed files with 5 additions and 4 deletions

View file

@ -76,8 +76,8 @@ def gen(out: TextIO, context: Context):
writer.newline()
def build(componentSpec: str, targetSpec: str) -> str:
context = contextFor(targetSpec)
def build(componentSpec: str, targetSpec: str, props: Props = {}) -> str:
context = contextFor(targetSpec, props)
target = context.target
shell.mkdir(context.builddir())

View file

@ -186,7 +186,7 @@ def instanciate(componentSpec: str, components: list[ComponentManifest], target:
context: dict = {}
def contextFor(targetSpec: str) -> Context:
def contextFor(targetSpec: str, props: Props = {}) -> Context:
if targetSpec in context:
return context[targetSpec]
@ -198,6 +198,8 @@ def contextFor(targetSpec: str) -> Context:
targetEls[0] = "host-" + shell.uname().machine
target = loadTarget(targetEls[0])
target.props |= props
components = loadAllComponents()
components = filterDisabled(components, target)
@ -221,7 +223,6 @@ def contextFor(targetSpec: str) -> Context:
for component in components:
for toolSpec in component.tools:
tool = component.tools[toolSpec]
tools[toolSpec].args += tool.args
instances = cast(list[ComponentInstance], list(filter(lambda e: e != None, map(lambda c: instanciate(