-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
:build:vscode-debug module generates VSCode debug config file
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2021, Raphael Lehmann | ||
# | ||
# This file is part of the modm project. | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# ----------------------------------------------------------------------------- | ||
|
||
from os.path import join, relpath, isdir, exists | ||
|
||
def init(module): | ||
module.name = ":build:vscode-debug" | ||
module.description = FileReader("module.md") | ||
|
||
|
||
def prepare(module, options): | ||
if not options[":target"].has_driver("core:cortex-m*"): | ||
return False | ||
else: | ||
return True | ||
|
||
|
||
def build(env): | ||
pass | ||
|
||
|
||
def post_build(env): | ||
debug_profiles = list() | ||
build_path = env.relative_outpath(env["::build.path"]) | ||
for buildtool in ["scons", "make", "cmake"]: | ||
for profile in ["release", "debug"]: | ||
if env.has_module(":build:" + buildtool): | ||
debug_profiles.append({ | ||
"name": buildtool + " profile=" + profile, | ||
"executable": "".join([build_path, "/", buildtool, "-", profile, "/", env[":build:project.name"], ".elf"]), | ||
}) | ||
|
||
env.substitutions.update({ | ||
"profiles": debug_profiles, | ||
"target": str(env[":target"]), | ||
}) | ||
# these are the ONLY files that are allowed to NOT be namespaced with modm! | ||
env.outbasepath = ".vscode/" | ||
env.template("resources/vscode_launch.json.in", "launch.json") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Visual Studio Code (VSCode) Debug Configuration | ||
|
||
[Visual Studio Code (VSCode)][VSCode] is a popular IDE with an integrated debugger UI. | ||
Together with the [Cortex-Debug][] extension it works great for Cortex-M targets. | ||
This modules generates a configuration suitable to launch the debugger with | ||
a single click (or keyboard shortcut) from the IDE. | ||
|
||
|
||
[VSCode]: https://code.visualstudio.com/ | ||
[Cortex-Debug]: https://github.com/Marus/cortex-debug#readme |
19 changes: 19 additions & 0 deletions
19
tools/build_script_generator/vscode_debug/resources/vscode_launch.json.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
%% for profile in profiles | ||
{ | ||
"name": "modm debug configuration ({{ profile.name }}) for {{ target }}", | ||
"cwd": "${workspaceRoot}", | ||
"executable": "{{ profile.executable }}", | ||
"request": "launch", | ||
"type": "cortex-debug", | ||
"servertype": "openocd", | ||
"device": "{{ target }}", | ||
"configFiles": [ | ||
"modm/openocd.cfg" | ||
] | ||
}{% if not loop.last %},{% endif %} | ||
%% endfor | ||
] | ||
} |