Added wait option to debbuger
This commit is contained in:
parent
594953ea68
commit
1fd19e757a
|
@ -15,8 +15,8 @@ class Scope:
|
|||
registry: model.Registry
|
||||
|
||||
@staticmethod
|
||||
def use(args: cli.Args) -> "Scope":
|
||||
registry = model.Registry.use(args)
|
||||
def use(args: cli.Args, props: model.Props = {}) -> "Scope":
|
||||
registry = model.Registry.use(args, props)
|
||||
return Scope(registry)
|
||||
|
||||
def key(self) -> str:
|
||||
|
@ -32,9 +32,9 @@ class TargetScope(Scope):
|
|||
target: model.Target
|
||||
|
||||
@staticmethod
|
||||
def use(args: cli.Args) -> "TargetScope":
|
||||
registry = model.Registry.use(args)
|
||||
target = model.Target.use(args)
|
||||
def use(args: cli.Args, props: model.Props = {}) -> "TargetScope":
|
||||
registry = model.Registry.use(args, props)
|
||||
target = model.Target.use(args, props)
|
||||
return TargetScope(registry, target)
|
||||
|
||||
def key(self) -> str:
|
||||
|
@ -151,7 +151,7 @@ def compile(
|
|||
res: list[str] = []
|
||||
for src in srcs:
|
||||
rel = Path(src).relative_to(scope.component.dirname())
|
||||
dest = buildpath(scope, path="__obj__") / rel.with_suffix(".o")
|
||||
dest = buildpath(scope, path="__obj__") / rel.with_suffix(rel.suffix + ".o")
|
||||
t = scope.target.tools[rule]
|
||||
w.build(str(dest), rule, inputs=src, order_only=t.files)
|
||||
res.append(str(dest))
|
||||
|
@ -353,12 +353,12 @@ def _(args: cli.Args):
|
|||
|
||||
@cli.command("r", "builder/run", "Run a component")
|
||||
def runCmd(args: cli.Args):
|
||||
scope = TargetScope.use(args)
|
||||
debug = args.consumeOpt("debug", False) is True
|
||||
wait = args.consumeOpt("wait", False) is True
|
||||
debugger = args.consumeOpt("debugger", "lldb")
|
||||
|
||||
componentSpec = args.consumeArg() or "__main__"
|
||||
componentSpec = "__main__" if componentSpec == "--" else componentSpec
|
||||
scope = TargetScope.use(args, {"debug": debug})
|
||||
|
||||
component = scope.registry.lookup(
|
||||
componentSpec, model.Component, includeProvides=True
|
||||
)
|
||||
|
@ -373,13 +373,25 @@ def runCmd(args: cli.Args):
|
|||
|
||||
if debug:
|
||||
if debugger == "lldb":
|
||||
shell.exec("lldb", "-o", "run", str(product.path), *args.args)
|
||||
shell.exec(
|
||||
"lldb",
|
||||
*(("-o", "b main") if wait else ()),
|
||||
*("-o", "run"),
|
||||
str(product.path),
|
||||
*args.extra,
|
||||
)
|
||||
elif debugger == "gdb":
|
||||
shell.exec("gdb", "-ex", "run", str(product.path), *args.args)
|
||||
shell.exec(
|
||||
"gdb",
|
||||
*(("-ex", "b main") if wait else ()),
|
||||
*("-ex", "run"),
|
||||
str(product.path),
|
||||
*args.extra,
|
||||
)
|
||||
else:
|
||||
raise RuntimeError(f"Unknown debugger {debugger}")
|
||||
else:
|
||||
shell.exec(str(product.path), *args.args)
|
||||
shell.exec(str(product.path), *args.extra)
|
||||
|
||||
|
||||
@cli.command("t", "builder/test", "Run all test targets")
|
||||
|
|
|
@ -16,10 +16,12 @@ _logger = logging.getLogger(__name__)
|
|||
class Args:
|
||||
opts: dict[str, Value]
|
||||
args: list[str]
|
||||
extra: list[str]
|
||||
|
||||
def __init__(self):
|
||||
self.opts = {}
|
||||
self.args = []
|
||||
self.extra = []
|
||||
|
||||
def consumePrefix(self, prefix: str) -> dict[str, Value]:
|
||||
result: dict[str, Value] = {}
|
||||
|
@ -56,13 +58,17 @@ class Args:
|
|||
def parse(args: list[str]) -> Args:
|
||||
result = Args()
|
||||
|
||||
for arg in args:
|
||||
for i in range(len(args)):
|
||||
arg = args[i]
|
||||
if arg.startswith("--") and not arg == "--":
|
||||
if "=" in arg:
|
||||
key, value = arg[2:].split("=", 1)
|
||||
result.opts[key] = value
|
||||
else:
|
||||
result.opts[arg[2:]] = True
|
||||
elif arg == "--":
|
||||
result.extra += args[i + 1 :]
|
||||
break
|
||||
else:
|
||||
result.args.append(arg)
|
||||
|
||||
|
|
|
@ -287,8 +287,8 @@ class Target(Manifest):
|
|||
return os.path.join(const.BUILD_DIR, f"{self.id}{postfix}")
|
||||
|
||||
@staticmethod
|
||||
def use(args: cli.Args) -> "Target":
|
||||
registry = Registry.use(args)
|
||||
def use(args: cli.Args, props: Props = {}) -> "Target":
|
||||
registry = Registry.use(args, props)
|
||||
targetSpec = str(args.consumeOpt("target", "host-" + shell.uname().machine))
|
||||
return registry.ensure(targetSpec, Target)
|
||||
|
||||
|
@ -536,7 +536,7 @@ class Registry(DataClassJsonMixin):
|
|||
return m
|
||||
|
||||
@staticmethod
|
||||
def use(args: cli.Args) -> "Registry":
|
||||
def use(args: cli.Args, props: Props = {}) -> "Registry":
|
||||
global _registry
|
||||
|
||||
if _registry is not None:
|
||||
|
@ -546,8 +546,7 @@ class Registry(DataClassJsonMixin):
|
|||
mixins = str(args.consumeOpt("mixins", "")).split(",")
|
||||
if mixins == [""]:
|
||||
mixins = []
|
||||
props = cast(dict[str, str], args.consumePrefix("prop:"))
|
||||
|
||||
props |= cast(dict[str, str], args.consumePrefix("prop:"))
|
||||
_registry = Registry.load(project, mixins, props)
|
||||
return _registry
|
||||
|
||||
|
|
|
@ -215,7 +215,11 @@ def podExecCmd(args: cli.Args):
|
|||
if not name.startswith(podPrefix):
|
||||
name = f"{podPrefix}{name}"
|
||||
|
||||
cmd = args.consumeArg()
|
||||
if cmd is None:
|
||||
raise RuntimeError("Missing command to execute")
|
||||
|
||||
try:
|
||||
shell.exec("docker", "exec", "-it", name, *args.args)
|
||||
shell.exec("docker", "exec", "-it", name, cmd, *args.extra)
|
||||
except Exception:
|
||||
raise RuntimeError(f"Pod '{name[len(podPrefix):]}' does not exist")
|
||||
|
|
Loading…
Reference in a new issue