mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-29 08:19:38 +08:00
Add System::set_environmental_variable()
This commit is contained in:
parent
c11b2c790e
commit
0d47ce63ed
@ -93,4 +93,6 @@ namespace vcpkg::System
|
||||
};
|
||||
|
||||
std::wstring get_environmental_variable(const wchar_t* varname) noexcept;
|
||||
|
||||
void set_environmental_variable(const wchar_t* varname, const wchar_t* varvalue) noexcept;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace vcpkg::Environment
|
||||
System::get_environmental_variable(L"PATH"),
|
||||
default_git_installation_dir.native(),
|
||||
default_git_installation_dir_x86.native());
|
||||
_wputenv_s(L"PATH", path_buf.c_str());
|
||||
System::set_environmental_variable(L"PATH", path_buf.c_str());
|
||||
|
||||
static constexpr std::array<int, 3> git_version = {2,0,0};
|
||||
static const std::wstring version_check_cmd = L"git --version 2>&1";
|
||||
@ -76,7 +76,7 @@ namespace vcpkg::Environment
|
||||
System::get_environmental_variable(L"PATH"),
|
||||
default_cmake_installation_dir.native(),
|
||||
default_cmake_installation_dir_x86.native());
|
||||
_wputenv_s(L"PATH", path_buf.c_str());
|
||||
System::set_environmental_variable(L"PATH", path_buf.c_str());
|
||||
|
||||
static constexpr std::array<int, 3> cmake_version = {3,7,2};
|
||||
static const std::wstring version_check_cmd = L"cmake --version 2>&1";
|
||||
@ -88,7 +88,7 @@ namespace vcpkg::Environment
|
||||
{
|
||||
const fs::path downloaded_nuget = paths.downloads / "nuget-3.5.0";
|
||||
const std::wstring path_buf = Strings::wformat(L"%s;%s", downloaded_nuget.native(), System::get_environmental_variable(L"PATH"));
|
||||
_wputenv_s(L"PATH", path_buf.c_str());
|
||||
System::set_environmental_variable(L"PATH", path_buf.c_str());
|
||||
|
||||
static constexpr std::array<int, 3> nuget_version = {3,3,0};
|
||||
static const std::wstring version_check_cmd = L"nuget 2>&1";
|
||||
|
@ -29,7 +29,7 @@ namespace vcpkg::System
|
||||
auto pipe = _wpopen(actual_cmd_line.c_str(), L"r");
|
||||
if (pipe == nullptr)
|
||||
{
|
||||
return {1, output};
|
||||
return { 1, output };
|
||||
}
|
||||
while (fgets(buf, 1024, pipe))
|
||||
{
|
||||
@ -37,10 +37,10 @@ namespace vcpkg::System
|
||||
}
|
||||
if (!feof(pipe))
|
||||
{
|
||||
return {1, output};
|
||||
return { 1, output };
|
||||
}
|
||||
auto ec = _pclose(pipe);
|
||||
return {ec, output};
|
||||
return { ec, output };
|
||||
}
|
||||
|
||||
void print(const char* message)
|
||||
@ -86,6 +86,11 @@ namespace vcpkg::System
|
||||
return ret;
|
||||
}
|
||||
|
||||
void set_environmental_variable(const wchar_t* varname, const wchar_t* varvalue) noexcept
|
||||
{
|
||||
_wputenv_s(varname, varvalue);
|
||||
}
|
||||
|
||||
void Stopwatch2::start()
|
||||
{
|
||||
static_assert(sizeof(start_time) == sizeof(LARGE_INTEGER), "");
|
||||
|
Loading…
Reference in New Issue
Block a user