This commit is contained in:
Nicolas Van Bossuyt 2022-07-29 14:55:38 +02:00
commit 1f5cddb55f
3 changed files with 34 additions and 8 deletions

View file

@ -55,6 +55,21 @@ def runCmd(opts: dict, args: list[str]) -> None:
print(f"{utils.Colors.GREEN}Process exited with success{utils.Colors.RESET}")
def debugCmd(opts: dict, args: list[str]) -> None:
props = propsFromOptions(opts)
if len(args) == 0:
print(f"Usage: osdk debug <component>")
sys.exit(1)
out = build.buildOne(opts.get('target', 'default:debug'), args[0], props)
print()
print(f"{utils.Colors.BOLD}Debugging: {args[0]}{utils.Colors.RESET}")
utils.runCmd("/usr/bin/lldb", out, *args[1:])
print()
print(f"{utils.Colors.GREEN}Process exited with success{utils.Colors.RESET}")
def buildCmd(opts: dict, args: list[str]) -> None:
props = propsFromOptions(opts)
allTargets = opts.get('all-targets', False)
@ -135,6 +150,10 @@ CMDS = {
"func": runCmd,
"desc": "Run a component on the host",
},
"debug": {
"func": debugCmd,
"desc": "Run a component on the host in debug mode",
},
"build": {
"func": buildCmd,
"desc": "Build one or more components",

View file

@ -26,6 +26,8 @@ def filter(manifests: dict, target: dict) -> dict:
if not req in target["props"] or \
not target["props"][req] in manifest["requires"][req]:
accepted = False
print(
f"Disabling {id} because it requires {req}: {manifest['requires'][req]}")
break
manifest["enabled"] = accepted

View file

@ -48,8 +48,6 @@ def enableSan(target: dict) -> dict:
def enableColors(target: dict) -> dict:
target = copy.deepcopy(target)
if (target["props"]["toolchain"] == "clang"):
target = patchToolArgs(target, "cc", ["-fcolor-diagnostics"])
target = patchToolArgs(target, "cxx", ["-fcolor-diagnostics"])
@ -61,20 +59,25 @@ def enableColors(target: dict) -> dict:
def enableOptimizer(target: dict, level: str) -> dict:
target = copy.deepcopy(target)
target = patchToolArgs(target, "cc", ["-O" + level])
target = patchToolArgs(target, "cxx", ["-O" + level])
return target
def enableDebug(target: dict) -> dict:
target = patchToolArgs(target, "cc", ["-g"])
target = patchToolArgs(target, "cxx", ["-g"])
return target
def available() -> list:
return [file.removesuffix(".json") for file in utils.tryListDir("meta/targets")
if file.endswith(".json")]
VARIANTS = ["debug", "devel", "release", "sanatize"]
VARIANTS = ["debug", "devel", "fast", "san"]
def load(targetId: str, props: dict) -> dict:
@ -135,13 +138,15 @@ def load(targetId: str, props: dict) -> dict:
target = enableColors(target)
if targetVariant == "debug":
target = enableOptimizer(target, "g")
target = enableDebug(target)
target = enableOptimizer(target, "0")
elif targetVariant == "devel":
target = enableOptimizer(target, "2")
elif targetVariant == "release":
elif targetVariant == "fast":
target = enableOptimizer(target, "3")
elif targetVariant == "sanitize":
elif targetVariant == "san":
target = enableOptimizer(target, "g")
target = enableDebug(target)
target = enableSan(target)
return target