runCmd will start __main__ by default.
This commit is contained in:
parent
16e321d82f
commit
bbe2d1d387
|
@ -170,7 +170,6 @@ def gen(out: TextIO, target: model.Target, registry: model.Registry):
|
|||
w.variable("cdefs", " ".join(aggregateCdefs(target)))
|
||||
w.newline()
|
||||
|
||||
w.rule("cp", "cp $in $out")
|
||||
for i in target.tools:
|
||||
tool = target.tools[i]
|
||||
rule = rules.rules[i]
|
||||
|
@ -251,11 +250,8 @@ def runCmd(args: cli.Args):
|
|||
target = model.Target.use(args)
|
||||
debug = args.consumeOpt("debug", False) is True
|
||||
|
||||
componentSpec = args.consumeArg()
|
||||
if componentSpec is None:
|
||||
raise RuntimeError("No component specified")
|
||||
|
||||
component = registry.lookup(componentSpec, model.Component)
|
||||
componentSpec = args.consumeArg() or "__main__"
|
||||
component = registry.lookup(componentSpec, model.Component, includeProvides=True)
|
||||
if component is None:
|
||||
raise RuntimeError(f"Component {componentSpec} not found")
|
||||
|
||||
|
|
|
@ -123,7 +123,10 @@ def helpCmd(args: Args):
|
|||
|
||||
print()
|
||||
vt100.title("Commands")
|
||||
for cmd in sorted(commands, key=lambda c: c.shortName or c.longName):
|
||||
for cmd in sorted(commands, key=lambda c: c.longName):
|
||||
if cmd.longName.startswith("_"):
|
||||
continue
|
||||
|
||||
pluginText = ""
|
||||
if cmd.isPlugin:
|
||||
pluginText = f"{vt100.CYAN}(plugin){vt100.RESET}"
|
||||
|
|
|
@ -6,6 +6,7 @@ from enum import Enum
|
|||
from typing import Any, Generator, Optional, Type, cast
|
||||
from pathlib import Path
|
||||
from dataclasses_json import DataClassJsonMixin
|
||||
import dataclasses
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from cutekit import const, shell
|
||||
|
@ -243,6 +244,10 @@ class Tool(DataClassJsonMixin):
|
|||
|
||||
Tools = dict[str, Tool]
|
||||
|
||||
DEFAULT_TOOLS: Tools = {
|
||||
"cp": Tool("cp"),
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class Target(Manifest):
|
||||
|
@ -472,7 +477,9 @@ class Registry(DataClassJsonMixin):
|
|||
if resolve.enabled:
|
||||
yield c
|
||||
|
||||
def lookup(self, name: str, type: Type[utils.T]) -> Optional[utils.T]:
|
||||
def lookup(
|
||||
self, name: str, type: Type[utils.T], includeProvides: bool = False
|
||||
) -> Optional[utils.T]:
|
||||
"""
|
||||
Lookup a manifest of a given type by name
|
||||
"""
|
||||
|
@ -482,6 +489,11 @@ class Registry(DataClassJsonMixin):
|
|||
if isinstance(m, type):
|
||||
return m
|
||||
|
||||
if includeProvides and type is Component:
|
||||
for m in self.iter(Component):
|
||||
if name in m.provides:
|
||||
return m
|
||||
|
||||
return None
|
||||
|
||||
def ensure(self, name: str, type: Type[utils.T]) -> utils.T:
|
||||
|
@ -576,6 +588,12 @@ class Registry(DataClassJsonMixin):
|
|||
|
||||
# Resolve tooling
|
||||
tools: Tools = target.tools
|
||||
|
||||
# Merge in default tools
|
||||
for k, v in DEFAULT_TOOLS.items():
|
||||
if k not in tools:
|
||||
tools[k] = dataclasses.replace(v)
|
||||
|
||||
from . import mixins as mxs
|
||||
|
||||
for mix in mixins:
|
||||
|
|
|
@ -27,6 +27,7 @@ class Rule:
|
|||
|
||||
|
||||
rules: dict[str, Rule] = {
|
||||
"cp": Rule("cp", ["*"], ["*"], "$in $out"),
|
||||
"cc": Rule(
|
||||
"cc",
|
||||
["*.c"],
|
||||
|
|
Loading…
Reference in a new issue