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

${buildType} doesnt work in launch.json #334

Closed
zbendefy opened this issue Mar 6, 2018 · 11 comments
Closed

${buildType} doesnt work in launch.json #334

zbendefy opened this issue Mar 6, 2018 · 11 comments
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: settings
Milestone

Comments

@zbendefy
Copy link

zbendefy commented Mar 6, 2018

I'm trying to set up a launch.json in VSCode, where upon launching, the currently selected built type is selected. So if I set cmake to debug, the Build/Debug/MyApp will launch, but if I select release, then Build/Release/MyApp will launch.

I tried to accomplish this according to the documentation here (I'm not sure if I followed it correctly): https://vector-of-bool.github.io/docs/vscode-cmake-tools/configuring.html?highlight=

In my launch.json I have something like this:

  {
  "name": "MyApp",
  "type": "cppdbg",
  "request": "launch",
  "program": "${workspaceFolder}/../Build/${buildType}/MyApp",  // <----- Here is where I tried to select the buildtype
  "stopAtEntry": false,
  "cwd": "${workspaceFolder}/Binary",
  "externalConsole": true,
  "MIMode": "gdb",
  "setupCommands": [
  		{
  				"description": "Enable pretty-printing for gdb",
  				"text": "-enable-pretty-printing",
  				"ignoreFailures": true
  		}
  ] 

}

Platform and Versions

  • Operating System: Linux Mint 18.3 64bit cinnamon
  • CMake Version: 3.5.1
  • VSCode Version: 1.20.1
  • CMake Tools Extension Version: 0.10.4
  • Compiler/Toolchain: GCC 6.3.0
@no-realm
Copy link
Contributor

no-realm commented Mar 6, 2018

That's not how this works. The variable substitution, at least to my knowledge, only works in the settings.json and maybe in the variant and kit json files (I can't remember right now).

@vector-of-bool
Copy link
Contributor

CMake Tools has no access to do those substitutions. You may want to look at ${command:cmake.launchTargetProgramPath}, which will substitute the path to the selected launch target.

@zbendefy
Copy link
Author

zbendefy commented Mar 6, 2018

@vector-of-bool Thanks, I actually found that, however I still need the buildType, because there are some other folders I need to set as Link directories. Is there a way to get that with a ${command:cmake.}?

@vector-of-bool
Copy link
Contributor

Not at the moment, but it's a valid feature request. I'll log it

@vector-of-bool vector-of-bool added the enhancement an enhancement to the product that is either not present or an improvement to an existing feature label Mar 6, 2018
@vector-of-bool vector-of-bool added this to the Backlog milestone Mar 6, 2018
@vincent-breysse
Copy link

Is there any progress on this feature ? I actually have pretty close needs.
I'd like to write something like this in my settings.json :

{

"catch2TestExplorer.executables": [
        {
            "name": "${filename}",
            "description": "${relDirpath}/",
            "pattern": "bin/${buildKit}/${buildType}/*"
        }
    ]

}

Maybe any workaround to advice ?

@notskm
Copy link
Contributor

notskm commented Aug 3, 2019

I found myself wanting this feature, too, but in tasks.json.

A task to use conan to install dependencies might look like this:

"tasks": [
  {
    "label": "conan install",
    "type": "shell",
    "options": {
      "cwd": "${command:cmake.buildDirectory}"
    },
    "command": "conan install ${workspaceRoot} -s build_type=${command:cmake.buildType}",
    "problemMatcher": []
  }
]

This would also make use of #564/#695

@xgdgsc
Copy link
Contributor

xgdgsc commented Nov 26, 2019

Hoping buildKit would work in launch.json. Since this is maintained by microsoft now.

@bobbrow
Copy link
Member

bobbrow commented Nov 26, 2019

I forgot to close this issue since it was fixed in 1.2. @xgdgsc the referenced Pull Request shows what needs to be done to add a new command. If you want to follow that pattern to add support for buildKit, we would accept a PR. I believe the data you are looking for is in this.activeKit.name (when this.activeKit is non-null).

@xgdgsc
Copy link
Contributor

xgdgsc commented Nov 27, 2019

Great. I will send a PR in a month.

@mfdeveloper
Copy link

Hello @xgdgsc and @bobbrow !!

How can I get the current buildKit.compiler of C or CXX properties in tasks.json or launch.json ?
Using ${command:cmake.buildKit} I've got just the name, right ?

@bobbrow
Copy link
Member

bobbrow commented Aug 13, 2020

@mfdeveloper I'm going to move your request to a new issue. This issue should have been closed. The solution for the original request is to use ${command:cmake.buildType} instead of ${buildType} in launch.json and tasks.json

@bobbrow bobbrow closed this as completed Aug 13, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: settings
Projects
None yet
Development

No branches or pull requests

8 participants