-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Added system to store and query properties from the active C/C++ configuration #5453
Conversation
@bugengine All the other properties in c_cpp_properties.json have a corresponding C_Cpp.default.* setting to enable a default to be set when no c_cpp_properties.json exist. Do you think adding that would be good? If not, it seems like we could wait for other user requests for it. |
Hi Sean, I added the possibility to set default properties in the settings like other entries. While doing this I used the convention that if in a configuration, the "${default}" property is added, then the default properties from the settings will be pulled from the configuration. Some notes:
While implementing this I noticed that the setting cannot be edited with the UI and I did not manage to implement this as I did not find a control for editing dictionaries of strings (other settings are string or list of strings), so the properties can only be set by editing the JSON file. |
Does it make sense to have a default setting for the usage purpose of this new "property"? |
Yeah, the settings UI is limited in it's ability to work with objects/dictionaries. I think it would require changes from VS Code. |
I'm not sure, but it seems possible. Do you disagree? |
Regarding the purpose of this new "property":
Does it make sense to add it to the C/C++ configuration settings? The C/C++ configuration settings primary purpose is to set information for IntelliSense engine and not info for launching. |
It makes sense to me -- I've always wanted an easy way to switch between Debug and Release configurations similar to VS. We have the config in the UI to switch, so overloading that to switch build values to use seems convenient. |
The concern is also on user experience. Configuring IntelliSense settings is not straightforward as it is, so adding this new setting may cause more confusion. |
@michelleangela @Colengms Is this okay to be based off and targetting the release branch? Usually we work out of master, although sometimes we recommend external users use the release branch if master has breaking changes that aren't compatible with the published cpptools binary. If we check this into the release branch, we'll want to cherry pick it into master afterwards. |
We definitely get lots of users who confused by thinking the c_cpp_properties.json properties should affect their tasks.json builds (i.e. the includePath isn't used for compiling). I figure that customProperties would be considered an advanced property that most users would ignore when setting up IntelliSense (i.e. it wouldn't appear in the UI), so the amount of additional confusion seems like it would be minimal and its use is unlikely to cause breakage, since it's opt-in. |
Using master was my first choice, but I read the contributing guide and there was no specific mention of a branch, or I missed it. The documentation for building and debugging the extension does mention to clone the release branch, so I went with that. I have learnt for the future :)
I agree it's actually not the right place, I think the issue is that there is no right place in VSCode as VSCode does not offer the concept of build variants directly. For instance the CMake tools for VSCode also added their variants as an extension and provide commands to fetch some values. If I could influence VSCode, I would say that the tasks.json file should direct that information, and cpptools/intellisense should be a client of the variant name and te properties (including user properties). |
Confirmed that this can go to into release branch, and we'll cherry pick into master after. |
…iguration (#5453) * Added system to store and query properties from the active C/C++ configuration Co-authored-by: yngwe@farnsworth <yngwe@farnsworth> Co-authored-by: yngwe@bender <yngwe@bender>
@bugengine This is available with https://github.com/microsoft/vscode-cpptools/releases/tag/0.29.0-insiders now. |
Is "activeConfigCustomVariable" usable in settings.json so I can use it in cmake configuration? The variables is defined in c_cpp_properties.json this way: This is not working and the content of Please note that "${command:cpptools.activeConfigName}" works as expted. So Iam suspecting that the way I am calling :myvar is incorrect. Can you plz help me resolve this? Thanks |
@SafwenBenJha I think it only works in launch.json via something like:
|
@bugengine @sean-mcmanus The solution presented here is useful, but I have some problems with it:
|
@PetaSoft Did you have a suggestion on how to make it better in regards to 1 and 2? |
@sean-mcmanus I think my comment is already a suggestion to make it better:
|
I ran into complexity issues when setting up configurations in cpptools. The main issue was that there was no way to affect the launch configuration depending on the currently active C++ configuration. In particular, my C++ configurations place the output binary in different folders. From the launch.json file, I did not have a way to query the output path or any property, that would allow a single launch configuration to "do the right thing". The workaround was to create one launch configuration per C++ configuration, which is a lot of additional work to maintain.
I described the issue on StackOverflow there: https://stackoverflow.com/questions/61685124/how-can-i-tie-together-the-c-c-configurations-in-vscode-with-the-tasks-and-lau
I went ahead and added a system that lets users store arbitrary properties in the C/C++ configuration files and to query them using a new command.
Example c_cpp_properties:
How to use it in launch.json: