vscode-qt-tools
vscode-qt-tools copied to clipboard
[feature] Provide "Command Substitutions" for `launch.json` or `tasks.json`.
Problem to solve
@tonka3000 About what you said in this reply,
For dev scenario it would be better to inject the PATH variable automatically into
launch.json
. There is a dedicated variable nameenvironment
for that. That way it would be automatically done for you without any copy of files.
If we use this method, we have to manually prepend those bin
directory into environment variable PATH
. Then, if we change another version of Qt, we also need to modify the value of that. It's very cumbersome.
Proposal
Here's my advise. After Qt-Tools found the Qt Kits, it can provides some Command Substitutions just like CMake-Tools does. After that, we can prepend PATH
with the bin
directory of Qt that variable in launch.json
. Moreover, we may use them in program
of tasks.json
.
Further details
Provide some Command Substitutions like:
-
qt.getQtPrefixPath
: "C:\Qt\6.2.0\msvc2019" -
qt.getDeployqtPath
: "C:\Qt\6.2.0\msvc2019\bin\windeployqt.exe" -
qt.getQmakePath
: "C:\Qt\6.2.0\msvc2019\bin\qmake.exe" -
qt.getUicPath
: "C:\Qt\6.2.0\msvc2019\bin\uic.exe" -
qt.getMocPath
: "C:\Qt\6.2.0\msvc2019\bin\moc.exe"
Case 1: Prepend the bin
directory to environment variable PATH
:
{
"version": "0.2.0",
"configurations": [
{
"name": "(CMake) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"cwd": "${command:cmake.launchTargetDirectory}",
"stopAtEntry": false,
"environment": [
{
"name": "PATH",
"value": "${command:qt.getQtPrefixPath}/bin;${env:PATH}"
}
],
"console": "externalTerminal"
}
]
}
Case 2: Use it in program
of tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "Qt Deploy executable",
"type": "shell",
"command": "${command:qt.getDeployqtPath}",
"args": [
"${command:cmake.launchTargetPath}"
"--verbose 2",
"--no-translations"
],
"problemMatcher": []
}
]
}