This commit is contained in:
Robert Schumacher 2016-09-30 14:59:58 -07:00
commit 17786b865a
17 changed files with 78 additions and 93 deletions

View File

@ -21,20 +21,20 @@ if(NOT VCPKG_TOOLCHAIN)
set(_VCPKG_TARGET_TRIPLET_PLAT windows) set(_VCPKG_TARGET_TRIPLET_PLAT windows)
endif() endif()
set(_VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT}) set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)")
set(_VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_LIST_DIR}/../../installed) set(_VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_LIST_DIR}/../../installed)
set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}) set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR})
if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE) if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE)
list(APPEND CMAKE_PREFIX_PATH list(APPEND CMAKE_PREFIX_PATH
${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}/debug ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug
) )
endif() endif()
list(APPEND CMAKE_PREFIX_PATH list(APPEND CMAKE_PREFIX_PATH
${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET} ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
) )
include_directories(${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}/include) include_directories(${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include)
option(OVERRIDE_ADD_EXECUTABLE "Automatically copy dependencies into the output directory for executables." ON) option(OVERRIDE_ADD_EXECUTABLE "Automatically copy dependencies into the output directory for executables." ON)
if(OVERRIDE_ADD_EXECUTABLE) if(OVERRIDE_ADD_EXECUTABLE)
@ -43,7 +43,7 @@ if(NOT VCPKG_TOOLCHAIN)
add_custom_command(TARGET ${name} POST_BUILD add_custom_command(TARGET ${name} POST_BUILD
COMMAND powershell -executionpolicy UnRestricted -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 COMMAND powershell -executionpolicy UnRestricted -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1
-targetBinary $<TARGET_FILE:${name}> -targetBinary $<TARGET_FILE:${name}>
-installedDir "${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin" -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
-OutVariable out -OutVariable out
) )
endfunction() endfunction()

View File

@ -16,11 +16,11 @@ set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE})
string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET}) string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET})
string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET}) string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET})
if(NOT EXISTS ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) set(CMAKE_TRIPLET_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
message(FATAL_ERROR "Unsupported target triplet. Toolchain file does not exist: ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake") if(NOT EXISTS ${CMAKE_TRIPLET_FILE})
message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}")
endif() endif()
set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
list(APPEND CMAKE_MODULE_PATH ${VCPKG_ROOT_DIR}/scripts/cmake) list(APPEND CMAKE_MODULE_PATH ${VCPKG_ROOT_DIR}/scripts/cmake)
set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages") set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools") set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools")

View File

@ -4,8 +4,6 @@
namespace vcpkg namespace vcpkg
{ {
struct vcpkg_paths;
struct triplet struct triplet
{ {
static const triplet X86_WINDOWS; static const triplet X86_WINDOWS;
@ -19,8 +17,6 @@ namespace vcpkg
std::string architecture() const; std::string architecture() const;
std::string system() const; std::string system() const;
bool validate(const vcpkg_paths& paths) const;
}; };
bool operator==(const triplet& left, const triplet& right); bool operator==(const triplet& left, const triplet& right);

View File

@ -31,7 +31,7 @@ namespace vcpkg {namespace Strings {namespace details
return s; return s;
} }
std::wstring format_internal(const wchar_t* fmtstr, ...); std::wstring wformat_internal(const wchar_t* fmtstr, ...);
}}} }}}
namespace vcpkg {namespace Strings namespace vcpkg {namespace Strings
@ -44,10 +44,10 @@ namespace vcpkg {namespace Strings
} }
template <class...Args> template <class...Args>
std::wstring format(const wchar_t* fmtstr, const Args&...args) std::wstring wformat(const wchar_t* fmtstr, const Args&...args)
{ {
using vcpkg::Strings::details::to_wprintf_arg; using vcpkg::Strings::details::to_wprintf_arg;
return details::format_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...); return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...);
} }
std::wstring utf8_to_utf16(const std::string& s); std::wstring utf8_to_utf16(const std::string& s);

View File

@ -13,6 +13,7 @@ namespace vcpkg
fs::path package_dir(const package_spec& spec) const; fs::path package_dir(const package_spec& spec) const;
fs::path port_dir(const package_spec& spec) const; fs::path port_dir(const package_spec& spec) const;
bool is_valid_triplet(const triplet& t) const;
std::tr2::sys::path root; std::tr2::sys::path root;
std::tr2::sys::path packages; std::tr2::sys::path packages;

View File

@ -28,15 +28,15 @@ namespace vcpkg
Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name), Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name),
R"(Filename cannot contain invalid chars %s, but was %s)", R"(Filename cannot contain invalid chars %s, but was %s)",
Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name); Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name);
custom_filename = Strings::format(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name)); custom_filename = Strings::wformat(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name));
} }
const std::wstring cmdline = Strings::format(LR"(cmake -DCMD=CREATE -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")", const std::wstring cmdline = Strings::wformat(LR"(cmake -DCMD=CREATE -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")",
Strings::utf8_to_utf16(spec->name), Strings::utf8_to_utf16(spec->name),
Strings::utf8_to_utf16(spec->target_triplet.value), Strings::utf8_to_utf16(spec->target_triplet.value),
Strings::utf8_to_utf16(args.command_arguments.at(1)), Strings::utf8_to_utf16(args.command_arguments.at(1)),
custom_filename, custom_filename,
paths.ports_cmake.generic_wstring()); paths.ports_cmake.generic_wstring());
exit(System::cmd_execute(cmdline)); exit(System::cmd_execute(cmdline));
} }

View File

@ -15,7 +15,7 @@ namespace vcpkg
env_EDITOR = LR"(C:\Program Files (x86)\Microsoft VS Code\Code.exe)"; env_EDITOR = LR"(C:\Program Files (x86)\Microsoft VS Code\Code.exe)";
auto portpath = paths.ports / spec.name; auto portpath = paths.ports / spec.name;
std::wstring cmdLine = Strings::format(LR"("%s" "%s" "%s")", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native()); std::wstring cmdLine = Strings::wformat(LR"("%s" "%s" "%s")", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native());
exit(System::cmd_execute(cmdLine)); exit(System::cmd_execute(cmdLine));
} }
} }

View File

@ -22,12 +22,12 @@ namespace vcpkg
static void build_internal(const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir) static void build_internal(const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir)
{ {
const fs::path ports_cmake_script_path = paths.ports_cmake; const fs::path ports_cmake_script_path = paths.ports_cmake;
const std::wstring command = Strings::format(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")", const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
Strings::utf8_to_utf16(spec.target_triplet.architecture()), Strings::utf8_to_utf16(spec.target_triplet.architecture()),
Strings::utf8_to_utf16(spec.name), Strings::utf8_to_utf16(spec.name),
Strings::utf8_to_utf16(spec.target_triplet.value), Strings::utf8_to_utf16(spec.target_triplet.value),
port_dir.generic_wstring(), port_dir.generic_wstring(),
ports_cmake_script_path.generic_wstring()); ports_cmake_script_path.generic_wstring());
System::Stopwatch timer; System::Stopwatch timer;
timer.start(); timer.start();
@ -39,12 +39,12 @@ namespace vcpkg
{ {
System::println(System::color::error, "Error: building package %s failed", to_string(spec)); System::println(System::color::error, "Error: building package %s failed", to_string(spec));
System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n" System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n"
"submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n" "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n"
" Package: %s\n" " Package: %s\n"
" Vcpkg version: %s\n" " Vcpkg version: %s\n"
"\n" "\n"
"Additionally, attach any relevant sections from the log files above." "Additionally, attach any relevant sections from the log files above."
, to_string(spec), version()); , to_string(spec), version());
TrackProperty("error", "build failed"); TrackProperty("error", "build failed");
TrackProperty("build_error", to_string(spec)); TrackProperty("build_error", to_string(spec));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View File

@ -238,7 +238,7 @@ namespace vcpkg
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
const std::wstring cmd_line = Strings::format(LR"(DEL "%s")", get_appdata_targets_path().native()); const std::wstring cmd_line = Strings::wformat(LR"(DEL "%s")", get_appdata_targets_path().native());
const int exit_code = System::cmd_execute(cmd_line); const int exit_code = System::cmd_execute(cmd_line);
if (exit_code) if (exit_code)
{ {
@ -269,7 +269,7 @@ namespace vcpkg
std::ofstream(nuspec_file_path) << create_nuspec_file(paths.root, nuget_id, nupkg_version); std::ofstream(nuspec_file_path) << create_nuspec_file(paths.root, nuget_id, nupkg_version);
// Using all forward slashes for the command line // Using all forward slashes for the command line
const std::wstring cmd_line = Strings::format(LR"(nuget.exe pack -OutputDirectory "%s" "%s" > nul)", buildsystems_dir.native(), nuspec_file_path.native()); const std::wstring cmd_line = Strings::wformat(LR"(nuget.exe pack -OutputDirectory "%s" "%s" > nul)", buildsystems_dir.native(), nuspec_file_path.native());
const int exit_code = System::cmd_execute(cmd_line); const int exit_code = System::cmd_execute(cmd_line);

View File

@ -70,14 +70,14 @@ static void inner(const vcpkg_cmd_arguments& args)
} }
triplet default_target_triplet; triplet default_target_triplet;
if(args.target_triplet != nullptr) if (args.target_triplet != nullptr)
{ {
default_target_triplet = {*args.target_triplet}; default_target_triplet = {*args.target_triplet};
} }
else else
{ {
const auto vcpkg_default_triplet_env = System::wdupenv_str(L"VCPKG_DEFAULT_TRIPLET"); const auto vcpkg_default_triplet_env = System::wdupenv_str(L"VCPKG_DEFAULT_TRIPLET");
if(!vcpkg_default_triplet_env.empty()) if (!vcpkg_default_triplet_env.empty())
{ {
default_target_triplet = {Strings::utf16_to_utf8(vcpkg_default_triplet_env)}; default_target_triplet = {Strings::utf16_to_utf8(vcpkg_default_triplet_env)};
} }
@ -87,7 +87,7 @@ static void inner(const vcpkg_cmd_arguments& args)
} }
} }
if(!default_target_triplet.validate(paths)) if (!paths.is_valid_triplet(default_target_triplet))
{ {
System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value); System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value);
TrackProperty("error", "invalid triplet: " + default_target_triplet.value); TrackProperty("error", "invalid triplet: " + default_target_triplet.value);

View File

@ -419,7 +419,7 @@ true
const fs::path vcpkg_metrics_txt_path = temp_folder_path / ("vcpkg" + GenerateRandomUUID() + ".txt"); const fs::path vcpkg_metrics_txt_path = temp_folder_path / ("vcpkg" + GenerateRandomUUID() + ".txt");
std::ofstream(vcpkg_metrics_txt_path) << payload; std::ofstream(vcpkg_metrics_txt_path) << payload;
const std::wstring cmdLine = Strings::format(L"start %s %s", temp_folder_path_exe.native(), vcpkg_metrics_txt_path.native()); const std::wstring cmdLine = Strings::wformat(L"start %s %s", temp_folder_path_exe.native(), vcpkg_metrics_txt_path.native());
System::cmd_execute(cmdLine); System::cmd_execute(cmdLine);
} }
} }

View File

@ -71,12 +71,10 @@ namespace vcpkg
System::println(System::color::warning, "Include files should not be duplicated into the /debug/include directory. If this cannot be disabled in the project cmake, use\n" System::println(System::color::warning, "Include files should not be duplicated into the /debug/include directory. If this cannot be disabled in the project cmake, use\n"
" file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)" " file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)"
); );
return return lint_status::ERROR;
lint_status::ERROR;
} }
return return lint_status::SUCCESS;
lint_status::SUCCESS;
} }
static lint_status check_for_files_in_debug_share_directory(const package_spec& spec, const vcpkg_paths& paths) static lint_status check_for_files_in_debug_share_directory(const package_spec& spec, const vcpkg_paths& paths)
@ -221,7 +219,7 @@ namespace vcpkg
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::wstring cmd_line = Strings::format(LR"("%s" /exports "%s")", DUMPBIN_EXE.native(), dll.native()); const std::wstring cmd_line = Strings::wformat(LR"("%s" /exports "%s")", DUMPBIN_EXE.native(), dll.native());
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
@ -252,7 +250,7 @@ namespace vcpkg
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::wstring cmd_line = Strings::format(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), dll.native()); const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), dll.native());
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
@ -284,7 +282,7 @@ namespace vcpkg
std::vector<file_and_arch> binaries_with_invalid_architecture; std::vector<file_and_arch> binaries_with_invalid_architecture;
for (const fs::path& f : files) for (const fs::path& f : files)
{ {
const std::wstring cmd_line = Strings::format(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native()); const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native());
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));

View File

@ -1,6 +1,4 @@
#include "triplet.h" #include "triplet.h"
#include "vcpkg.h"
#include "vcpkg_System.h"
#include "vcpkg_Checks.h" #include "vcpkg_Checks.h"
namespace vcpkg namespace vcpkg
@ -38,38 +36,15 @@ namespace vcpkg
std::string triplet::architecture() const std::string triplet::architecture() const
{ {
if (*this == X86_WINDOWS || *this == X86_UWP) auto it = std::find(this->value.cbegin(), this->value.cend(), '-');
return "x86"; Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value);
if (*this == X64_WINDOWS || *this == X64_UWP) return std::string(this->value.cbegin(), it);
return "x64";
if (*this == ARM_UWP)
return "arm";
Checks::exit_with_message("Unknown architecture: %s", value);
} }
std::string triplet::system() const std::string triplet::system() const
{ {
if (*this == X86_WINDOWS || *this == X64_WINDOWS) auto it = std::find(this->value.cbegin(), this->value.cend(), '-');
return "windows"; Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value);
if (*this == X86_UWP || *this == X64_UWP || *this == ARM_UWP) return std::string(it + 1, this->value.cend());
return "uwp";
Checks::exit_with_message("Unknown system: %s", value);
}
bool triplet::validate(const vcpkg_paths& paths) const
{
auto it = fs::directory_iterator(paths.triplets);
for (; it != fs::directory_iterator(); ++it)
{
std::string triplet_file_name = it->path().stem().generic_u8string();
if (value == triplet_file_name) // TODO: fuzzy compare
{
//value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
return true;
}
}
return false;
} }
} }

View File

@ -48,11 +48,11 @@ namespace vcpkg {namespace Environment
void ensure_git_on_path(const vcpkg_paths& paths) void ensure_git_on_path(const vcpkg_paths& paths)
{ {
const fs::path downloaded_git = paths.downloads / "PortableGit" / "cmd"; const fs::path downloaded_git = paths.downloads / "PortableGit" / "cmd";
const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s", const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s",
downloaded_git.native(), downloaded_git.native(),
System::wdupenv_str(L"PATH"), System::wdupenv_str(L"PATH"),
default_git_installation_dir.native(), default_git_installation_dir.native(),
default_git_installation_dir_x86.native()); default_git_installation_dir_x86.native());
_wputenv_s(L"PATH", path_buf.c_str()); _wputenv_s(L"PATH", path_buf.c_str());
static constexpr std::array<int, 3> git_version = {2,0,0}; static constexpr std::array<int, 3> git_version = {2,0,0};
@ -63,11 +63,11 @@ namespace vcpkg {namespace Environment
void ensure_cmake_on_path(const vcpkg_paths& paths) void ensure_cmake_on_path(const vcpkg_paths& paths)
{ {
const fs::path downloaded_cmake = paths.downloads / "cmake-3.5.2-win32-x86" / "bin"; const fs::path downloaded_cmake = paths.downloads / "cmake-3.5.2-win32-x86" / "bin";
const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s", const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s",
downloaded_cmake.native(), downloaded_cmake.native(),
System::wdupenv_str(L"PATH"), System::wdupenv_str(L"PATH"),
default_cmake_installation_dir.native(), default_cmake_installation_dir.native(),
default_cmake_installation_dir_x86.native()); default_cmake_installation_dir_x86.native());
_wputenv_s(L"PATH", path_buf.c_str()); _wputenv_s(L"PATH", path_buf.c_str());
static constexpr std::array<int, 3> cmake_version = {3,5,0}; static constexpr std::array<int, 3> cmake_version = {3,5,0};
@ -77,7 +77,7 @@ namespace vcpkg {namespace Environment
void ensure_nuget_on_path(const vcpkg_paths& paths) void ensure_nuget_on_path(const vcpkg_paths& paths)
{ {
const std::wstring path_buf = Strings::format(L"%s;%s", paths.downloads.native(), System::wdupenv_str(L"PATH")); const std::wstring path_buf = Strings::wformat(L"%s;%s", paths.downloads.native(), System::wdupenv_str(L"PATH"));
_wputenv_s(L"PATH", path_buf.c_str()); _wputenv_s(L"PATH", path_buf.c_str());
static constexpr std::array<int, 3> nuget_version = {1,0,0}; static constexpr std::array<int, 3> nuget_version = {1,0,0};

View File

@ -20,7 +20,7 @@ namespace vcpkg {namespace Strings {namespace details
return output; return output;
} }
std::wstring format_internal(const wchar_t* fmtstr, ...) std::wstring wformat_internal(const wchar_t* fmtstr, ...)
{ {
va_list lst; va_list lst;
va_start(lst, fmtstr); va_start(lst, fmtstr);

View File

@ -19,14 +19,14 @@ namespace vcpkg {namespace System
int cmd_execute(const wchar_t* cmd_line) int cmd_execute(const wchar_t* cmd_line)
{ {
// Basically we are wrapping it in quotes // Basically we are wrapping it in quotes
const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line); const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
int exit_code = _wsystem(actual_cmd_line.c_str()); int exit_code = _wsystem(actual_cmd_line.c_str());
return exit_code; return exit_code;
} }
exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line) exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line)
{ {
const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line); const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
std::string output; std::string output;
char buf[1024]; char buf[1024];

View File

@ -56,4 +56,19 @@ namespace vcpkg
{ {
return this->ports / spec.name; return this->ports / spec.name;
} }
bool vcpkg_paths::is_valid_triplet(const triplet& t) const
{
auto it = fs::directory_iterator(this->triplets);
for (; it != fs::directory_iterator(); ++it)
{
std::string triplet_file_name = it->path().stem().generic_u8string();
if (t.value == triplet_file_name) // TODO: fuzzy compare
{
//t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
return true;
}
}
return false;
}
} }