aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/system.cpp
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2020-10-06 12:06:26 -0700
committerGitHub <noreply@github.com>2020-10-06 12:06:26 -0700
commit8fe1851e1eb51a971b2b7cfdb8161ac03bbbd6d5 (patch)
treebe0a98124bdd9702c32692caa58a5ff76b4ae8ad /toolsrc/src/vcpkg-test/system.cpp
parent587dc2ed881b885f715fae623e6fee96ce526fe4 (diff)
downloadvcpkg-8fe1851e1eb51a971b2b7cfdb8161ac03bbbd6d5.tar.gz
vcpkg-8fe1851e1eb51a971b2b7cfdb8161ac03bbbd6d5.zip
[vcpkg] Enable reentrant vcpkg calls (#13751)
* [vcpkg] Enable recursive vcpkg calls Via envvars VCPKG_COMMAND and VCPKG_X_RECURSIVE_DATA. Child processes can call vcpkg via "$VCPKG_COMMAND <args>" in limited internal circumstances. * [vcpkg] Address CR comments * [vcpkg] Do not move through Optional<&> into Optional<T> Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test/system.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/system.cpp30
1 files changed, 1 insertions, 29 deletions
diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp
index dec7b5769..e7f8aca8f 100644
--- a/toolsrc/src/vcpkg-test/system.cpp
+++ b/toolsrc/src/vcpkg-test/system.cpp
@@ -23,39 +23,11 @@ using vcpkg::Checks::check_exit;
using vcpkg::System::CPUArchitecture;
using vcpkg::System::get_environment_variable;
using vcpkg::System::guess_visual_studio_prompt_target_architecture;
+using vcpkg::System::set_environment_variable;
using vcpkg::System::to_cpu_architecture;
namespace
{
- void set_environment_variable(ZStringView varname, Optional<std::string> value)
- {
-#if defined(_WIN32)
- const auto w_varname = vcpkg::Strings::to_utf16(varname);
- const auto w_varcstr = w_varname.c_str();
- BOOL exit_code;
- if (value)
- {
- const auto w_value = vcpkg::Strings::to_utf16(value.value_or_exit(VCPKG_LINE_INFO));
- exit_code = SetEnvironmentVariableW(w_varcstr, w_value.c_str());
- }
- else
- {
- exit_code = SetEnvironmentVariableW(w_varcstr, nullptr);
- }
-
- check_exit(VCPKG_LINE_INFO, exit_code != 0);
-#else // ^^^ defined(_WIN32) / !defined(_WIN32) vvv
- if (auto v = value.get())
- {
- check_exit(VCPKG_LINE_INFO, setenv(varname.c_str(), v->c_str(), 1) == 0);
- }
- else
- {
- check_exit(VCPKG_LINE_INFO, unsetenv(varname.c_str()) == 0);
- }
-#endif // defined(_WIN32)
- }
-
struct environment_variable_resetter
{
explicit environment_variable_resetter(ZStringView varname_)