Skip to content

Multi-line f-string for vs code configuration file contents #87

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: update_vscode_json_to_sdk1_5
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 130 additions & 121 deletions pico_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,127 +1128,136 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger):

for p in projects :
if p == 'vscode':
launch = ('{\n'
' "version": "0.2.0",\n'
' "configurations": [\n'
' {\n'
' "name": "Pico Debug (Cortex-Debug)",\n'
' "cwd": "${workspaceRoot}",\n'
' "executable": "${command:cmake.launchTargetPath}",\n'
' "request": "launch",\n'
' "type": "cortex-debug",\n'
' "servertype": "openocd",\n'
f' "gdbPath": "{gdbPath}",\n'
' "device": "RP2040",\n'
' "configFiles": [\n'
f' "interface/{debugger}",\n'
' "target/rp2040.cfg"\n'
' ],\n'
' "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",\n'
' "runToEntryPoint": "main",\n'
' // Give restart the same functionality as runToEntryPoint - main\n'
' "postRestartCommands": [\n'
' "break main",\n'
' "continue"\n'
' ],\n'
' "openOCDLaunchCommands": [\n'
' "adapter speed 1000"\n'
' ]\n'
' },\n'
' {\n'
' "name": "Pico Debug (Cortex-Debug with external OpenOCD)",\n'
' "cwd": "${workspaceRoot}",\n'
' "executable": "${command:cmake.launchTargetPath}",\n'
' "request": "launch",\n'
' "type": "cortex-debug",\n'
' "servertype": "external",\n'
' "gdbTarget": "localhost:3333",\n'
f' "gdbPath": "{gdbPath}",\n'
' "device": "RP2040",\n'
' "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",\n'
' "runToEntryPoint": "main",\n'
' // Give restart the same functionality as runToEntryPoint - main\n'
' "postRestartCommands": [\n'
' "break main",\n'
' "continue"\n'
' ]\n'
' },\n'
' {\n'
' "name": "Pico Debug (C++ Debugger)",\n'
' "type": "cppdbg",\n'
' "request": "launch",\n'
' "cwd": "${workspaceRoot}",\n'
' "program": "${command:cmake.launchTargetPath}",\n'
' "MIMode": "gdb",\n'
' "miDebuggerPath": "{gdbPath}",\n'
' "miDebuggerServerAddress": "localhost:3333",\n'
' "debugServerPath": "openocd",\n'
' "debugServerArgs": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \\"adapter speed 1000\\"",\n'
' "serverStarted": "Listening on port .* for gdb connections",\n'
' "filterStderr": true,\n'
' "stopAtEntry": true,\n'
' "hardwareBreakpoints": {\n'
' "require": true,\n'
' "limit": 4\n'
' },\n'
' "preLaunchTask": "Flash",\n'
' "svdPath": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd"\n'
' },\n'
' ]\n'
'}\n')

properties = ('{\n'
' "configurations": [\n'
' {\n'
' "name": "Pico",\n'
' "includePath": [\n'
' "${workspaceFolder}/**",\n'
' "${env:PICO_SDK_PATH}/**"\n'
' ],\n'
' "defines": [],\n'
f' "compilerPath": "{cPath}",\n'
' "cStandard": "c17",\n'
' "cppStandard": "c++14",\n'
' "intelliSenseMode": "linux-gcc-arm",\n'
' "configurationProvider" : "ms-vscode.cmake-tools"\n'
' }\n'
' ],\n'
' "version": 4\n'
'}\n')

settings = ( '{\n'
' "cmake.statusbar.advanced": {\n'
' "debug": {\n'
' "visibility": "hidden"\n'
' },\n'
' "launch": {\n'
' "visibility": "hidden"\n'
' },\n'
' "build": {\n'
' "visibility": "hidden"\n'
' },\n'
' "buildTarget": {\n'
' "visibility": "hidden"\n'
' }\n'
' },\n'
' "cmake.buildBeforeRun": true,\n'
' "cmake.configureOnOpen": true,\n'
' "cmake.configureSettings": {\n'
' "CMAKE_MODULE_PATH": "${env:PICO_INSTALL_PATH}/pico-sdk-tools"\n'
' },\n'
' "cmake.generator": "Ninja",\n'
' "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"\n'
'}\n')

extensions = ( '{\n'
' "recommendations": [\n'
' "marus25.cortex-debug",\n'
' "ms-vscode.cmake-tools",\n'
' "ms-vscode.cpptools",\n'
' "ms-vscode.cpptools-extension-pack",\n'
' "ms-vscode.vscode-serial-monitor"\n'
' ]\n'
'}\n')
# Visual Studio Code launch configurations
launch = f'''{{
"version": "0.2.0",
"configurations": [
{{
"name": "Pico Debug (Cortex-Debug)",
"cwd": "${{workspaceRoot}}",
"executable": "${{command:cmake.launchTargetPath}}",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"gdbPath": "{gdbPath}",
"device": "RP2040",
"configFiles": [
"interface/{debugger}",
"target/rp2040.cfg"
],
"svdFile": "${{env:PICO_SDK_PATH}}/src/rp2040/hardware_regs/rp2040.svd",
"runToEntryPoint": "main",
// Give restart the same functionality as runToEntryPoint - main
"postRestartCommands": [
"break main",
"continue"
],
"openOCDLaunchCommands": [
"adapter speed 1000"
]
}},
{{
"name": "Pico Debug (Cortex-Debug with external OpenOCD)",
"cwd": "${{workspaceRoot}}",
"executable": "${{command:cmake.launchTargetPath}}",
"request": "launch",
"type": "cortex-debug",
"servertype": "external",
"gdbTarget": "localhost:3333",
"gdbPath": "{gdbPath}",
"device": "RP2040",
"svdFile": "${{env:PICO_SDK_PATH}}/src/rp2040/hardware_regs/rp2040.svd",
"runToEntryPoint": "main",
// Give restart the same functionality as runToEntryPoint - main
"postRestartCommands": [
"break main",
"continue"
]
}},
{{
"name": "Pico Debug (C++ Debugger)",
"type": "cppdbg",
"request": "launch",
"cwd": "${{workspaceRoot}}",
"program": "${{command:cmake.launchTargetPath}}",
"MIMode": "gdb",
"miDebuggerPath": "{gdbPath}",
"miDebuggerServerAddress": "localhost:3333",
"debugServerPath": "openocd",
"debugServerArgs": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \\"adapter speed 1000\\"",
"serverStarted": "Listening on port .* for gdb connections",
"filterStderr": true,
"stopAtEntry": true,
"hardwareBreakpoints": {{
"require": true,
"limit": 4
}},
"preLaunchTask": "Flash",
"svdPath": "${{env:PICO_SDK_PATH}}/src/rp2040/hardware_regs/rp2040.svd"
}},
]
}}
'''

# cpp-tools extension settings
properties = f'''{{
"configurations": [
{{
"name": "Pico",
"includePath": [
"${{workspaceFolder}}/**",
"${{env:PICO_SDK_PATH}}/**"
],
"defines": [],
"compilerPath": "{cPath}",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-gcc-arm",
"configurationProvider": "ms-vscode.cmake-tools"
}}
],
"version": 4
}}
'''


# Visual Studio Code settings
settings = f'''{{
"cmake.statusbar.advanced": {{
"debug": {{
"visibility": "hidden"
}},
"launch": {{
"visibility": "hidden"
}},
"build": {{
"visibility": "hidden"
}},
"buildTarget": {{
"visibility": "hidden"
}}
}},
"cmake.buildBeforeRun": true,
"cmake.configureOnOpen": true,
"cmake.configureSettings": {{
"CMAKE_MODULE_PATH": "${{env:PICO_INSTALL_PATH}}/pico-sdk-tools"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note, PICO_INSTALL_PATH only exists on Windows when the installer is used. Should be harmless otherwise but should be tested I think.

}},
"cmake.generator": "Ninja",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}}
'''

# recommended Visual Studio Code extensions
extensions = f'''{{
"recommendations": [
"marus25.cortex-debug",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.vscode-serial-monitor"
]
}}
'''

# Create a build folder, and run our cmake project build from it
if not os.path.exists(VSCODE_FOLDER):
Expand Down