I use VSC to compile and debug a CPP generated test executable. The name of the executable and makefile changes depending on which build I’m debugging, and importantly there is only ever a single executable/makefile in my workspace directory.
I’m wondering if there’s a way to simply build/debug the makefile/exe that is found within the directory, as my current solution is to create a new build task/launch configuration (or update my existing configuration) for each build with the updated exe/makefile name, but this is of course not an ideal solution.
"tasks":[
{
"label": "Build A",
"type": "shell",
"command": "vcvars32.bat && nmake /nologo /S /F .\TestA.mak",
"group": "build",
"options": {"cwd": "${workspaceFolder}"
},
{
"label": "Build B",
"type": "shell",
"command": "vcvars32.bat && nmake /nologo /S /F .\TestB.mak",
"group": "build",
"options": {"cwd": "${workspaceFolder}"
},
]
"configurations":
[
{
"name": "Test A",
"program": "${workspaceRoot}\TestA.exe"
"cwd": "${fileDirname}",
...
},
{
"name": "Test B",
"program": "${workspaceRoot}\TestB.exe"
"cwd": "${fileDirname}",
...
}
]
Changing the name of the makefile/exe is not a solution here, I’m limited by the tools my org uses.
For reference, I open create a new workspace for each build. Our codebase is auto-generated code, so for each build, each required .cpp/.hpp is generated. Having a new workspace for each build means I don’t have duplicates of files. I don’t know if this is the optimal workflow for me.. but it works. As such, having some easily transferable/global build tasks/run configurations would make my life a little bit easier.
EDIT:
I was able to set up my task.json for this, just need to figure out for launch configurations 🙂
"tasks":[
{
"label": "Build",
"type": "shell",
"command": "vcvars32.bat && for /r ${workspaceFolder} %i in (*.mak) do nmake /nologo /S /F %i",
"group": "build",
"options": {"cwd": "${workspaceFolder}"
},
]
2
Answers
Using the extension Command Variable you can add a pickFile selection:
Global
tasks.json
The property
"acceptIfOneFile": true
is implemented in v1.45.You can do the same for your Global Launch configs in
settings.json
You can use a compound task to build using your
for
trick in the OP:Global
tasks.json
In your Global Launch config use the exe
TestRENAME.exe