microsoft / microsoft/vscode-cmake-tools
Add `envFile` property for dynamic injection of env vars before Configuration/Build
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
Add an `envFile` property in `settings.json` to support `dotenv` files. This way we could inject env variables programmatically generated in a `dotenv` file by an upstream process. C/C++ extension provides this property for debugger configuration in `launch.json`.
### Rational
It would be very useful when using `conan` for example. Indeed it is able to create a `dotenv` file setting `PATH`, `LD_LIBRARY_PATH` and `DYLD_LIBRARY_PATH` to build tools runtimes.
For example let's say I want to compile SPIRV shaders through CMake:
- I can install a SPIRV compiler at system level.
- or I can install a SPIRV compiler (`glslang` or `shaderc`) through conan, but it can work with CMake only if these executables are in `PATH`, and their shared libs dependencies in `PATH` (on Windows), `LD_LIBRARY_PATH` (Linux) or `DYLD_LIBRARY_PATH` (Macos).
Manual setting of env variables in current CMake Tools is not generic enough, conan paths are very specific to each dependency and complex (different for each version, os, arch, compiler).
`environmentSetupScript` works but it's quite static and tied to kits (and I think that this property should not be in kits but settings, or there should be a way to add this in settings also). It means that you have to reload the kit after a modification of the script. It's not very intuitive. And it doesn't seem to work on Windows with `.bat` (https://github.com/microsoft/vscode-cmake-tools/issues/1463).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the settings.json handling and the existing environmentSetupScript entry point in CMake Tools, then compare the requested behavior with the envFile property used in C/C++ launch.json configurations. Define how a dotenv file is loaded before configuration and build, including updates without requiring a kit reload, and verify the behavior across the Windows, Linux, and macOS environment variables described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, typescript
- Domain
- build-system, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100