Using preLaunchTask with Cmake Tools
See original GitHub issueAfter some fiddling I finally found out how to invoke cmake.build properly from within launch.json.
Steps:
- create a ba(t)ch file someFolder/prelaunch.bash:
#!/bin/bash
if [ $1 == 0 ]
then
printf "Build is OK :-)\n"
exit 0
fi
if [ $1 == 1 ]
then
printf "**** Please build project first. ****\n\n"
exit 1
else
printf "**** Please fix build errors. ****\n\n"
fi
exit 2
- create the following task:
{
"label": "Check build",
"type": "shell",
"options": { "statusbar": { "hide" : true } },
"presentation": {
"echo": false,
"focus": false,
"reveal": "never",
"revealProblems": "always" // Use "always" to default to the "problems" window or "never" to default to the "output" window after build.
},
"command" : "someFolder/prelaunch.bash ${command:cmake.build}"
}
-
add the preLaunchTask to launch.json:
"preLaunchTask": "Check build" -
change the source code of the extension (main.js in the VS code extensions folder):
/**
* Implementation of `cmake.build`
*/
async build(target_) {
this.m_promise_build = await this.runBuild(target_); // add await to the build function
//return this.m_promise_build; // comment this and add the following line
return JSON.stringify(this.m_promise_build);
}
Is there any chance this modification gets into the releases? Or add an implementation (eg. cmake.prebuild)?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:13 (8 by maintainers)
Top Results From Across the Web
preLaunchTask to build using cmaketools in settings.json #540
I've tried using a build task but I couldnt get it to work. Is there any way to do this currently? { //...
Read more >Target Debugging and Launching — CMake Tools 1.4.0 ...
CMake Tools removes some of the friction required in setting up debugging. ... Debugging is only supported when using CMake Server mode.
Read more >VSCode make launch configuration fail if preLaunchTask fails
I had the same problem with a cmake task. I've solved it by changing task's type to shell and passing everything else in...
Read more >vscode-cmake-tools/support - Gitter
Just wanting to know if anyone recommends using cmake-tools-helper , or not? ... "preLaunchTask": "clang++ build active file", "logging": { "trace": true, ...
Read more >Debug an app running in a Docker container
The Docker extension provides a docker debug configuration provider that manages how VS Code will launch an application and/or attach a debugger to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Oops! Yes you did. 😅 Try this instead:
The first parameter is a vscode.WorkspaceFolder (can be
undefinedif you want to use the currently “active” folder as context) The second parameter is the target nameThis is exactly what I did. I noticed it was possible to Ctrl+click the links in the terminal window indeed, however creating a dedicated .js (using the Powertools extension) provided the most flexible solution.
I created a .js file with the following command implementation:
Next, I called this command directly from the preBuildTask.