启动.json
\n...\n"preLaunchTask": "startDebug",\n"postDebugTask": "closeOpenOCDTerminal"\nRun Code Online (Sandbox Code Playgroud)\n任务.json
\n{\n"version": "2.0.0",\n"tasks": [\n {\n "label": "startDebug",\n "type": "shell",\n "command": "make -j4; openocd -f interface/cmsis-dap.cfg -c \'transport select swd\' -f target/stm32f1x.cfg",\n "isBackground": true,\n "problemMatcher": {\n "pattern": {\n "regexp": "."\n },\n "background": {\n "activeOnStart": true,\n "beginsPattern": ".",\n "endsPattern": "."\n }\n }\n },\n {\n "label": "closeOpenOCDTerminal",\n "type": "process",\n "command":[\n "${command:workbench.action.tasks.terminate}",\n // "${command:workbench.action.acceptSelectedQuickOpenItem}" //invalid\n ]\n }\n]\n}\nRun Code Online (Sandbox Code Playgroud)\nOpenOCD 服务不会像 make 命令那样自动结束,只依赖于关闭终端或者执行 Ctrl + C。\n如何在调试后自动关闭任务终端\xef\xbc\x9f\n或者在任务终端结束Openocd服务。\n当前使用的closeOpenOCDTerminal方法需要手动点击弹出列表。
\n{
"version": "2.0.0",
"tasks": [
{
"label": "start",
"type": "shell",
"command": "make -j4; openocd -f interface/cmsis-dap.cfg -c 'transport select swd' -f target/stm32f1x.cfg",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "."
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "."
}
}
},
{
"label": "stop",
"command": "echo ${input:terminate}",
"type": "shell",
}
],
"inputs": [
{
"id": "terminate",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "terminateAll"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这个例子恰好关闭了任务终端。