diff options
| author | Don <don.j.olmstead@gmail.com> | 2019-03-28 14:34:26 -0700 |
|---|---|---|
| committer | Phil Christensen <philc@microsoft.com> | 2019-03-28 14:34:26 -0700 |
| commit | d71ad4800bd5023f1452200af6c29832673892dc (patch) | |
| tree | f4ee58b1a5733b7d2868305cf60f7d1bae3f468e | |
| parent | 78a8de6cf468dc3d3301b26fedae7969bb366a75 (diff) | |
| download | vcpkg-d71ad4800bd5023f1452200af6c29832673892dc.tar.gz vcpkg-d71ad4800bd5023f1452200af6c29832673892dc.zip | |
Allow additional environment variables to be set in a clean environment (#5650)
* Allow additional environment variables to be set in a clean environment
* Add documentation for VCPKG_KEEP_ENV_VARS
| -rw-r--r-- | docs/users/config-environment.md | 7 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/base/system.cpp | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/docs/users/config-environment.md b/docs/users/config-environment.md index f25df89a3..bffa07278 100644 --- a/docs/users/config-environment.md +++ b/docs/users/config-environment.md @@ -40,3 +40,10 @@ This environment variable can be set to a triplet name which will be used for un #### VCPKG_FORCE_SYSTEM_BINARIES
This environment variable, if set, suppresses the downloading of CMake and Ninja and forces the use of the system binaries.
+
+### VCPKG_KEEP_ENV_VARS
+
+This environment variable can be set to a list of environment variables, separated by `;`, which will be propagated to
+the build environment.
+
+Example: `FOO_SDK_DIR;BAR_SDK_DIR`
diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index 90b9c34b3..6ddf17496 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -178,6 +178,19 @@ namespace vcpkg::System L"ANDROID_NDK_HOME", }; + const Optional<std::string> keep_vars = System::get_environment_variable("VCPKG_KEEP_ENV_VARS"); + const auto k = keep_vars.get(); + + if (k && !k->empty()) + { + auto vars = Strings::split(*k, ";"); + + for (auto&& var : vars) + { + env_wstrings.push_back(Strings::to_utf16(var.c_str())); + } + } + std::wstring env_cstr; for (auto&& env_wstring : env_wstrings) |
