mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 17:12:47 +08:00
[vcpkg] Rewriting CmdLineBuilder (2/n) (#15627)
* [vcpkg] Rewriting CmdLineBuilder (2/n) I would like, and I think the team would like generally, to switch to using stuff like `posix_spawn`, as opposed to the existing use of `system` and `popen`. This requires a pretty large change to how we use CmdLineBuilder. The first change we have to make is that the execute functions _cannot_ take a StringView anymore. This PR makes that change.
This commit is contained in:
parent
fb21b70846
commit
1515d080fe
1
test.cmake
Normal file
1
test.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
execute_process(COMMAND "bash" "-c" "echo \$TEST_ENV_VAR")
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace vcpkg
|
namespace vcpkg
|
||||||
{
|
{
|
||||||
template<class Key, class Value>
|
template<class Key, class Value, class Less = std::less<Key>>
|
||||||
struct Cache
|
struct Cache
|
||||||
{
|
{
|
||||||
template<class F>
|
template<class F>
|
||||||
@ -16,6 +16,6 @@ namespace vcpkg
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable std::map<Key, Value> m_cache;
|
mutable std::map<Key, Value, Less> m_cache;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,6 @@ namespace vcpkg::System
|
|||||||
std::string s;
|
std::string s;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string make_basic_cmake_cmd(const fs::path& cmake_tool_path,
|
|
||||||
const fs::path& cmake_script,
|
|
||||||
const std::vector<CMakeVariable>& pass_variables);
|
|
||||||
|
|
||||||
struct CmdLineBuilder
|
struct CmdLineBuilder
|
||||||
{
|
{
|
||||||
CmdLineBuilder() = default;
|
CmdLineBuilder() = default;
|
||||||
@ -46,15 +42,27 @@ namespace vcpkg::System
|
|||||||
CmdLineBuilder&& raw_arg(StringView s) && { return std::move(raw_arg(s)); }
|
CmdLineBuilder&& raw_arg(StringView s) && { return std::move(raw_arg(s)); }
|
||||||
|
|
||||||
std::string&& extract() && { return std::move(buf); }
|
std::string&& extract() && { return std::move(buf); }
|
||||||
operator StringView() noexcept { return buf; }
|
|
||||||
StringView command_line() const { return buf; }
|
StringView command_line() const { return buf; }
|
||||||
|
|
||||||
void clear() { buf.clear(); }
|
void clear() { buf.clear(); }
|
||||||
|
bool empty() const { return buf.empty(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string buf;
|
std::string buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CmdLineBuilderMapLess
|
||||||
|
{
|
||||||
|
bool operator()(const CmdLineBuilder& lhs, const CmdLineBuilder& rhs) const
|
||||||
|
{
|
||||||
|
return lhs.command_line() < rhs.command_line();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
CmdLineBuilder make_basic_cmake_cmd(const fs::path& cmake_tool_path,
|
||||||
|
const fs::path& cmake_script,
|
||||||
|
const std::vector<CMakeVariable>& pass_variables);
|
||||||
|
|
||||||
fs::path get_exe_path_of_current_process();
|
fs::path get_exe_path_of_current_process();
|
||||||
|
|
||||||
struct ExitCodeAndOutput
|
struct ExitCodeAndOutput
|
||||||
@ -79,48 +87,48 @@ namespace vcpkg::System
|
|||||||
const fs::path& working_directory;
|
const fs::path& working_directory;
|
||||||
};
|
};
|
||||||
|
|
||||||
int cmd_execute(StringView cmd_line, InWorkingDirectory wd, const Environment& env = {});
|
int cmd_execute(const CmdLineBuilder& cmd_line, InWorkingDirectory wd, const Environment& env = {});
|
||||||
inline int cmd_execute(StringView cmd_line, const Environment& env = {})
|
inline int cmd_execute(const CmdLineBuilder& cmd_line, const Environment& env = {})
|
||||||
{
|
{
|
||||||
return cmd_execute(cmd_line, InWorkingDirectory{fs::path()}, env);
|
return cmd_execute(cmd_line, InWorkingDirectory{fs::path()}, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_execute_clean(StringView cmd_line, InWorkingDirectory wd);
|
int cmd_execute_clean(const CmdLineBuilder& cmd_line, InWorkingDirectory wd);
|
||||||
inline int cmd_execute_clean(StringView cmd_line)
|
inline int cmd_execute_clean(const CmdLineBuilder& cmd_line)
|
||||||
{
|
{
|
||||||
return cmd_execute_clean(cmd_line, InWorkingDirectory{fs::path()});
|
return cmd_execute_clean(cmd_line, InWorkingDirectory{fs::path()});
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
Environment cmd_execute_modify_env(StringView cmd_line, const Environment& env = {});
|
Environment cmd_execute_modify_env(const CmdLineBuilder& cmd_line, const Environment& env = {});
|
||||||
|
|
||||||
void cmd_execute_background(const StringView cmd_line);
|
void cmd_execute_background(const CmdLineBuilder& cmd_line);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ExitCodeAndOutput cmd_execute_and_capture_output(StringView cmd_line,
|
ExitCodeAndOutput cmd_execute_and_capture_output(const CmdLineBuilder& cmd_line,
|
||||||
InWorkingDirectory wd,
|
InWorkingDirectory wd,
|
||||||
const Environment& env = {});
|
const Environment& env = {});
|
||||||
inline ExitCodeAndOutput cmd_execute_and_capture_output(StringView cmd_line, const Environment& env = {})
|
inline ExitCodeAndOutput cmd_execute_and_capture_output(const CmdLineBuilder& cmd_line, const Environment& env = {})
|
||||||
{
|
{
|
||||||
return cmd_execute_and_capture_output(cmd_line, InWorkingDirectory{fs::path()}, env);
|
return cmd_execute_and_capture_output(cmd_line, InWorkingDirectory{fs::path()}, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_execute_and_stream_lines(StringView cmd_line,
|
int cmd_execute_and_stream_lines(const CmdLineBuilder& cmd_line,
|
||||||
InWorkingDirectory wd,
|
InWorkingDirectory wd,
|
||||||
std::function<void(StringView)> per_line_cb,
|
std::function<void(StringView)> per_line_cb,
|
||||||
const Environment& env = {});
|
const Environment& env = {});
|
||||||
inline int cmd_execute_and_stream_lines(StringView cmd_line,
|
inline int cmd_execute_and_stream_lines(const CmdLineBuilder& cmd_line,
|
||||||
std::function<void(StringView)> per_line_cb,
|
std::function<void(StringView)> per_line_cb,
|
||||||
const Environment& env = {})
|
const Environment& env = {})
|
||||||
{
|
{
|
||||||
return cmd_execute_and_stream_lines(cmd_line, InWorkingDirectory{fs::path()}, std::move(per_line_cb), env);
|
return cmd_execute_and_stream_lines(cmd_line, InWorkingDirectory{fs::path()}, std::move(per_line_cb), env);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_execute_and_stream_data(StringView cmd_line,
|
int cmd_execute_and_stream_data(const CmdLineBuilder& cmd_line,
|
||||||
InWorkingDirectory wd,
|
InWorkingDirectory wd,
|
||||||
std::function<void(StringView)> data_cb,
|
std::function<void(StringView)> data_cb,
|
||||||
const Environment& env = {});
|
const Environment& env = {});
|
||||||
inline int cmd_execute_and_stream_data(StringView cmd_line,
|
inline int cmd_execute_and_stream_data(const CmdLineBuilder& cmd_line,
|
||||||
std::function<void(StringView)> data_cb,
|
std::function<void(StringView)> data_cb,
|
||||||
const Environment& env = {})
|
const Environment& env = {})
|
||||||
{
|
{
|
||||||
|
@ -232,7 +232,7 @@ namespace vcpkg::Build
|
|||||||
const VcpkgPaths& m_paths;
|
const VcpkgPaths& m_paths;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
|
System::CmdLineBuilder make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
|
||||||
|
|
||||||
struct ExtendedBuildResult
|
struct ExtendedBuildResult
|
||||||
{
|
{
|
||||||
@ -369,7 +369,7 @@ namespace vcpkg::Build
|
|||||||
struct EnvMapEntry
|
struct EnvMapEntry
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, std::string> env_map;
|
std::unordered_map<std::string, std::string> env_map;
|
||||||
Cache<std::string, System::Environment> cmd_cache;
|
Cache<System::CmdLineBuilder, System::Environment, System::CmdLineBuilderMapLess> cmd_cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
Cache<std::vector<std::string>, EnvMapEntry> envs;
|
Cache<std::vector<std::string>, EnvMapEntry> envs;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace vcpkg
|
namespace vcpkg
|
||||||
{
|
{
|
||||||
std::string make_cmake_cmd(const VcpkgPaths& paths,
|
System::CmdLineBuilder make_cmake_cmd(const VcpkgPaths& paths,
|
||||||
const fs::path& cmake_script,
|
const fs::path& cmake_script,
|
||||||
std::vector<System::CMakeVariable>&& pass_variables);
|
std::vector<System::CMakeVariable>&& pass_variables);
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,21 @@ namespace vcpkg::Archives
|
|||||||
const std::string nugetid = match[1];
|
const std::string nugetid = match[1];
|
||||||
const std::string version = match[2];
|
const std::string version = match[2];
|
||||||
|
|
||||||
const auto code_and_output = System::cmd_execute_and_capture_output(Strings::format(
|
const auto code_and_output = System::cmd_execute_and_capture_output(System::CmdLineBuilder{nuget_exe}
|
||||||
R"("%s" install %s -Version %s -OutputDirectory "%s" -Source "%s" -nocache -DirectDownload -NonInteractive -ForceEnglishOutput -PackageSaveMode nuspec)",
|
.string_arg("install")
|
||||||
fs::u8string(nuget_exe),
|
.string_arg(nugetid)
|
||||||
nugetid,
|
.string_arg("-Version")
|
||||||
version,
|
.string_arg(version)
|
||||||
fs::u8string(to_path_partial),
|
.string_arg("-OutputDirectory")
|
||||||
fs::u8string(paths.downloads)));
|
.path_arg(to_path_partial)
|
||||||
|
.string_arg("-Source")
|
||||||
|
.path_arg(paths.downloads)
|
||||||
|
.string_arg("-nocache")
|
||||||
|
.string_arg("-DirectDownload")
|
||||||
|
.string_arg("-NonInteractive")
|
||||||
|
.string_arg("-ForceEnglishOutput")
|
||||||
|
.string_arg("-PackageSaveMode")
|
||||||
|
.string_arg("nuspec"));
|
||||||
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
code_and_output.exit_code == 0,
|
code_and_output.exit_code == 0,
|
||||||
@ -65,11 +73,12 @@ namespace vcpkg::Archives
|
|||||||
Checks::check_exit(VCPKG_LINE_INFO, !recursion_limiter_sevenzip);
|
Checks::check_exit(VCPKG_LINE_INFO, !recursion_limiter_sevenzip);
|
||||||
recursion_limiter_sevenzip = true;
|
recursion_limiter_sevenzip = true;
|
||||||
const auto seven_zip = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
const auto seven_zip = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
||||||
const auto code_and_output =
|
const auto code_and_output = System::cmd_execute_and_capture_output(
|
||||||
System::cmd_execute_and_capture_output(Strings::format(R"("%s" x "%s" -o"%s" -y)",
|
System::CmdLineBuilder{seven_zip}
|
||||||
fs::u8string(seven_zip),
|
.string_arg("x")
|
||||||
fs::u8string(archive),
|
.path_arg(archive)
|
||||||
fs::u8string(to_path_partial)));
|
.string_arg(Strings::format("-o%s", fs::u8string(to_path_partial)))
|
||||||
|
.string_arg("-y"));
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
code_and_output.exit_code == 0,
|
code_and_output.exit_code == 0,
|
||||||
"7zip failed while extracting '%s' with message:\n%s",
|
"7zip failed while extracting '%s' with message:\n%s",
|
||||||
|
@ -184,18 +184,17 @@ namespace vcpkg
|
|||||||
}
|
}
|
||||||
System::CMakeVariable::CMakeVariable(std::string var) : s(std::move(var)) { }
|
System::CMakeVariable::CMakeVariable(std::string var) : s(std::move(var)) { }
|
||||||
|
|
||||||
std::string System::make_basic_cmake_cmd(const fs::path& cmake_tool_path,
|
System::CmdLineBuilder System::make_basic_cmake_cmd(const fs::path& cmake_tool_path,
|
||||||
const fs::path& cmake_script,
|
const fs::path& cmake_script,
|
||||||
const std::vector<CMakeVariable>& pass_variables)
|
const std::vector<CMakeVariable>& pass_variables)
|
||||||
{
|
{
|
||||||
System::CmdLineBuilder cmd;
|
System::CmdLineBuilder cmd{cmake_tool_path};
|
||||||
cmd.path_arg(cmake_tool_path);
|
|
||||||
for (auto&& var : pass_variables)
|
for (auto&& var : pass_variables)
|
||||||
{
|
{
|
||||||
cmd.string_arg(var.s);
|
cmd.string_arg(var.s);
|
||||||
}
|
}
|
||||||
cmd.string_arg("-P").path_arg(cmake_script);
|
cmd.string_arg("-P").path_arg(cmake_script);
|
||||||
return std::move(cmd).extract();
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
System::CmdLineBuilder& System::CmdLineBuilder::string_arg(StringView s) &
|
System::CmdLineBuilder& System::CmdLineBuilder::string_arg(StringView s) &
|
||||||
@ -384,7 +383,7 @@ namespace vcpkg
|
|||||||
return clean_env;
|
return clean_env;
|
||||||
}
|
}
|
||||||
|
|
||||||
int System::cmd_execute_clean(StringView cmd_line, InWorkingDirectory wd)
|
int System::cmd_execute_clean(const CmdLineBuilder& cmd_line, InWorkingDirectory wd)
|
||||||
{
|
{
|
||||||
return cmd_execute(cmd_line, wd, get_clean_environment());
|
return cmd_execute(cmd_line, wd, get_clean_environment());
|
||||||
}
|
}
|
||||||
@ -565,12 +564,12 @@ namespace vcpkg
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
void System::cmd_execute_background(StringView cmd_line)
|
void System::cmd_execute_background(const CmdLineBuilder& cmd_line)
|
||||||
{
|
{
|
||||||
auto timer = Chrono::ElapsedTimer::create_started();
|
auto timer = Chrono::ElapsedTimer::create_started();
|
||||||
|
|
||||||
auto process_info =
|
auto process_info =
|
||||||
windows_create_windowless_process(cmd_line,
|
windows_create_windowless_process(cmd_line.command_line(),
|
||||||
InWorkingDirectory{fs::path()},
|
InWorkingDirectory{fs::path()},
|
||||||
{},
|
{},
|
||||||
CREATE_NEW_CONSOLE | CREATE_NO_WINDOW | CREATE_BREAKAWAY_FROM_JOB);
|
CREATE_NEW_CONSOLE | CREATE_NO_WINDOW | CREATE_BREAKAWAY_FROM_JOB);
|
||||||
@ -582,48 +581,55 @@ namespace vcpkg
|
|||||||
Debug::print("cmd_execute_background() took ", static_cast<int>(timer.microseconds()), " us\n");
|
Debug::print("cmd_execute_background() took ", static_cast<int>(timer.microseconds()), " us\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment System::cmd_execute_modify_env(StringView cmd_line, const Environment& env)
|
Environment System::cmd_execute_modify_env(const CmdLineBuilder& cmd_line, const Environment& env)
|
||||||
{
|
{
|
||||||
static StringLiteral magic_string = "cdARN4xjKueKScMy9C6H";
|
static StringLiteral magic_string = "cdARN4xjKueKScMy9C6H";
|
||||||
|
|
||||||
auto actual_cmd_line = Strings::concat(cmd_line, " & echo ", magic_string, "& set");
|
auto actual_cmd_line = cmd_line;
|
||||||
|
actual_cmd_line.raw_arg(Strings::concat(" & echo ", magic_string, " & set"));
|
||||||
|
|
||||||
auto rc_output = cmd_execute_and_capture_output(actual_cmd_line, env);
|
auto rc_output = cmd_execute_and_capture_output(actual_cmd_line, env);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, rc_output.exit_code == 0);
|
Checks::check_exit(VCPKG_LINE_INFO, rc_output.exit_code == 0);
|
||||||
auto it = Strings::search(rc_output.output, Strings::concat(magic_string, "\r\n"));
|
Debug::print("command line: ", actual_cmd_line.command_line(), "\n");
|
||||||
const auto e = static_cast<const char*>(rc_output.output.data()) + rc_output.output.size();
|
Debug::print(rc_output.output, "\n");
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, it != e);
|
|
||||||
it += magic_string.size() + 2;
|
auto it = Strings::search(rc_output.output, magic_string);
|
||||||
|
const char* const last = rc_output.output.data() + rc_output.output.size();
|
||||||
|
|
||||||
|
Checks::check_exit(VCPKG_LINE_INFO, it != last);
|
||||||
|
// find the first non-whitespace character after the magic string
|
||||||
|
it = std::find_if_not(it + magic_string.size(), last, ::isspace);
|
||||||
|
Checks::check_exit(VCPKG_LINE_INFO, it != last);
|
||||||
|
|
||||||
std::wstring out_env;
|
std::wstring out_env;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
auto eq = std::find(it, e, '=');
|
auto equal_it = std::find(it, last, '=');
|
||||||
if (eq == e) break;
|
if (equal_it == last) break;
|
||||||
StringView varname(it, eq);
|
StringView variable_name(it, equal_it);
|
||||||
auto nl = std::find(eq + 1, e, '\r');
|
auto newline_it = std::find(equal_it + 1, last, '\r');
|
||||||
if (nl == e) break;
|
if (newline_it == last) break;
|
||||||
StringView value(eq + 1, nl);
|
StringView value(equal_it + 1, newline_it);
|
||||||
|
|
||||||
out_env.append(Strings::to_utf16(Strings::concat(varname, '=', value)));
|
out_env.append(Strings::to_utf16(Strings::concat(variable_name, '=', value)));
|
||||||
out_env.push_back(L'\0');
|
out_env.push_back(L'\0');
|
||||||
|
|
||||||
it = nl + 1;
|
it = newline_it + 1;
|
||||||
if (it != e && *it == '\n') ++it;
|
if (it != last && *it == '\n') ++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {std::move(out_env)};
|
return {std::move(out_env)};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int System::cmd_execute(StringView cmd_line, System::InWorkingDirectory wd, const Environment& env)
|
int System::cmd_execute(const CmdLineBuilder& cmd_line, System::InWorkingDirectory wd, const Environment& env)
|
||||||
{
|
{
|
||||||
auto timer = Chrono::ElapsedTimer::create_started();
|
auto timer = Chrono::ElapsedTimer::create_started();
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
using vcpkg::g_ctrl_c_state;
|
using vcpkg::g_ctrl_c_state;
|
||||||
g_ctrl_c_state.transition_to_spawn_process();
|
g_ctrl_c_state.transition_to_spawn_process();
|
||||||
auto proc_info = windows_create_windowless_process(cmd_line, wd, env, 0);
|
auto proc_info = windows_create_windowless_process(cmd_line.command_line(), wd, env, 0);
|
||||||
auto long_exit_code = [&]() -> unsigned long {
|
auto long_exit_code = [&]() -> unsigned long {
|
||||||
if (auto p = proc_info.get())
|
if (auto p = proc_info.get())
|
||||||
return p->wait();
|
return p->wait();
|
||||||
@ -641,12 +647,15 @@ namespace vcpkg
|
|||||||
std::string real_command_line;
|
std::string real_command_line;
|
||||||
if (wd.working_directory.empty())
|
if (wd.working_directory.empty())
|
||||||
{
|
{
|
||||||
real_command_line.assign(cmd_line.begin(), cmd_line.end());
|
real_command_line = cmd_line.command_line().to_string();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
real_command_line =
|
real_command_line = System::CmdLineBuilder("cd")
|
||||||
System::CmdLineBuilder("cd").path_arg(wd.working_directory).raw_arg("&&").raw_arg(cmd_line).extract();
|
.path_arg(wd.working_directory)
|
||||||
|
.raw_arg("&&")
|
||||||
|
.raw_arg(cmd_line.command_line())
|
||||||
|
.extract();
|
||||||
}
|
}
|
||||||
Debug::print("system(", real_command_line, ")\n");
|
Debug::print("system(", real_command_line, ")\n");
|
||||||
fflush(nullptr);
|
fflush(nullptr);
|
||||||
@ -658,7 +667,7 @@ namespace vcpkg
|
|||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int System::cmd_execute_and_stream_lines(StringView cmd_line,
|
int System::cmd_execute_and_stream_lines(const CmdLineBuilder& cmd_line,
|
||||||
System::InWorkingDirectory wd,
|
System::InWorkingDirectory wd,
|
||||||
std::function<void(StringView)> per_line_cb,
|
std::function<void(StringView)> per_line_cb,
|
||||||
const Environment& env)
|
const Environment& env)
|
||||||
@ -687,7 +696,7 @@ namespace vcpkg
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int System::cmd_execute_and_stream_data(StringView cmd_line,
|
int System::cmd_execute_and_stream_data(const CmdLineBuilder& cmd_line,
|
||||||
System::InWorkingDirectory wd,
|
System::InWorkingDirectory wd,
|
||||||
std::function<void(StringView)> data_cb,
|
std::function<void(StringView)> data_cb,
|
||||||
const Environment& env)
|
const Environment& env)
|
||||||
@ -698,7 +707,7 @@ namespace vcpkg
|
|||||||
using vcpkg::g_ctrl_c_state;
|
using vcpkg::g_ctrl_c_state;
|
||||||
|
|
||||||
g_ctrl_c_state.transition_to_spawn_process();
|
g_ctrl_c_state.transition_to_spawn_process();
|
||||||
auto maybe_proc_info = windows_create_process_redirect(cmd_line, wd, env, 0);
|
auto maybe_proc_info = windows_create_process_redirect(cmd_line.command_line(), wd, env, 0);
|
||||||
auto exit_code = [&]() -> unsigned long {
|
auto exit_code = [&]() -> unsigned long {
|
||||||
if (auto p = maybe_proc_info.get())
|
if (auto p = maybe_proc_info.get())
|
||||||
return p->wait_and_stream_output(data_cb);
|
return p->wait_and_stream_output(data_cb);
|
||||||
@ -711,14 +720,14 @@ namespace vcpkg
|
|||||||
std::string actual_cmd_line;
|
std::string actual_cmd_line;
|
||||||
if (wd.working_directory.empty())
|
if (wd.working_directory.empty())
|
||||||
{
|
{
|
||||||
actual_cmd_line = Strings::format(R"(%s 2>&1)", cmd_line);
|
actual_cmd_line = Strings::format(R"(%s 2>&1)", cmd_line.command_line());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
actual_cmd_line = System::CmdLineBuilder("cd")
|
actual_cmd_line = System::CmdLineBuilder("cd")
|
||||||
.path_arg(wd.working_directory)
|
.path_arg(wd.working_directory)
|
||||||
.raw_arg("&&")
|
.raw_arg("&&")
|
||||||
.raw_arg(cmd_line)
|
.raw_arg(cmd_line.command_line())
|
||||||
.raw_arg("2>&1")
|
.raw_arg("2>&1")
|
||||||
.extract();
|
.extract();
|
||||||
}
|
}
|
||||||
@ -754,7 +763,7 @@ namespace vcpkg
|
|||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExitCodeAndOutput System::cmd_execute_and_capture_output(StringView cmd_line,
|
ExitCodeAndOutput System::cmd_execute_and_capture_output(const CmdLineBuilder& cmd_line,
|
||||||
System::InWorkingDirectory wd,
|
System::InWorkingDirectory wd,
|
||||||
const Environment& env)
|
const Environment& env)
|
||||||
{
|
{
|
||||||
|
@ -420,7 +420,7 @@ namespace
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int run_nuget_commandline(StringView cmdline)
|
int run_nuget_commandline(const System::CmdLineBuilder& cmdline)
|
||||||
{
|
{
|
||||||
if (m_interactive)
|
if (m_interactive)
|
||||||
{
|
{
|
||||||
@ -450,7 +450,9 @@ namespace
|
|||||||
}
|
}
|
||||||
else if (res.output.find("for example \"-ApiKey AzureDevOps\"") != std::string::npos)
|
else if (res.output.find("for example \"-ApiKey AzureDevOps\"") != std::string::npos)
|
||||||
{
|
{
|
||||||
auto res2 = System::cmd_execute_and_capture_output(Strings::concat(cmdline, " -ApiKey AzureDevOps"));
|
auto real_cmdline = cmdline;
|
||||||
|
real_cmdline.string_arg("-ApiKey").string_arg("AzureDevOps");
|
||||||
|
auto res2 = System::cmd_execute_and_capture_output(real_cmdline);
|
||||||
if (Debug::g_debugging)
|
if (Debug::g_debugging)
|
||||||
{
|
{
|
||||||
System::print2(res2.output);
|
System::print2(res2.output);
|
||||||
@ -514,7 +516,7 @@ namespace
|
|||||||
};
|
};
|
||||||
|
|
||||||
const auto& nuget_exe = paths.get_tool_exe("nuget");
|
const auto& nuget_exe = paths.get_tool_exe("nuget");
|
||||||
std::vector<std::string> cmdlines;
|
std::vector<System::CmdLineBuilder> cmdlines;
|
||||||
|
|
||||||
if (!m_read_sources.empty())
|
if (!m_read_sources.empty())
|
||||||
{
|
{
|
||||||
@ -544,7 +546,7 @@ namespace
|
|||||||
cmdline.string_arg("-NonInteractive");
|
cmdline.string_arg("-NonInteractive");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdlines.push_back(std::move(cmdline).extract());
|
cmdlines.push_back(std::move(cmdline));
|
||||||
}
|
}
|
||||||
for (auto&& cfg : m_read_configs)
|
for (auto&& cfg : m_read_configs)
|
||||||
{
|
{
|
||||||
@ -574,7 +576,7 @@ namespace
|
|||||||
cmdline.string_arg("-NonInteractive");
|
cmdline.string_arg("-NonInteractive");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdlines.push_back(std::move(cmdline).extract());
|
cmdlines.push_back(std::move(cmdline));
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t current_restored = m_restored.size();
|
const size_t current_restored = m_restored.size();
|
||||||
|
@ -328,7 +328,7 @@ namespace vcpkg::Build
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
const System::Environment& EnvCache::get_action_env(const VcpkgPaths& paths, const AbiInfo& abi_info)
|
const System::Environment& EnvCache::get_action_env(const VcpkgPaths& paths, const AbiInfo& abi_info)
|
||||||
{
|
{
|
||||||
std::string build_env_cmd =
|
auto build_env_cmd =
|
||||||
make_build_env_cmd(*abi_info.pre_build_info, abi_info.toolset.value_or_exit(VCPKG_LINE_INFO));
|
make_build_env_cmd(*abi_info.pre_build_info, abi_info.toolset.value_or_exit(VCPKG_LINE_INFO));
|
||||||
|
|
||||||
const auto& base_env = envs.get_lazy(abi_info.pre_build_info->passthrough_env_vars, [&]() -> EnvMapEntry {
|
const auto& base_env = envs.get_lazy(abi_info.pre_build_info->passthrough_env_vars, [&]() -> EnvMapEntry {
|
||||||
@ -439,9 +439,9 @@ namespace vcpkg::Build
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset)
|
System::CmdLineBuilder make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset)
|
||||||
{
|
{
|
||||||
if (!pre_build_info.using_vcvars()) return "";
|
if (!pre_build_info.using_vcvars()) return {};
|
||||||
|
|
||||||
const char* tonull = " >nul";
|
const char* tonull = " >nul";
|
||||||
if (Debug::g_debugging)
|
if (Debug::g_debugging)
|
||||||
@ -452,12 +452,13 @@ namespace vcpkg::Build
|
|||||||
const auto arch = to_vcvarsall_toolchain(pre_build_info.target_architecture, toolset);
|
const auto arch = to_vcvarsall_toolchain(pre_build_info.target_architecture, toolset);
|
||||||
const auto target = to_vcvarsall_target(pre_build_info.cmake_system_name);
|
const auto target = to_vcvarsall_target(pre_build_info.cmake_system_name);
|
||||||
|
|
||||||
return Strings::format(R"(cmd /c ""%s" %s %s %s %s 2>&1 <NUL")",
|
return System::CmdLineBuilder{"cmd"}.string_arg("/c").raw_arg(
|
||||||
|
Strings::format(R"("%s" %s %s %s %s 2>&1 <NUL)",
|
||||||
fs::u8string(toolset.vcvarsall),
|
fs::u8string(toolset.vcvarsall),
|
||||||
Strings::join(" ", toolset.vcvarsall_options),
|
Strings::join(" ", toolset.vcvarsall_options),
|
||||||
arch,
|
arch,
|
||||||
target,
|
target,
|
||||||
tonull);
|
tonull));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<BinaryControlFile> create_binary_control_file(
|
static std::unique_ptr<BinaryControlFile> create_binary_control_file(
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace vcpkg
|
namespace vcpkg
|
||||||
{
|
{
|
||||||
std::string make_cmake_cmd(const VcpkgPaths& paths,
|
System::CmdLineBuilder make_cmake_cmd(const VcpkgPaths& paths,
|
||||||
const fs::path& cmake_script,
|
const fs::path& cmake_script,
|
||||||
std::vector<System::CMakeVariable>&& pass_variables)
|
std::vector<System::CMakeVariable>&& pass_variables)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ namespace vcpkg::Commands::Contact
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
System::cmd_execute("start https://aka.ms/NPS_vcpkg");
|
System::cmd_execute(System::CmdLineBuilder("start").string_arg("https://aka.ms/NPS_vcpkg"));
|
||||||
System::print2("Default browser launched to https://aka.ms/NPS_vcpkg; thank you for your feedback!\n");
|
System::print2("Default browser launched to https://aka.ms/NPS_vcpkg; thank you for your feedback!\n");
|
||||||
#else
|
#else
|
||||||
System::print2("Please navigate to https://aka.ms/NPS_vcpkg in your preferred browser. Thank you for your "
|
System::print2("Please navigate to https://aka.ms/NPS_vcpkg in your preferred browser. Thank you for your "
|
||||||
|
@ -51,7 +51,7 @@ namespace vcpkg::Commands::Create
|
|||||||
cmake_args.emplace_back("FILENAME", zip_file_name);
|
cmake_args.emplace_back("FILENAME", zip_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string cmd_launch_cmake = make_cmake_cmd(paths, paths.ports_cmake, std::move(cmake_args));
|
auto cmd_launch_cmake = make_cmake_cmd(paths, paths.ports_cmake, std::move(cmake_args));
|
||||||
return System::cmd_execute_clean(cmd_launch_cmake);
|
return System::cmd_execute_clean(cmd_launch_cmake);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,13 +219,14 @@ namespace vcpkg::Commands::Edit
|
|||||||
candidate_paths.push_back(fs::path{"/usr/share/code/bin/code"});
|
candidate_paths.push_back(fs::path{"/usr/share/code/bin/code"});
|
||||||
candidate_paths.push_back(fs::path{"/usr/bin/code"});
|
candidate_paths.push_back(fs::path{"/usr/bin/code"});
|
||||||
|
|
||||||
if (System::cmd_execute("command -v xdg-mime") == 0)
|
if (System::cmd_execute(System::CmdLineBuilder("command").string_arg("-v").string_arg("xdg-mime")) == 0)
|
||||||
{
|
{
|
||||||
auto mime_qry = Strings::format(R"(xdg-mime query default text/plain)");
|
auto mime_qry =
|
||||||
|
System::CmdLineBuilder("xdg-mime").string_arg("query").string_arg("default").string_arg("text/plain");
|
||||||
auto execute_result = System::cmd_execute_and_capture_output(mime_qry);
|
auto execute_result = System::cmd_execute_and_capture_output(mime_qry);
|
||||||
if (execute_result.exit_code == 0 && !execute_result.output.empty())
|
if (execute_result.exit_code == 0 && !execute_result.output.empty())
|
||||||
{
|
{
|
||||||
mime_qry = Strings::format(R"(command -v %s)",
|
mime_qry = System::CmdLineBuilder("command").string_arg("-v").string_arg(
|
||||||
execute_result.output.substr(0, execute_result.output.find('.')));
|
execute_result.output.substr(0, execute_result.output.find('.')));
|
||||||
execute_result = System::cmd_execute_and_capture_output(mime_qry);
|
execute_result = System::cmd_execute_and_capture_output(mime_qry);
|
||||||
if (execute_result.exit_code == 0 && !execute_result.output.empty())
|
if (execute_result.exit_code == 0 && !execute_result.output.empty())
|
||||||
@ -254,7 +255,7 @@ namespace vcpkg::Commands::Edit
|
|||||||
const fs::path env_editor = *it;
|
const fs::path env_editor = *it;
|
||||||
const std::vector<std::string> arguments = create_editor_arguments(paths, options, ports);
|
const std::vector<std::string> arguments = create_editor_arguments(paths, options, ports);
|
||||||
const auto args_as_string = Strings::join(" ", arguments);
|
const auto args_as_string = Strings::join(" ", arguments);
|
||||||
const auto cmd_line = Strings::format(R"("%s" %s -n)", fs::u8string(env_editor), args_as_string);
|
auto cmd_line = System::CmdLineBuilder(env_editor).raw_arg(args_as_string).string_arg("-n");
|
||||||
|
|
||||||
auto editor_exe = fs::u8string(env_editor.filename());
|
auto editor_exe = fs::u8string(env_editor.filename());
|
||||||
|
|
||||||
@ -262,7 +263,8 @@ namespace vcpkg::Commands::Edit
|
|||||||
if (editor_exe == "Code.exe" || editor_exe == "Code - Insiders.exe")
|
if (editor_exe == "Code.exe" || editor_exe == "Code - Insiders.exe")
|
||||||
{
|
{
|
||||||
// note that we are invoking cmd silently but Code.exe is relaunched from there
|
// note that we are invoking cmd silently but Code.exe is relaunched from there
|
||||||
System::cmd_execute_background(Strings::concat("cmd /c \"", cmd_line, " <NUL\""));
|
System::cmd_execute_background(
|
||||||
|
System::CmdLineBuilder("cmd").string_arg("/c").string_arg(cmd_line.command_line()).raw_arg("<NUL"));
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -98,7 +98,11 @@ namespace vcpkg::Commands::Env
|
|||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
std::string cmd = args.command_arguments.empty() ? "cmd" : ("cmd /c " + args.command_arguments.at(0));
|
System::CmdLineBuilder cmd("cmd");
|
||||||
|
if (!args.command_arguments.empty())
|
||||||
|
{
|
||||||
|
cmd.string_arg("/c").raw_arg(args.command_arguments.at(0));
|
||||||
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
System::enter_interactive_subprocess();
|
System::enter_interactive_subprocess();
|
||||||
#endif
|
#endif
|
||||||
|
@ -379,10 +379,11 @@ CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=%s"
|
|||||||
nuspec_file_path, create_nuspec_file_contents(paths.root, nuget_id, nupkg_version), VCPKG_LINE_INFO);
|
nuspec_file_path, create_nuspec_file_contents(paths.root, nuget_id, nupkg_version), VCPKG_LINE_INFO);
|
||||||
|
|
||||||
// Using all forward slashes for the command line
|
// Using all forward slashes for the command line
|
||||||
const std::string cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s")",
|
auto cmd_line = System::CmdLineBuilder(nuget_exe)
|
||||||
fs::u8string(nuget_exe),
|
.string_arg("pack")
|
||||||
fs::u8string(buildsystems_dir),
|
.string_arg("-OutputDirectory")
|
||||||
fs::u8string(nuspec_file_path));
|
.path_arg(buildsystems_dir)
|
||||||
|
.path_arg(nuspec_file_path);
|
||||||
|
|
||||||
const int exit_code =
|
const int exit_code =
|
||||||
System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code;
|
System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code;
|
||||||
@ -414,9 +415,12 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
|
|||||||
const fs::path script_path = paths.scripts / "addPoshVcpkgToPowershellProfile.ps1";
|
const fs::path script_path = paths.scripts / "addPoshVcpkgToPowershellProfile.ps1";
|
||||||
|
|
||||||
const auto& ps = paths.get_tool_exe("powershell-core");
|
const auto& ps = paths.get_tool_exe("powershell-core");
|
||||||
const std::string cmd = Strings::format(R"("%s" -NoProfile -ExecutionPolicy Bypass -Command "& {& '%s' }")",
|
auto cmd = System::CmdLineBuilder(ps)
|
||||||
fs::u8string(ps),
|
.string_arg("-NoProfile")
|
||||||
fs::u8string(script_path));
|
.string_arg("-ExecutionPolicy")
|
||||||
|
.string_arg("Bypass")
|
||||||
|
.string_arg("-Command")
|
||||||
|
.string_arg(Strings::format("& {& '%s' }", fs::u8string(script_path)));
|
||||||
const int rc = System::cmd_execute(cmd);
|
const int rc = System::cmd_execute(cmd);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
|
@ -31,21 +31,20 @@ namespace vcpkg::Commands::PortHistory
|
|||||||
const System::ExitCodeAndOutput run_git_command_inner(const VcpkgPaths& paths,
|
const System::ExitCodeAndOutput run_git_command_inner(const VcpkgPaths& paths,
|
||||||
const fs::path& dot_git_directory,
|
const fs::path& dot_git_directory,
|
||||||
const fs::path& working_directory,
|
const fs::path& working_directory,
|
||||||
StringView cmd)
|
const System::CmdLineBuilder& cmd)
|
||||||
{
|
{
|
||||||
const fs::path& git_exe = paths.get_tool_exe(Tools::GIT);
|
const fs::path& git_exe = paths.get_tool_exe(Tools::GIT);
|
||||||
|
|
||||||
System::CmdLineBuilder builder;
|
auto full_cmd = System::CmdLineBuilder(git_exe)
|
||||||
builder.path_arg(git_exe)
|
|
||||||
.string_arg(Strings::concat("--git-dir=", fs::u8string(dot_git_directory)))
|
.string_arg(Strings::concat("--git-dir=", fs::u8string(dot_git_directory)))
|
||||||
.string_arg(Strings::concat("--work-tree=", fs::u8string(working_directory)));
|
.string_arg(Strings::concat("--work-tree=", fs::u8string(working_directory)))
|
||||||
const std::string full_cmd = Strings::concat(std::move(builder).extract(), " ", cmd);
|
.raw_arg(cmd.command_line());
|
||||||
|
|
||||||
const auto output = System::cmd_execute_and_capture_output(full_cmd);
|
auto output = System::cmd_execute_and_capture_output(full_cmd);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
const System::ExitCodeAndOutput run_git_command(const VcpkgPaths& paths, StringView cmd)
|
const System::ExitCodeAndOutput run_git_command(const VcpkgPaths& paths, const System::CmdLineBuilder& cmd)
|
||||||
{
|
{
|
||||||
const fs::path& work_dir = paths.root;
|
const fs::path& work_dir = paths.root;
|
||||||
const fs::path dot_git_dir = paths.root / ".git";
|
const fs::path dot_git_dir = paths.root / ".git";
|
||||||
@ -89,7 +88,8 @@ namespace vcpkg::Commands::PortHistory
|
|||||||
const std::string& commit_date,
|
const std::string& commit_date,
|
||||||
const std::string& port_name)
|
const std::string& port_name)
|
||||||
{
|
{
|
||||||
const std::string rev_parse_cmd = Strings::format("rev-parse %s:ports/%s", commit_id, port_name);
|
auto rev_parse_cmd =
|
||||||
|
System::CmdLineBuilder("rev-parse").string_arg(Strings::concat(commit_id, ":ports/", port_name));
|
||||||
auto rev_parse_output = run_git_command(paths, rev_parse_cmd);
|
auto rev_parse_output = run_git_command(paths, rev_parse_cmd);
|
||||||
if (rev_parse_output.exit_code == 0)
|
if (rev_parse_output.exit_code == 0)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ namespace vcpkg::Commands::PortHistory
|
|||||||
const auto git_tree = Strings::trim(std::move(rev_parse_output.output));
|
const auto git_tree = Strings::trim(std::move(rev_parse_output.output));
|
||||||
|
|
||||||
// Do we have a manifest file?
|
// Do we have a manifest file?
|
||||||
const std::string manifest_cmd = Strings::format(R"(show %s:vcpkg.json)", git_tree, port_name);
|
auto manifest_cmd = System::CmdLineBuilder("show").string_arg(Strings::concat(git_tree, ":vcpkg.json"));
|
||||||
auto manifest_output = run_git_command(paths, manifest_cmd);
|
auto manifest_output = run_git_command(paths, manifest_cmd);
|
||||||
if (manifest_output.exit_code == 0)
|
if (manifest_output.exit_code == 0)
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ namespace vcpkg::Commands::PortHistory
|
|||||||
manifest_output.output, git_tree, commit_id, commit_date, port_name, true);
|
manifest_output.output, git_tree, commit_id, commit_date, port_name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string cmd = Strings::format(R"(show %s:CONTROL)", git_tree, commit_id, port_name);
|
auto cmd = System::CmdLineBuilder("show").string_arg(Strings::concat(git_tree, ":CONTROL"));
|
||||||
auto control_output = run_git_command(paths, cmd);
|
auto control_output = run_git_command(paths, cmd);
|
||||||
|
|
||||||
if (control_output.exit_code == 0)
|
if (control_output.exit_code == 0)
|
||||||
|
@ -91,15 +91,18 @@ namespace vcpkg::Commands::PortsDiff
|
|||||||
const auto checkout_this_dir =
|
const auto checkout_this_dir =
|
||||||
Strings::format(R"(.\%s)", ports_dir_name_as_string); // Must be relative to the root of the repository
|
Strings::format(R"(.\%s)", ports_dir_name_as_string); // Must be relative to the root of the repository
|
||||||
|
|
||||||
const std::string cmd = Strings::format(R"("%s" --git-dir="%s" --work-tree="%s" checkout %s -f -q -- %s %s)",
|
auto cmd = System::CmdLineBuilder(git_exe)
|
||||||
fs::u8string(git_exe),
|
.string_arg(Strings::format("--git-dir=%s", fs::u8string(dot_git_dir)))
|
||||||
fs::u8string(dot_git_dir),
|
.string_arg(Strings::format("--work-tree=%s", fs::u8string(temp_checkout_path)))
|
||||||
fs::u8string(temp_checkout_path),
|
.string_arg("checkout")
|
||||||
git_commit_id,
|
.string_arg(git_commit_id)
|
||||||
checkout_this_dir,
|
.string_arg("-f")
|
||||||
".vcpkg-root");
|
.string_arg("-q")
|
||||||
|
.string_arg("--")
|
||||||
|
.string_arg(checkout_this_dir)
|
||||||
|
.string_arg(".vcpkg-root");
|
||||||
System::cmd_execute_and_capture_output(cmd, System::get_clean_environment());
|
System::cmd_execute_and_capture_output(cmd, System::get_clean_environment());
|
||||||
System::cmd_execute_and_capture_output(Strings::format(R"("%s" reset)", fs::u8string(git_exe)),
|
System::cmd_execute_and_capture_output(System::CmdLineBuilder(git_exe).string_arg("reset"),
|
||||||
System::get_clean_environment());
|
System::get_clean_environment());
|
||||||
const auto ports_at_commit =
|
const auto ports_at_commit =
|
||||||
Paragraphs::load_overlay_ports(paths, temp_checkout_path / ports_dir_name_as_string);
|
Paragraphs::load_overlay_ports(paths, temp_checkout_path / ports_dir_name_as_string);
|
||||||
@ -117,7 +120,7 @@ namespace vcpkg::Commands::PortsDiff
|
|||||||
{
|
{
|
||||||
static const std::string VALID_COMMIT_OUTPUT = "commit\n";
|
static const std::string VALID_COMMIT_OUTPUT = "commit\n";
|
||||||
|
|
||||||
const auto cmd = Strings::format(R"("%s" cat-file -t %s)", fs::u8string(git_exe), git_commit_id);
|
auto cmd = System::CmdLineBuilder(git_exe).string_arg("cat-file").string_arg("-t").string_arg(git_commit_id);
|
||||||
const System::ExitCodeAndOutput output = System::cmd_execute_and_capture_output(cmd);
|
const System::ExitCodeAndOutput output = System::cmd_execute_and_capture_output(cmd);
|
||||||
Checks::check_exit(
|
Checks::check_exit(
|
||||||
VCPKG_LINE_INFO, output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", git_commit_id);
|
VCPKG_LINE_INFO, output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", git_commit_id);
|
||||||
|
@ -216,10 +216,12 @@ if (Test-Path $installedDir)
|
|||||||
const fs::path chocolatey_uninstall_file_path = per_package_dir_path / "tools" / "chocolateyUninstall.ps1";
|
const fs::path chocolatey_uninstall_file_path = per_package_dir_path / "tools" / "chocolateyUninstall.ps1";
|
||||||
fs.write_contents(chocolatey_uninstall_file_path, chocolatey_uninstall_content, VCPKG_LINE_INFO);
|
fs.write_contents(chocolatey_uninstall_file_path, chocolatey_uninstall_content, VCPKG_LINE_INFO);
|
||||||
|
|
||||||
const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes)",
|
auto cmd_line = System::CmdLineBuilder(nuget_exe)
|
||||||
fs::u8string(nuget_exe),
|
.string_arg("pack")
|
||||||
fs::u8string(exported_dir_path),
|
.string_arg("-OutputDirectory")
|
||||||
fs::u8string(nuspec_file_path));
|
.path_arg(exported_dir_path)
|
||||||
|
.path_arg(nuspec_file_path)
|
||||||
|
.string_arg("-NoDefaultExcludes");
|
||||||
|
|
||||||
const int exit_code =
|
const int exit_code =
|
||||||
System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code;
|
System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code;
|
||||||
|
@ -370,10 +370,10 @@ namespace vcpkg::Export::IFW
|
|||||||
fs::generic_u8string(repository_dir),
|
fs::generic_u8string(repository_dir),
|
||||||
failure_point.string());
|
failure_point.string());
|
||||||
|
|
||||||
const auto cmd_line = Strings::format(R"("%s" --packages "%s" "%s")",
|
auto cmd_line = System::CmdLineBuilder(repogen_exe)
|
||||||
fs::u8string(repogen_exe),
|
.string_arg("--packages")
|
||||||
fs::u8string(packages_dir),
|
.path_arg(packages_dir)
|
||||||
fs::u8string(repository_dir));
|
.path_arg(repository_dir);
|
||||||
|
|
||||||
const int exit_code =
|
const int exit_code =
|
||||||
System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code;
|
System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code;
|
||||||
@ -393,24 +393,27 @@ namespace vcpkg::Export::IFW
|
|||||||
|
|
||||||
System::printf("Generating installer %s...\n", fs::generic_u8string(installer_file));
|
System::printf("Generating installer %s...\n", fs::generic_u8string(installer_file));
|
||||||
|
|
||||||
std::string cmd_line;
|
System::CmdLineBuilder cmd_line;
|
||||||
|
|
||||||
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
||||||
if (!ifw_repo_url.empty())
|
if (!ifw_repo_url.empty())
|
||||||
{
|
{
|
||||||
cmd_line = Strings::format(R"("%s" --online-only --config "%s" --repository "%s" "%s")",
|
cmd_line = System::CmdLineBuilder(binarycreator_exe)
|
||||||
fs::u8string(binarycreator_exe),
|
.string_arg("--online-only")
|
||||||
fs::u8string(config_file),
|
.string_arg("--config")
|
||||||
fs::u8string(repository_dir),
|
.path_arg(config_file)
|
||||||
fs::u8string(installer_file));
|
.string_arg("--repository")
|
||||||
|
.path_arg(repository_dir)
|
||||||
|
.path_arg(installer_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd_line = Strings::format(R"("%s" --config "%s" --packages "%s" "%s")",
|
cmd_line = System::CmdLineBuilder(binarycreator_exe)
|
||||||
fs::u8string(binarycreator_exe),
|
.string_arg("--config")
|
||||||
fs::u8string(config_file),
|
.path_arg(config_file)
|
||||||
fs::u8string(packages_dir),
|
.string_arg("--packages")
|
||||||
fs::u8string(installer_file));
|
.path_arg(packages_dir)
|
||||||
|
.path_arg(installer_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int exit_code =
|
const int exit_code =
|
||||||
|
@ -206,9 +206,10 @@ namespace vcpkg::Export::Prefab
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
||||||
|
|
||||||
System::cmd_execute_and_capture_output(
|
System::cmd_execute_and_capture_output(System::CmdLineBuilder(seven_zip_exe)
|
||||||
Strings::format(
|
.string_arg("a")
|
||||||
R"("%s" a "%s" "%s\*")", fs::u8string(seven_zip_exe), fs::u8string(destination), fs::u8string(source)),
|
.path_arg(destination)
|
||||||
|
.path_arg(source / fs::u8path("*")),
|
||||||
System::get_clean_environment());
|
System::get_clean_environment());
|
||||||
#else
|
#else
|
||||||
System::cmd_execute_clean(
|
System::cmd_execute_clean(
|
||||||
@ -223,11 +224,14 @@ namespace vcpkg::Export::Prefab
|
|||||||
{
|
{
|
||||||
System::print2("\n[DEBUG] Installing POM and AAR file to ~/.m2\n\n");
|
System::print2("\n[DEBUG] Installing POM and AAR file to ~/.m2\n\n");
|
||||||
}
|
}
|
||||||
const char* cmd_line_format = prefab_options.enable_debug
|
auto cmd_line = System::CmdLineBuilder(Tools::MAVEN);
|
||||||
? R"("%s" "install:install-file" "-Dfile=%s" "-DpomFile=%s")"
|
if (!prefab_options.enable_debug)
|
||||||
: R"("%s" "-q" "install:install-file" "-Dfile=%s" "-DpomFile=%s")";
|
{
|
||||||
|
cmd_line.string_arg("-q");
|
||||||
const auto cmd_line = Strings::format(cmd_line_format, Tools::MAVEN, fs::u8string(aar), fs::u8string(pom));
|
}
|
||||||
|
cmd_line.string_arg("install:install-file")
|
||||||
|
.string_arg(Strings::concat("-Dfile=", fs::u8string(aar)))
|
||||||
|
.string_arg(Strings::concat("-DpomFile=", fs::u8string(pom)));
|
||||||
const int exit_code = System::cmd_execute_clean(cmd_line);
|
const int exit_code = System::cmd_execute_clean(cmd_line);
|
||||||
Checks::check_exit(
|
Checks::check_exit(
|
||||||
VCPKG_LINE_INFO, exit_code == 0, "Error: %s installing maven file", fs::generic_u8string(aar));
|
VCPKG_LINE_INFO, exit_code == 0, "Error: %s installing maven file", fs::generic_u8string(aar));
|
||||||
|
@ -257,7 +257,7 @@ namespace vcpkg::Metrics
|
|||||||
return "{}";
|
return "{}";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto getmac = System::cmd_execute_and_capture_output("getmac");
|
auto getmac = System::cmd_execute_and_capture_output(System::CmdLineBuilder("getmac"));
|
||||||
|
|
||||||
if (getmac.exit_code != 0) return "0";
|
if (getmac.exit_code != 0) return "0";
|
||||||
|
|
||||||
@ -480,11 +480,21 @@ namespace vcpkg::Metrics
|
|||||||
builder.path_arg(vcpkg_metrics_txt_path);
|
builder.path_arg(vcpkg_metrics_txt_path);
|
||||||
System::cmd_execute_background(builder);
|
System::cmd_execute_background(builder);
|
||||||
#else
|
#else
|
||||||
auto escaped_path = Strings::escape_string(fs::u8string(vcpkg_metrics_txt_path), '\'', '\\');
|
// TODO: convert to cmd_execute_background or something.
|
||||||
const std::string cmd_line = Strings::format(
|
auto curl = System::CmdLineBuilder("curl")
|
||||||
R"((curl "https://dc.services.visualstudio.com/v2/track" -H "Content-Type: application/json" -X POST --tlsv1.2 --data '@%s' >/dev/null 2>&1; rm '%s') &)",
|
.string_arg("https://dc.services.visualstudio.com/v2/track")
|
||||||
escaped_path,
|
.string_arg("-H")
|
||||||
escaped_path);
|
.string_arg("Content-Type: application/json")
|
||||||
|
.string_arg("-X")
|
||||||
|
.string_arg("POST")
|
||||||
|
.string_arg("--tlsv1.2")
|
||||||
|
.string_arg("--data")
|
||||||
|
.string_arg(Strings::concat("@", fs::u8string(vcpkg_metrics_txt_path)))
|
||||||
|
.raw_arg(">/dev/null")
|
||||||
|
.raw_arg("2>&1");
|
||||||
|
auto remove = System::CmdLineBuilder("rm").path_arg(vcpkg_metrics_txt_path);
|
||||||
|
System::CmdLineBuilder cmd_line;
|
||||||
|
cmd_line.raw_arg("(").raw_arg(curl.command_line()).raw_arg(";").raw_arg(remove.command_line()).raw_arg(") &");
|
||||||
System::cmd_execute_clean(cmd_line);
|
System::cmd_execute_clean(cmd_line);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -390,10 +390,10 @@ namespace vcpkg::PostBuildLint
|
|||||||
std::vector<fs::path> dlls_with_no_exports;
|
std::vector<fs::path> dlls_with_no_exports;
|
||||||
for (const fs::path& dll : dlls)
|
for (const fs::path& dll : dlls)
|
||||||
{
|
{
|
||||||
const std::string cmd_line =
|
auto cmd_line = System::CmdLineBuilder(dumpbin_exe).string_arg("/exports").path_arg(dll);
|
||||||
Strings::format(R"("%s" /exports "%s")", fs::u8string(dumpbin_exe), fs::u8string(dll));
|
|
||||||
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line);
|
Checks::check_exit(
|
||||||
|
VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line.command_line());
|
||||||
|
|
||||||
if (ec_data.output.find("ordinal hint RVA name") == std::string::npos)
|
if (ec_data.output.find("ordinal hint RVA name") == std::string::npos)
|
||||||
{
|
{
|
||||||
@ -428,10 +428,10 @@ namespace vcpkg::PostBuildLint
|
|||||||
std::vector<fs::path> dlls_with_improper_uwp_bit;
|
std::vector<fs::path> dlls_with_improper_uwp_bit;
|
||||||
for (const fs::path& dll : dlls)
|
for (const fs::path& dll : dlls)
|
||||||
{
|
{
|
||||||
const std::string cmd_line =
|
auto cmd_line = System::CmdLineBuilder(dumpbin_exe).string_arg("/headers").path_arg(dll);
|
||||||
Strings::format(R"("%s" /headers "%s")", fs::u8string(dumpbin_exe), fs::u8string(dll));
|
|
||||||
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line);
|
Checks::check_exit(
|
||||||
|
VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line.command_line());
|
||||||
|
|
||||||
if (ec_data.output.find("App Container") == std::string::npos)
|
if (ec_data.output.find("App Container") == std::string::npos)
|
||||||
{
|
{
|
||||||
@ -720,13 +720,12 @@ namespace vcpkg::PostBuildLint
|
|||||||
|
|
||||||
for (const fs::path& lib : libs)
|
for (const fs::path& lib : libs)
|
||||||
{
|
{
|
||||||
const std::string cmd_line =
|
auto cmd_line = System::CmdLineBuilder(dumpbin_exe).string_arg("/directives").path_arg(lib);
|
||||||
Strings::format(R"("%s" /directives "%s")", fs::u8string(dumpbin_exe), fs::u8string(lib));
|
|
||||||
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
ec_data.exit_code == 0,
|
ec_data.exit_code == 0,
|
||||||
"Running command:\n %s\n failed with message:\n%s",
|
"Running command:\n %s\n failed with message:\n%s",
|
||||||
cmd_line,
|
cmd_line.command_line(),
|
||||||
ec_data.output);
|
ec_data.output);
|
||||||
|
|
||||||
for (const BuildType& bad_build_type : bad_build_types)
|
for (const BuildType& bad_build_type : bad_build_types)
|
||||||
@ -775,10 +774,10 @@ namespace vcpkg::PostBuildLint
|
|||||||
|
|
||||||
for (const fs::path& dll : dlls)
|
for (const fs::path& dll : dlls)
|
||||||
{
|
{
|
||||||
const auto cmd_line =
|
auto cmd_line = System::CmdLineBuilder(dumpbin_exe).string_arg("/dependents").path_arg(dll);
|
||||||
Strings::format(R"("%s" /dependents "%s")", fs::u8string(dumpbin_exe), fs::u8string(dll));
|
|
||||||
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line);
|
Checks::check_exit(
|
||||||
|
VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line.command_line());
|
||||||
|
|
||||||
for (const OutdatedDynamicCrt& outdated_crt : get_outdated_dynamic_crts(pre_build_info.platform_toolset))
|
for (const OutdatedDynamicCrt& outdated_crt : get_outdated_dynamic_crts(pre_build_info.platform_toolset))
|
||||||
{
|
{
|
||||||
|
@ -297,7 +297,7 @@ namespace vcpkg
|
|||||||
}
|
}
|
||||||
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
||||||
{
|
{
|
||||||
const std::string cmd = Strings::format(R"("%s" --version)", fs::u8string(path_to_exe));
|
auto cmd = System::CmdLineBuilder(path_to_exe).string_arg("--version");
|
||||||
auto rc = System::cmd_execute_and_capture_output(cmd);
|
auto rc = System::cmd_execute_and_capture_output(cmd);
|
||||||
if (rc.exit_code != 0)
|
if (rc.exit_code != 0)
|
||||||
{
|
{
|
||||||
@ -326,7 +326,7 @@ CMake suite maintained and supported by Kitware (kitware.com/cmake).
|
|||||||
|
|
||||||
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
||||||
{
|
{
|
||||||
const std::string cmd = Strings::format(R"("%s" --version)", fs::u8string(path_to_exe));
|
auto cmd = System::CmdLineBuilder(path_to_exe).string_arg("--version");
|
||||||
auto rc = System::cmd_execute_and_capture_output(cmd);
|
auto rc = System::cmd_execute_and_capture_output(cmd);
|
||||||
if (rc.exit_code != 0)
|
if (rc.exit_code != 0)
|
||||||
{
|
{
|
||||||
@ -414,7 +414,7 @@ Type 'NuGet help <command>' for help on a specific command.
|
|||||||
|
|
||||||
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
||||||
{
|
{
|
||||||
const std::string cmd = Strings::format(R"("%s" --version)", fs::u8string(path_to_exe));
|
auto cmd = System::CmdLineBuilder(path_to_exe).string_arg("--version");
|
||||||
auto rc = System::cmd_execute_and_capture_output(cmd);
|
auto rc = System::cmd_execute_and_capture_output(cmd);
|
||||||
if (rc.exit_code != 0)
|
if (rc.exit_code != 0)
|
||||||
{
|
{
|
||||||
@ -443,8 +443,8 @@ git version 2.17.1.windows.2
|
|||||||
|
|
||||||
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
||||||
{
|
{
|
||||||
auto rc = System::cmd_execute_and_capture_output(
|
auto rc =
|
||||||
System::CmdLineBuilder().path_arg(path_to_exe).string_arg("--version").extract());
|
System::cmd_execute_and_capture_output(System::CmdLineBuilder(path_to_exe).string_arg("--version"));
|
||||||
if (rc.exit_code != 0)
|
if (rc.exit_code != 0)
|
||||||
{
|
{
|
||||||
return {Strings::concat(
|
return {Strings::concat(
|
||||||
@ -485,7 +485,7 @@ Mono JIT compiler version 6.8.0.105 (Debian 6.8.0.105+dfsg-2 Wed Feb 26 23:23:50
|
|||||||
|
|
||||||
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
||||||
{
|
{
|
||||||
const std::string cmd = Strings::format(R"("%s" --framework-version)", fs::u8string(path_to_exe));
|
auto cmd = System::CmdLineBuilder(path_to_exe).string_arg("--framework-version");
|
||||||
auto rc = System::cmd_execute_and_capture_output(cmd);
|
auto rc = System::cmd_execute_and_capture_output(cmd);
|
||||||
if (rc.exit_code != 0)
|
if (rc.exit_code != 0)
|
||||||
{
|
{
|
||||||
@ -512,8 +512,8 @@ Mono JIT compiler version 6.8.0.105 (Debian 6.8.0.105+dfsg-2 Wed Feb 26 23:23:50
|
|||||||
|
|
||||||
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
virtual ExpectedS<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override
|
||||||
{
|
{
|
||||||
auto rc = System::cmd_execute_and_capture_output(
|
auto rc =
|
||||||
System::CmdLineBuilder().path_arg(path_to_exe).string_arg("--version").extract());
|
System::cmd_execute_and_capture_output(System::CmdLineBuilder(path_to_exe).string_arg("--version"));
|
||||||
if (rc.exit_code != 0)
|
if (rc.exit_code != 0)
|
||||||
{
|
{
|
||||||
return {Strings::concat(
|
return {Strings::concat(
|
||||||
|
@ -573,8 +573,7 @@ If you wish to silence this error and use classic mode, you can:
|
|||||||
.string_arg("-d")
|
.string_arg("-d")
|
||||||
.string_arg("HEAD")
|
.string_arg("HEAD")
|
||||||
.string_arg("--")
|
.string_arg("--")
|
||||||
.path_arg(path_with_separator)
|
.path_arg(path_with_separator);
|
||||||
.extract();
|
|
||||||
|
|
||||||
auto output = System::cmd_execute_and_capture_output(git_cmd);
|
auto output = System::cmd_execute_and_capture_output(git_cmd);
|
||||||
if (output.exit_code != 0)
|
if (output.exit_code != 0)
|
||||||
@ -589,19 +588,22 @@ If you wish to silence this error and use classic mode, you can:
|
|||||||
// <mode> SP <type> SP <object> TAB <file>
|
// <mode> SP <type> SP <object> TAB <file>
|
||||||
auto split_line = Strings::split(line, '\t');
|
auto split_line = Strings::split(line, '\t');
|
||||||
if (split_line.size() != 2)
|
if (split_line.size() != 2)
|
||||||
return Strings::format(
|
return Strings::format("Error: Unexpected output from command `%s`. Couldn't split by `\\t`.\n%s",
|
||||||
"Error: Unexpected output from command `%s`. Couldn't split by `\\t`.\n%s", git_cmd, line);
|
git_cmd.command_line(),
|
||||||
|
line);
|
||||||
|
|
||||||
auto file_info_section = Strings::split(split_line[0], ' ');
|
auto file_info_section = Strings::split(split_line[0], ' ');
|
||||||
if (file_info_section.size() != 3)
|
if (file_info_section.size() != 3)
|
||||||
return Strings::format(
|
return Strings::format("Error: Unexepcted output from command `%s`. Couldn't split by ` `.\n%s",
|
||||||
"Error: Unexepcted output from command `%s`. Couldn't split by ` `.\n%s", git_cmd, line);
|
git_cmd.command_line(),
|
||||||
|
line);
|
||||||
|
|
||||||
const auto index = split_line[1].find_last_of('/');
|
const auto index = split_line[1].find_last_of('/');
|
||||||
if (index == std::string::npos)
|
if (index == std::string::npos)
|
||||||
{
|
{
|
||||||
return Strings::format(
|
return Strings::format("Error: Unexpected output from command `%s`. Couldn't split by `/`.\n%s",
|
||||||
"Error: Unexpected output from command `%s`. Couldn't split by `/`.\n%s", git_cmd, line);
|
git_cmd.command_line(),
|
||||||
|
line);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.emplace(split_line[1].substr(index + 1), file_info_section.back());
|
ret.emplace(split_line[1].substr(index + 1), file_info_section.back());
|
||||||
|
@ -84,8 +84,14 @@ namespace vcpkg::VisualStudio
|
|||||||
const fs::path vswhere_exe = program_files_32_bit / "Microsoft Visual Studio" / "Installer" / "vswhere.exe";
|
const fs::path vswhere_exe = program_files_32_bit / "Microsoft Visual Studio" / "Installer" / "vswhere.exe";
|
||||||
if (fs.exists(vswhere_exe))
|
if (fs.exists(vswhere_exe))
|
||||||
{
|
{
|
||||||
const auto code_and_output = System::cmd_execute_and_capture_output(
|
const auto code_and_output = System::cmd_execute_and_capture_output(System::CmdLineBuilder(vswhere_exe)
|
||||||
Strings::format(R"("%s" -all -prerelease -legacy -products * -format xml)", fs::u8string(vswhere_exe)));
|
.string_arg("-all")
|
||||||
|
.string_arg("-prerelease")
|
||||||
|
.string_arg("-legacy")
|
||||||
|
.string_arg("-products")
|
||||||
|
.string_arg("*")
|
||||||
|
.string_arg("-format")
|
||||||
|
.string_arg("xml"));
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
code_and_output.exit_code == 0,
|
code_and_output.exit_code == 0,
|
||||||
"Running vswhere.exe failed with message:\n%s",
|
"Running vswhere.exe failed with message:\n%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user