Skip to content

Commit 94617d9

Browse files
committed
Multi-line f-string for vs code configuration file contents
1 parent 2f3efc5 commit 94617d9

File tree

1 file changed

+128
-121
lines changed

1 file changed

+128
-121
lines changed

pico_project.py

Lines changed: 128 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,127 +1128,134 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger):
11281128

11291129
for p in projects :
11301130
if p == 'vscode':
1131-
launch = ('{\n'
1132-
' "version": "0.2.0",\n'
1133-
' "configurations": [\n'
1134-
' {\n'
1135-
' "name": "Pico Debug (Cortex-Debug)",\n'
1136-
' "cwd": "${workspaceRoot}",\n'
1137-
' "executable": "${command:cmake.launchTargetPath}",\n'
1138-
' "request": "launch",\n'
1139-
' "type": "cortex-debug",\n'
1140-
' "servertype": "openocd",\n'
1141-
f' "gdbPath": "{gdbPath}",\n'
1142-
' "device": "RP2040",\n'
1143-
' "configFiles": [\n'
1144-
f' "interface/{debugger}",\n'
1145-
' "target/rp2040.cfg"\n'
1146-
' ],\n'
1147-
' "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",\n'
1148-
' "runToEntryPoint": "main",\n'
1149-
' // Give restart the same functionality as runToEntryPoint - main\n'
1150-
' "postRestartCommands": [\n'
1151-
' "break main",\n'
1152-
' "continue"\n'
1153-
' ],\n'
1154-
' "openOCDLaunchCommands": [\n'
1155-
' "adapter speed 1000"\n'
1156-
' ]\n'
1157-
' },\n'
1158-
' {\n'
1159-
' "name": "Pico Debug (Cortex-Debug with external OpenOCD)",\n'
1160-
' "cwd": "${workspaceRoot}",\n'
1161-
' "executable": "${command:cmake.launchTargetPath}",\n'
1162-
' "request": "launch",\n'
1163-
' "type": "cortex-debug",\n'
1164-
' "servertype": "external",\n'
1165-
' "gdbTarget": "localhost:3333",\n'
1166-
f' "gdbPath": "{gdbPath}",\n'
1167-
' "device": "RP2040",\n'
1168-
' "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",\n'
1169-
' "runToEntryPoint": "main",\n'
1170-
' // Give restart the same functionality as runToEntryPoint - main\n'
1171-
' "postRestartCommands": [\n'
1172-
' "break main",\n'
1173-
' "continue"\n'
1174-
' ]\n'
1175-
' },\n'
1176-
' {\n'
1177-
' "name": "Pico Debug (C++ Debugger)",\n'
1178-
' "type": "cppdbg",\n'
1179-
' "request": "launch",\n'
1180-
' "cwd": "${workspaceRoot}",\n'
1181-
' "program": "${command:cmake.launchTargetPath}",\n'
1182-
' "MIMode": "gdb",\n'
1183-
' "miDebuggerPath": "{gdbPath}",\n'
1184-
' "miDebuggerServerAddress": "localhost:3333",\n'
1185-
' "debugServerPath": "openocd",\n'
1186-
' "debugServerArgs": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \\"adapter speed 1000\\"",\n'
1187-
' "serverStarted": "Listening on port .* for gdb connections",\n'
1188-
' "filterStderr": true,\n'
1189-
' "stopAtEntry": true,\n'
1190-
' "hardwareBreakpoints": {\n'
1191-
' "require": true,\n'
1192-
' "limit": 4\n'
1193-
' },\n'
1194-
' "preLaunchTask": "Flash",\n'
1195-
' "svdPath": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd"\n'
1196-
' },\n'
1197-
' ]\n'
1198-
'}\n')
1199-
1200-
properties = ('{\n'
1201-
' "configurations": [\n'
1202-
' {\n'
1203-
' "name": "Pico",\n'
1204-
' "includePath": [\n'
1205-
' "${workspaceFolder}/**",\n'
1206-
' "${env:PICO_SDK_PATH}/**"\n'
1207-
' ],\n'
1208-
' "defines": [],\n'
1209-
f' "compilerPath": "{cPath}",\n'
1210-
' "cStandard": "c17",\n'
1211-
' "cppStandard": "c++14",\n'
1212-
' "intelliSenseMode": "linux-gcc-arm",\n'
1213-
' "configurationProvider" : "ms-vscode.cmake-tools"\n'
1214-
' }\n'
1215-
' ],\n'
1216-
' "version": 4\n'
1217-
'}\n')
1218-
1219-
settings = ( '{\n'
1220-
' "cmake.statusbar.advanced": {\n'
1221-
' "debug": {\n'
1222-
' "visibility": "hidden"\n'
1223-
' },\n'
1224-
' "launch": {\n'
1225-
' "visibility": "hidden"\n'
1226-
' },\n'
1227-
' "build": {\n'
1228-
' "visibility": "hidden"\n'
1229-
' },\n'
1230-
' "buildTarget": {\n'
1231-
' "visibility": "hidden"\n'
1232-
' }\n'
1233-
' },\n'
1234-
' "cmake.buildBeforeRun": true,\n'
1235-
' "cmake.configureOnOpen": true,\n'
1236-
' "cmake.configureSettings": {\n'
1237-
' "CMAKE_MODULE_PATH": "${env:PICO_INSTALL_PATH}/pico-sdk-tools"\n'
1238-
' },\n'
1239-
' "cmake.generator": "Ninja",\n'
1240-
' "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"\n'
1241-
'}\n')
1242-
1243-
extensions = ( '{\n'
1244-
' "recommendations": [\n'
1245-
' "marus25.cortex-debug",\n'
1246-
' "ms-vscode.cmake-tools",\n'
1247-
' "ms-vscode.cpptools",\n'
1248-
' "ms-vscode.cpptools-extension-pack",\n'
1249-
' "ms-vscode.vscode-serial-monitor"\n'
1250-
' ]\n'
1251-
'}\n')
1131+
launch = f'''{{
1132+
"version": "0.2.0",
1133+
"configurations": [
1134+
{{
1135+
"name": "Pico Debug (Cortex-Debug)",
1136+
"cwd": "${{workspaceRoot}}",
1137+
"executable": "${{command:cmake.launchTargetPath}}",
1138+
"request": "launch",
1139+
"type": "cortex-debug",
1140+
"servertype": "openocd",
1141+
"gdbPath": "{gdbPath}",
1142+
"device": "RP2040",
1143+
"configFiles": [
1144+
"interface/{debugger}",
1145+
"target/rp2040.cfg"
1146+
],
1147+
"svdFile": "${{env:PICO_SDK_PATH}}/src/rp2040/hardware_regs/rp2040.svd",
1148+
"runToEntryPoint": "main",
1149+
// Give restart the same functionality as runToEntryPoint - main
1150+
"postRestartCommands": [
1151+
"break main",
1152+
"continue"
1153+
],
1154+
"openOCDLaunchCommands": [
1155+
"adapter speed 1000"
1156+
]
1157+
}},
1158+
{{
1159+
"name": "Pico Debug (Cortex-Debug with external OpenOCD)",
1160+
"cwd": "${{workspaceRoot}}",
1161+
"executable": "${{command:cmake.launchTargetPath}}",
1162+
"request": "launch",
1163+
"type": "cortex-debug",
1164+
"servertype": "external",
1165+
"gdbTarget": "localhost:3333",
1166+
"gdbPath": "{gdbPath}",
1167+
"device": "RP2040",
1168+
"svdFile": "${{env:PICO_SDK_PATH}}/src/rp2040/hardware_regs/rp2040.svd",
1169+
"runToEntryPoint": "main",
1170+
// Give restart the same functionality as runToEntryPoint - main
1171+
"postRestartCommands": [
1172+
"break main",
1173+
"continue"
1174+
]
1175+
}},
1176+
{{
1177+
"name": "Pico Debug (C++ Debugger)",
1178+
"type": "cppdbg",
1179+
"request": "launch",
1180+
"cwd": "${{workspaceRoot}}",
1181+
"program": "${{command:cmake.launchTargetPath}}",
1182+
"MIMode": "gdb",
1183+
"miDebuggerPath": "{gdbPath}",
1184+
"miDebuggerServerAddress": "localhost:3333",
1185+
"debugServerPath": "openocd",
1186+
"debugServerArgs": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \\"adapter speed 1000\\"",
1187+
"serverStarted": "Listening on port .* for gdb connections",
1188+
"filterStderr": true,
1189+
"stopAtEntry": true,
1190+
"hardwareBreakpoints": {{
1191+
"require": true,
1192+
"limit": 4
1193+
}},
1194+
"preLaunchTask": "Flash",
1195+
"svdPath": "${{env:PICO_SDK_PATH}}/src/rp2040/hardware_regs/rp2040.svd"
1196+
}},
1197+
]
1198+
}}
1199+
'''
1200+
1201+
properties = f'''{{
1202+
"configurations": [
1203+
{{
1204+
"name": "Pico",
1205+
"includePath": [
1206+
"${{workspaceFolder}}/**",
1207+
"${{env:PICO_SDK_PATH}}/**"
1208+
],
1209+
"defines": [],
1210+
"compilerPath": "{cPath}",
1211+
"cStandard": "c17",
1212+
"cppStandard": "c++14",
1213+
"intelliSenseMode": "linux-gcc-arm",
1214+
"configurationProvider": "ms-vscode.cmake-tools"
1215+
}}
1216+
],
1217+
"version": 4
1218+
}}
1219+
'''
1220+
1221+
1222+
# settings
1223+
settings = f'''{{
1224+
"cmake.statusbar.advanced": {{
1225+
"debug": {{
1226+
"visibility": "hidden"
1227+
}},
1228+
"launch": {{
1229+
"visibility": "hidden"
1230+
}},
1231+
"build": {{
1232+
"visibility": "hidden"
1233+
}},
1234+
"buildTarget": {{
1235+
"visibility": "hidden"
1236+
}}
1237+
}},
1238+
"cmake.buildBeforeRun": true,
1239+
"cmake.configureOnOpen": true,
1240+
"cmake.configureSettings": {{
1241+
"CMAKE_MODULE_PATH": "${{env:PICO_INSTALL_PATH}}/pico-sdk-tools"
1242+
}},
1243+
"cmake.generator": "Ninja",
1244+
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
1245+
}}
1246+
'''
1247+
1248+
# extensions
1249+
extensions = f'''{{
1250+
"recommendations": [
1251+
"marus25.cortex-debug",
1252+
"ms-vscode.cmake-tools",
1253+
"ms-vscode.cpptools",
1254+
"ms-vscode.cpptools-extension-pack",
1255+
"ms-vscode.vscode-serial-monitor"
1256+
]
1257+
}}
1258+
'''
12521259

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

0 commit comments

Comments
 (0)