From b1caaa2208c546a4cfe5927e3b4d4b79f408fb01 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 Apr 2018 20:37:41 +0300 Subject: [PATCH] Export path to SVD file for IDEs --- platformio/builder/tools/pioide.py | 17 ++++++++++++++++- .../ide/tpls/vscode/.vscode/launch.json.tpl | 10 ++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index b8e5c346..cfb93fc8 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -16,7 +16,7 @@ from __future__ import absolute_import from glob import glob from os import environ -from os.path import abspath, join +from os.path import abspath, dirname, join from SCons.Defaults import processDefines @@ -107,6 +107,19 @@ def _dump_defines(env): return defines +def _get_svd_path(env): + if "BOARD" not in env: + return None + try: + svd_path = env.BoardConfig().get("debug.svd_path") + except KeyError: + return None + if not svd_path: + return None + with util.cd(dirname(env.BoardConfig().manifest_path)): + return abspath(svd_path) + + def DumpIDEData(env): LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS" LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS" @@ -130,6 +143,8 @@ def DumpIDEData(env): util.where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")), "prog_path": env.subst("$PROG_PATH"), + "svd_path": + _get_svd_path(env), "compiler_type": env.GetCompilerType() } diff --git a/platformio/ide/tpls/vscode/.vscode/launch.json.tpl b/platformio/ide/tpls/vscode/.vscode/launch.json.tpl index 0277c921..fc6de3b4 100644 --- a/platformio/ide/tpls/vscode/.vscode/launch.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/launch.json.tpl @@ -28,18 +28,24 @@ { "type": "platformio-debug", "request": "launch", - "name": "PlatformIO Debugger (Beta)", + "name": "PlatformIO Debugger (Dev)", "executable": "{{ _escape_path(prog_path) }}", "toolchainBinDir": "{{ _escape_path(dirname(gdb_path)) }}", +% if svd_path: + "svdPath": "{{ _escape_path(svd_path) }}", +% end "preLaunchTask": "PlatformIO: Pre-Debug", "internalConsoleOptions": "openOnSessionStart" }, { "type": "platformio-debug", "request": "launch", - "name": "PlatformIO Debugger (Beta) (Quick)", + "name": "PlatformIO Debugger (Dev) (Quick)", "executable": "{{ _escape_path(prog_path) }}", "toolchainBinDir": "{{ _escape_path(dirname(gdb_path)) }}", +% if svd_path: + "svdPath": "{{ _escape_path(svd_path) }}", +% end "internalConsoleOptions": "openOnSessionStart" } ]