mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Preserve user-specified debug configurations in VSCode integration (#3878)
* Preserve user-specified debug configurations in VSCode integration Issue #3824 * Tidy up Python code
This commit is contained in:
@ -15,6 +15,7 @@ PlatformIO Core 5
|
||||
* Fixed an issue with `device monitor <https://docs.platformio.org/page/core/userguide/device/cmd_monitor.html>`__ when the "send_on_enter" filter didn't send EOL chars (`issue #3787 <https://github.com/platformio/platformio-core/issues/3787>`_)
|
||||
* Fixed an issue with silent mode when unwanted data is printed to stdout (`issue #3837 <https://github.com/platformio/platformio-core/issues/3837>`_)
|
||||
* Fixed an issue when code inspection fails with "Bad JSON" (`issue #3790 <https://github.com/platformio/platformio-core/issues/3790>`_)
|
||||
* Fixed an issue with overriding user-specified debugging configuration information in VSCode (`issue #3824 <https://github.com/platformio/platformio-core/issues/3824>`_)
|
||||
|
||||
5.1.0 (2021-01-28)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
130
platformio/ide/tpls/vscode/.vscode/launch.json.tpl
vendored
130
platformio/ide/tpls/vscode/.vscode/launch.json.tpl
vendored
@ -1,50 +1,96 @@
|
||||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
||||
|
||||
// PIO Unified Debugger
|
||||
//
|
||||
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
||||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
||||
|
||||
% from os.path import dirname, join
|
||||
% import codecs
|
||||
% import json
|
||||
% import os
|
||||
%
|
||||
% def _escape(text):
|
||||
% return text.replace('"', '\"')
|
||||
% end
|
||||
%
|
||||
% def _escape_path(path):
|
||||
% return path.replace('\\\\', '/').replace('\\', '/').replace('"', '\\"')
|
||||
% end
|
||||
%
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug",
|
||||
"executable": "{{ _escape_path(prog_path) }}",
|
||||
"projectEnvName": "{{ env_name }}",
|
||||
"toolchainBinDir": "{{ _escape_path(dirname(gdb_path)) }}",
|
||||
% if svd_path:
|
||||
"svdPath": "{{ _escape_path(svd_path) }}",
|
||||
% def get_pio_configurations():
|
||||
% predebug = {
|
||||
% "type": "platformio-debug",
|
||||
% "request": "launch",
|
||||
% "name": "PIO Debug (skip Pre-Debug)",
|
||||
% "executable": _escape_path(prog_path),
|
||||
% "projectEnvName": env_name,
|
||||
% "toolchainBinDir": _escape_path(os.path.dirname(gdb_path)),
|
||||
% "internalConsoleOptions": "openOnSessionStart",
|
||||
% }
|
||||
%
|
||||
% if svd_path:
|
||||
% predebug["svdPath"] = _escape_path(svd_path)
|
||||
% end
|
||||
% debug = predebug.copy()
|
||||
% debug["name"] = "PIO Debug"
|
||||
% debug["preLaunchTask"] = {
|
||||
% "type": "PlatformIO",
|
||||
% "task": ("Pre-Debug (%s)" % env_name) if len(config.envs()) > 1 else "Pre-Debug",
|
||||
% }
|
||||
% return [debug, predebug]
|
||||
% end
|
||||
"preLaunchTask": {
|
||||
"type": "PlatformIO",
|
||||
% if len(config.envs()) > 1:
|
||||
"task": "Pre-Debug ({{ env_name }})"
|
||||
% else:
|
||||
"task": "Pre-Debug"
|
||||
%
|
||||
% def _remove_comments(lines):
|
||||
% data = ""
|
||||
% for line in lines:
|
||||
% line = line.strip()
|
||||
% if not line.startswith("//"):
|
||||
% data += line
|
||||
% end
|
||||
% end
|
||||
% return data
|
||||
% end
|
||||
},
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug (skip Pre-Debug)",
|
||||
"executable": "{{ _escape_path(prog_path) }}",
|
||||
"projectEnvName": "{{ env_name }}",
|
||||
"toolchainBinDir": "{{ _escape_path(dirname(gdb_path)) }}",
|
||||
% if svd_path:
|
||||
"svdPath": "{{ _escape_path(svd_path) }}",
|
||||
%
|
||||
% def _contains_external_configurations(launch_config):
|
||||
% return any(
|
||||
% c.get("type", "") != "platformio-debug"
|
||||
% for c in launch_config.get("configurations", [])
|
||||
% )
|
||||
% end
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
||||
%
|
||||
% def _remove_pio_configurations(launch_config):
|
||||
% if "configurations" not in launch_config:
|
||||
% return launch_config
|
||||
% end
|
||||
%
|
||||
% external_configurations = [
|
||||
% config
|
||||
% for config in launch_config["configurations"]
|
||||
% if config.get("type", "") != "platformio-debug"
|
||||
% ]
|
||||
%
|
||||
% launch_config["configurations"] = external_configurations
|
||||
% return launch_config
|
||||
% end
|
||||
%
|
||||
% def get_launch_configuration():
|
||||
% launch_config = {"version": "0.2.0", "configurations": []}
|
||||
% launch_file = os.path.join(project_dir, ".vscode", "launch.json")
|
||||
% if os.path.isfile(launch_file):
|
||||
% with codecs.open(launch_file, "r", encoding="utf8") as fp:
|
||||
% launch_data = _remove_comments(fp.readlines())
|
||||
% try:
|
||||
% prev_config = json.loads(launch_data)
|
||||
% if _contains_external_configurations(prev_config):
|
||||
% launch_config = _remove_pio_configurations(prev_config)
|
||||
% end
|
||||
% except:
|
||||
% pass
|
||||
% end
|
||||
% end
|
||||
% end
|
||||
% launch_config["configurations"].extend(get_pio_configurations())
|
||||
% return launch_config
|
||||
% end
|
||||
%
|
||||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
||||
//
|
||||
// PIO Unified Debugger
|
||||
//
|
||||
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
||||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
||||
|
||||
{{ json.dumps(get_launch_configuration(), indent=4, ensure_ascii=False) }}
|
||||
|
Reference in New Issue
Block a user