Context caching
This commit is contained in:
parent
120f4ee152
commit
e620d8e1cf
|
@ -76,8 +76,8 @@ def gen(out: TextIO, context: Context):
|
|||
writer.newline()
|
||||
|
||||
|
||||
def build(componentSpec: str, targetSpec: str, props: Props = {}) -> str:
|
||||
context = contextFor(targetSpec, props)
|
||||
def build(componentSpec: str, targetSpec: str) -> str:
|
||||
context = contextFor(targetSpec)
|
||||
target = context.target
|
||||
|
||||
shell.mkdir(context.builddir())
|
||||
|
@ -107,8 +107,8 @@ class Paths:
|
|||
self.obj = obj
|
||||
|
||||
|
||||
def buildAll(targetSpec: str, props: Props = {}) -> Paths:
|
||||
context = contextFor(targetSpec, props)
|
||||
def buildAll(targetSpec: str) -> Paths:
|
||||
context = contextFor(targetSpec)
|
||||
target = context.target
|
||||
|
||||
shell.mkdir(context.builddir())
|
||||
|
|
|
@ -156,7 +156,7 @@ def graphCmd(args: Args):
|
|||
scope: str | None = cast(str | None, args.tryConsumeOpt("scope"))
|
||||
onlyLibs: bool = args.consumeOpt("only-libs", False) == True
|
||||
|
||||
context = contextFor(targetSpec, {})
|
||||
context = contextFor(targetSpec)
|
||||
|
||||
graph.view(context, scope=scope, showExe=not onlyLibs)
|
||||
|
||||
|
|
|
@ -183,7 +183,13 @@ def instanciate(componentSpec: str, components: list[ComponentManifest], target:
|
|||
return ComponentInstance(manifest, sources, resolved[1:])
|
||||
|
||||
|
||||
def contextFor(targetSpec: str, props: Props) -> Context:
|
||||
context: dict = {}
|
||||
|
||||
|
||||
def contextFor(targetSpec: str) -> Context:
|
||||
if targetSpec in context:
|
||||
return context[targetSpec]
|
||||
|
||||
logger.log(f"Loading context for {targetSpec}")
|
||||
|
||||
targetEls = targetSpec.split(":")
|
||||
|
@ -221,8 +227,10 @@ def contextFor(targetSpec: str, props: Props) -> Context:
|
|||
instances = cast(list[ComponentInstance], list(filter(lambda e: e != None, map(lambda c: instanciate(
|
||||
c.id, components, target), components))))
|
||||
|
||||
return Context(
|
||||
context[targetSpec] = Context(
|
||||
target,
|
||||
instances,
|
||||
tools,
|
||||
)
|
||||
|
||||
return context[targetSpec]
|
||||
|
|
Loading…
Reference in a new issue