Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Provide "Command Substitutions" for launch.json or tasks.json. #74

Open
hwhsu1231 opened this issue Mar 31, 2022 · 0 comments

Comments

@hwhsu1231
Copy link

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 name environment 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": []
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant