Add cmake.environmentSetupScript for preset mode#4996
Open
vasdal wants to merge 1 commit into
Open
Conversation
Presets can only bootstrap a parent environment on Windows (vcvarsall via
tryApplyVsDevEnv). Add a cross-platform setting that sources (Linux/macOS) or
calls (Windows) a script and uses its environment for presets, so environments
that cannot be expressed as static variables work with presets.
The script env is applied both to include/`$penv{}` resolution (via the presets
controller's settings environment) and to per-preset expansion and the
configure/build/test spawn (via preset.__parentEnvironment). Cached by script
path + mtime; re-applied when the setting changes.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changes visible behavior + adds a setting
The following changes are proposed:
cmake.environmentSetupScriptsetting. When using CMakePresets, CMake Tools sources (Linux/macOS) or calls (Windows) the script and
uses its environment as the parent environment.
$penv{}/includeresolution and toper-preset expansion + the configure/build/test spawn, so a single script
bootstraps everything. Cached by script path + mtime; re-applied on change.
The purpose of this change
Presets can only auto-bootstrap a parent environment on Windows (vcvarsall via
tryApplyVsDevEnv). On other platforms there's no way to source a setup script,so environments whose variables are large, interdependent, or produced by a
tool's own setup script can't be used with presets:
$penv{...}ininclude/toolchain paths doesn't resolve (presets may fail to load) andfind_package()fails at configure time. Reconstructing such environments asstatic
cmake.environmententries isn't viable; sourcing the script is — whichis exactly what kits already do. This brings that to preset mode,
cross-platform.
Other Notes/Information
__parentEnvironmentseam as the VS Dev Env; no new driver plumbing.${workspaceFolder}-style substitution.yarn.lockuntouched; no dependency changes.