2016-09-18 20:50:08 -07:00
|
|
|
#pragma once
|
|
|
|
|
2017-10-13 18:37:41 -07:00
|
|
|
#include <vcpkg/base/files.h>
|
|
|
|
#include <vcpkg/base/optional.h>
|
|
|
|
#include <vcpkg/base/strings.h>
|
|
|
|
|
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-11-20 18:17:24 -08:00
|
|
|
struct CMakeVariable
|
|
|
|
{
|
|
|
|
CMakeVariable(const CStringView varname, const char* varvalue);
|
|
|
|
CMakeVariable(const CStringView varname, const std::string& varvalue);
|
|
|
|
CMakeVariable(const CStringView varname, const fs::path& path);
|
|
|
|
|
|
|
|
std::string s;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string make_cmake_cmd(const fs::path& cmake_exe,
|
|
|
|
const fs::path& cmake_script,
|
|
|
|
const std::vector<CMakeVariable>& pass_variables);
|
|
|
|
|
|
|
|
struct PowershellParameter
|
|
|
|
{
|
|
|
|
PowershellParameter(const CStringView varname, const char* varvalue);
|
|
|
|
PowershellParameter(const CStringView varname, const std::string& varvalue);
|
|
|
|
PowershellParameter(const CStringView varname, const fs::path& path);
|
|
|
|
|
|
|
|
std::string s;
|
|
|
|
};
|
|
|
|
|
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-10-16 11:44:04 -07:00
|
|
|
int cmd_execute_clean(const CStringView cmd_line);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-10-16 11:44:04 -07:00
|
|
|
int cmd_execute(const CStringView cmd_line);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-10-16 11:44:04 -07:00
|
|
|
ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line);
|
2017-03-06 16:16:56 -08:00
|
|
|
|
2017-11-26 02:49:23 -08:00
|
|
|
void powershell_execute(const std::string& title,
|
|
|
|
const fs::path& script_path,
|
|
|
|
const std::vector<PowershellParameter>& parameters = {});
|
|
|
|
|
2017-11-04 16:40:11 -07:00
|
|
|
std::string powershell_execute_and_capture_output(const std::string& title,
|
|
|
|
const fs::path& script_path,
|
2017-11-20 18:17:24 -08:00
|
|
|
const std::vector<PowershellParameter>& parameters = {});
|
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-08-28 19:29:12 -07:00
|
|
|
void println();
|
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-10-19 21:34:58 -07:00
|
|
|
void print(const char* message_template, const Arg1& message_arg1, const Args&... message_args)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-10-19 21:34:58 -07:00
|
|
|
return System::print(Strings::format(message_template, message_arg1, message_args...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<class Arg1, class... Args>
|
2017-10-19 21:34:58 -07:00
|
|
|
void print(const Color c, const char* message_template, const Arg1& message_arg1, const Args&... message_args)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-10-19 21:34:58 -07:00
|
|
|
return System::print(c, Strings::format(message_template, message_arg1, message_args...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<class Arg1, class... Args>
|
2017-10-19 21:34:58 -07:00
|
|
|
void println(const char* message_template, const Arg1& message_arg1, const Args&... message_args)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-10-19 21:34:58 -07:00
|
|
|
return System::println(Strings::format(message_template, message_arg1, message_args...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<class Arg1, class... Args>
|
2017-10-19 21:34:58 -07:00
|
|
|
void println(const Color c, const char* message_template, const Arg1& message_arg1, const Args&... message_args)
|
2016-12-12 14:58:38 -08:00
|
|
|
{
|
2017-10-19 21:34:58 -07:00
|
|
|
return System::println(c, Strings::format(message_template, message_arg1, message_args...));
|
2016-12-12 14:58:38 -08:00
|
|
|
}
|
|
|
|
|
2017-10-16 11:44:04 -07:00
|
|
|
Optional<std::string> get_environment_variable(const CStringView varname) noexcept;
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-10-16 13:50:28 -07:00
|
|
|
Optional<std::string> get_registry_string(void* base_hkey, const CStringView subkey, const CStringView valuename);
|
2017-03-31 17:24:45 -07:00
|
|
|
|
2017-05-03 16:33:02 -07:00
|
|
|
enum class CPUArchitecture
|
|
|
|
{
|
|
|
|
X86,
|
|
|
|
X64,
|
|
|
|
ARM,
|
|
|
|
ARM64,
|
|
|
|
};
|
|
|
|
|
2017-10-16 13:50:28 -07:00
|
|
|
Optional<CPUArchitecture> to_cpu_architecture(const CStringView& arch);
|
2017-05-03 16:33:02 -07:00
|
|
|
|
|
|
|
CPUArchitecture get_host_processor();
|
|
|
|
|
2017-08-24 13:26:42 +03:00
|
|
|
std::vector<CPUArchitecture> get_supported_host_architectures();
|
|
|
|
|
2017-08-31 18:02:12 -07:00
|
|
|
const fs::path& get_program_files_32_bit();
|
2017-03-31 17:24:45 -07:00
|
|
|
|
2017-08-31 18:02:51 -07:00
|
|
|
const fs::path& get_program_files_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>
|
2017-10-19 21:34:58 -07:00
|
|
|
void println(const char* message_template, const Arg1& message_arg1, const Args&... message_args)
|
2017-05-05 14:37:58 -07:00
|
|
|
{
|
2017-10-19 21:34:58 -07:00
|
|
|
return Debug::println(Strings::format(message_template, message_arg1, message_args...));
|
2017-05-05 14:37:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class Arg1, class... Args>
|
|
|
|
void println(const System::Color c,
|
2017-10-19 21:34:58 -07:00
|
|
|
const char* message_template,
|
|
|
|
const Arg1& message_arg1,
|
|
|
|
const Args&... message_args)
|
2017-05-05 14:37:58 -07:00
|
|
|
{
|
2017-10-19 21:34:58 -07:00
|
|
|
return Debug::println(c, Strings::format(message_template, message_arg1, message_args...));
|
2017-05-05 14:37:58 -07:00
|
|
|
}
|
|
|
|
}
|