Added build all command.

This commit is contained in:
Sleepy Monax 2023-02-10 21:40:57 +01:00
parent 250930c977
commit e12f82b6cc
3 changed files with 16 additions and 8 deletions

View file

@ -39,10 +39,9 @@ def gen(out: TextIO, context: Context):
writer.separator("Components")
for instance in context.instances:
if not instance.enabled:
continue
all: list[str] = []
for instance in context.enabledInstances():
objects = instance.objsfiles(context)
writer.comment(f"Component: {instance.manifest.id}")
writer.comment(f"Resolved: {', '.join(instance.resolved)}")
@ -76,8 +75,14 @@ def gen(out: TextIO, context: Context):
writer.build(instance.binfile(context), "ld",
list(map(lambda o: o[1], objects)) + libraries)
all.append(instance.binfile(context))
writer.newline()
writer.separator("Phony targets")
writer.build("all", "phony", all)
def build(componentSpec: str, targetSpec: str, props: Props = {}) -> str:
context = contextFor(targetSpec, props)

View file

@ -71,9 +71,9 @@ def buildCmd(args: Args):
componentSpec = args.consumeArg()
if componentSpec is None:
raise Exception("Component not specified")
builder.build(componentSpec, targetSpec)
builder.buildAll(targetSpec)
else:
builder.build(componentSpec, targetSpec)
cmds += [Cmd("b", "build", "Build the target", buildCmd)]

View file

@ -1,4 +1,4 @@
from typing import cast, Protocol
from typing import cast, Protocol, Iterable
from pathlib import Path
@ -71,6 +71,9 @@ class Context(IContext):
instances: list[ComponentInstance]
tools: Tools
def enabledInstances(self) -> Iterable[ComponentInstance]:
return filter(lambda x: x.enabled, self.instances)
def __init__(self, target: TargetManifest, instances: list[ComponentInstance], tools: Tools):
self.target = target
self.instances = instances
@ -84,7 +87,7 @@ class Context(IContext):
def cincls(self) -> list[str]:
includes = list(
map(lambda x: x.cinclude(), self.instances))
map(lambda x: x.cinclude(), self.enabledInstances()))
return utils.uniq(includes)
def cdefs(self) -> list[str]: