2016-09-18 20:50:08 -07:00
|
|
|
#pragma once
|
|
|
|
|
2016-11-29 18:08:53 -08:00
|
|
|
#include "filesystem_fs.h"
|
2017-04-27 17:56:06 -07:00
|
|
|
#include "vcpkg_Strings.h"
|
2017-02-14 15:35:34 -08:00
|
|
|
#include "vcpkg_optional.h"
|
2017-04-27 17:56:06 -07:00
|
|
|
#include <Windows.h>
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-01-05 12:47:08 -08:00
|
|
|
namespace vcpkg::System
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-04-20 18:59:03 -07:00
|
|
|
tm get_current_date_time();
|
|
|
|
|
2016-11-29 18:08:53 -08:00
|
|
|
fs::path get_exe_path_of_current_process();
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 16:30:11 -07:00
|
|
|
struct ExitCodeAndOutput
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
int exit_code;
|
|
|
|
std::string output;
|
|
|
|
};
|
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
int cmd_execute_clean(const CWStringView cmd_line);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
int cmd_execute(const CWStringView cmd_line);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 16:30:11 -07:00
|
|
|
ExitCodeAndOutput cmd_execute_and_capture_output(const CWStringView cmd_line);
|
2017-03-06 16:16:56 -08:00
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args = L"");
|
2017-03-06 16:16:56 -08:00
|
|
|
|
2017-04-03 16:31:00 -07:00
|
|
|
enum class Color
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
success = 10,
|
|
|
|
error = 12,
|
|
|
|
warning = 14,
|
|
|
|
};
|
|
|
|
|
2017-04-03 14:21:51 -07:00
|
|
|
void print(const CStringView message);
|
|
|
|
void println(const CStringView message);
|
2017-04-03 16:31:00 -07:00
|
|
|
void print(const Color c, const CStringView message);
|
|
|
|
void println(const Color c, const CStringView message);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<class Arg1, class... Args>
|
2017-03-28 12:51:35 -07:00
|
|
|
void print(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-05-05 14:37:58 -07:00
|
|
|
return System::print(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<class Arg1, class... Args>
|
2017-04-03 16:31:00 -07:00
|
|
|
void print(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-05-05 14:37:58 -07:00
|
|
|
return System::print(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<class Arg1, class... Args>
|
2017-03-28 12:51:35 -07:00
|
|
|
void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-05-05 14:37:58 -07:00
|
|
|
return System::println(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<class Arg1, class... Args>
|
2017-04-03 16:31:00 -07:00
|
|
|
void println(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-05-05 14:37:58 -07:00
|
|
|
return System::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-05-04 14:58:18 -07:00
|
|
|
Optional<std::wstring> get_environment_variable(const CWStringView varname) noexcept;
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-03 16:27:51 -07:00
|
|
|
Optional<std::wstring> get_registry_string(HKEY base, const CWStringView subkey, const CWStringView valuename);
|
2017-03-31 17:24:45 -07:00
|
|
|
|
2017-05-03 16:33:02 -07:00
|
|
|
enum class CPUArchitecture
|
|
|
|
{
|
|
|
|
X86,
|
|
|
|
X64,
|
|
|
|
ARM,
|
|
|
|
ARM64,
|
|
|
|
};
|
|
|
|
|
|
|
|
Optional<CPUArchitecture> to_cpu_architecture(CStringView arch);
|
|
|
|
|
|
|
|
CPUArchitecture get_host_processor();
|
|
|
|
|
2017-03-31 17:24:45 -07:00
|
|
|
const fs::path& get_ProgramFiles_32_bit();
|
|
|
|
|
|
|
|
const fs::path& get_ProgramFiles_platform_bitness();
|
2017-01-05 12:47:08 -08:00
|
|
|
}
|
2017-05-05 14:37:58 -07:00
|
|
|
|
|
|
|
namespace vcpkg::Debug
|
|
|
|
{
|
|
|
|
void println(const CStringView message);
|
|
|
|
void println(const System::Color c, const CStringView message);
|
|
|
|
|
|
|
|
template<class Arg1, class... Args>
|
|
|
|
void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
|
|
|
{
|
|
|
|
return Debug::println(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Arg1, class... Args>
|
|
|
|
void println(const System::Color c,
|
|
|
|
const char* messageTemplate,
|
|
|
|
const Arg1& messageArg1,
|
|
|
|
const Args&... messageArgs)
|
|
|
|
{
|
|
|
|
return Debug::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
|
|
|
}
|
|
|
|
}
|