diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 3ae92943..04a19eba 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -64,7 +64,11 @@ commonvars.AddVariables( ("UPLOAD_PROTOCOL",), ("UPLOAD_SPEED",), ("UPLOAD_FLAGS",), - ("UPLOAD_RESETMETHOD",) + ("UPLOAD_RESETMETHOD",), + + # debug options + ("DEBUG_TOOL",), + ) # yapf: disable diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index bc08f4f1..bfaa447e 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -832,9 +832,9 @@ def BuildProjectLibraries(env): project.env = env ldf_mode = LibBuilderBase.lib_ldf_mode.fget(project) - print "Library Dependency Finder -> http://bit.ly/configure-pio-ldf" - print "Modes: Finder/%s Compatibility/%s" % (ldf_mode, - project.lib_compat_mode) + print "Library Dependency Finder (LDF) -> http://bit.ly/configure-pio-ldf" + print "LDF MODES: FINDER/%s COMPATIBILITY/%s" % (ldf_mode, + project.lib_compat_mode) lib_builders = env.GetLibBuilders() print "Collected %d compatible libraries" % len(lib_builders) diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 38da971e..c668eaef 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -99,8 +99,8 @@ def LoadPioPlatform(env, variables): def PrintConfiguration(env): # pylint: disable=too-many-branches - platform_data = ["Platform: %s >" % env.PioPlatform().title] - system_data = ["System:"] + platform_data = ["PLATFORM: %s >" % env.PioPlatform().title] + system_data = ["SYSTEM:"] mcu = env.subst("$BOARD_MCU") f_cpu = env.subst("$BOARD_F_CPU") if mcu: @@ -131,7 +131,10 @@ def PrintConfiguration(env): # pylint: disable=too-many-branches if not debug_tools: return - data = [] + data = [ + "CURRENT/%s" % board_config.get_debug_tool_name( + env.subst("$DEBUG_TOOL")) + ] onboard = [] external = [] for key, value in debug_tools.items(): @@ -144,7 +147,7 @@ def PrintConfiguration(env): # pylint: disable=too-many-branches if external: data.append("EXTERNAL/%s" % ", ".join(sorted(external))) - print "Debug: %s" % " ".join(data) + print "DEBUG: %s" % " ".join(data) def exists(_): diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index ff7af319..7afa8587 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -220,9 +220,9 @@ def PrintUploadInfo(env): available.extend(env.BoardConfig().get("upload", {}).get( "protocols", [])) if available: - print "Available: %s" % ", ".join(sorted(available)) + print "AVAILABLE: %s" % ", ".join(sorted(available)) if configured: - print "Configured: upload_protocol = %s" % configured + print "CURRENT: upload_protocol = %s" % configured def exists(_): diff --git a/platformio/commands/run.py b/platformio/commands/run.py index fb185e8b..14db42a7 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -141,12 +141,11 @@ class EnvironmentProcessor(object): "monitor_dtr") IGNORE_BUILD_OPTIONS = ("test_transport", "test_filter", "test_ignore", - "test_port", "test_speed", "debug_tool", - "debug_port", "debug_init_cmds", - "debug_extra_cmds", "debug_server", - "debug_init_break", "debug_load_cmd", - "monitor_port", "monitor_baud", "monitor_rts", - "monitor_dtr") + "test_port", "test_speed", "debug_port", + "debug_init_cmds", "debug_extra_cmds", + "debug_server", "debug_init_break", + "debug_load_cmd", "monitor_port", "monitor_baud", + "monitor_rts", "monitor_dtr") REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"} diff --git a/platformio/exception.py b/platformio/exception.py index 1b8f3f45..afedf5a9 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -238,3 +238,15 @@ class CygwinEnvDetected(PlatformioException): MESSAGE = ("PlatformIO does not work within Cygwin environment. " "Use native Terminal instead.") + + +class DebugSupportError(PlatformioException): + + MESSAGE = ("Currently, PlatformIO does not support debugging for `{0}`.\n" + "Please mail contact@pioplus.com or visit " + "< http://docs.platformio.org/page/plus/debugging.html >") + + +class DebugInvalidOptions(PlatformioException): + + pass diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 1485059f..53fec46f 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -715,3 +715,32 @@ class PlatformBoardConfig(object): if key in ("default", "onboard"): tools[name][key] = value return {"tools": tools} + + def get_debug_tool_name(self, custom=None): + debug_tools = self._manifest.get("debug", {}).get("tools") + tool_name = custom + if tool_name == "custom": + return tool_name + if not debug_tools: + raise exception.DebugSupportError(self._manifest['name']) + if tool_name: + if tool_name in debug_tools: + return tool_name + raise exception.DebugInvalidOptions( + "Unknown debug tool `%s`. Please use one of `%s` or `custom`" % + (tool_name, ", ".join(sorted(debug_tools.keys())))) + + # automatically select best tool + default = [] + onboard = [] + external = [] + for key, value in debug_tools.items(): + if value.get("default"): + default.append(key) + elif value.get("onboard"): + onboard.append(key) + external.append(key) + + assert default or onboard or external + return (default[0] if default else onboard[0] + if onboard else external[0])