From 04fed940ad985f47c0b140f062d0b60f147e82cd Mon Sep 17 00:00:00 2001 From: VAN BOSSUYT Nicolas Date: Wed, 27 Jul 2022 18:53:58 +0200 Subject: [PATCH] Tell why we disable a target. --- osdk/__init__.py | 19 +++++++++++++++++++ osdk/manifests.py | 2 ++ osdk/targets.py | 21 +++++++++++++-------- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/osdk/__init__.py b/osdk/__init__.py index ef9a0c4..2779f3b 100644 --- a/osdk/__init__.py +++ b/osdk/__init__.py @@ -57,6 +57,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 ") + 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) @@ -137,6 +152,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", diff --git a/osdk/manifests.py b/osdk/manifests.py index 5ed5c39..3277daf 100644 --- a/osdk/manifests.py +++ b/osdk/manifests.py @@ -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 diff --git a/osdk/targets.py b/osdk/targets.py index 70ea567..8fe1bad 100644 --- a/osdk/targets.py +++ b/osdk/targets.py @@ -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