From 8ea76e833eff904a958348b560a57e12b3fbeb3f Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 27 Sep 2016 15:51:38 -0700 Subject: [PATCH 1/8] [triplet] Part before dash is arch. Part after dash is system --- toolsrc/src/triplet.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp index 4270c458d3..080198f2b7 100644 --- a/toolsrc/src/triplet.cpp +++ b/toolsrc/src/triplet.cpp @@ -38,24 +38,16 @@ namespace vcpkg std::string triplet::architecture() const { - if (*this == X86_WINDOWS || *this == X86_UWP) - return "x86"; - if (*this == X64_WINDOWS || *this == X64_UWP) - return "x64"; - if (*this == ARM_UWP) - return "arm"; - - Checks::exit_with_message("Unknown architecture: %s", value); + auto it = std::find(this->value.cbegin(), this->value.cend(), '-'); + Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value); + return std::string(this->value.cbegin(), it); } std::string triplet::system() const { - if (*this == X86_WINDOWS || *this == X64_WINDOWS) - return "windows"; - if (*this == X86_UWP || *this == X64_UWP || *this == ARM_UWP) - return "uwp"; - - Checks::exit_with_message("Unknown system: %s", value); + auto it = std::find(this->value.cbegin(), this->value.cend(), '-'); + Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value); + return std::string(it + 1, this->value.cend()); } bool triplet::validate(const vcpkg_paths& paths) const @@ -64,9 +56,9 @@ namespace vcpkg for (; it != fs::directory_iterator(); ++it) { std::string triplet_file_name = it->path().stem().generic_u8string(); - if (value == triplet_file_name) // TODO: fuzzy compare + if (this->value == triplet_file_name) // TODO: fuzzy compare { - //value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare + //this->value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare return true; } } From 17b95eb28ce2040f1321c4c8348354597fbaa184 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 28 Sep 2016 12:05:46 -0700 Subject: [PATCH 2/8] Remove leading underscore in _VCPKG_TARGET_TRIPLET and add CACHE attribute --- scripts/buildsystems/vcpkg.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 10be855e5f..ca0900b895 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -21,20 +21,20 @@ if(NOT VCPKG_TOOLCHAIN) set(_VCPKG_TARGET_TRIPLET_PLAT windows) 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_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}) if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE) list(APPEND CMAKE_PREFIX_PATH - ${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}/debug + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug ) endif() 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) if(OVERRIDE_ADD_EXECUTABLE) @@ -43,7 +43,7 @@ if(NOT VCPKG_TOOLCHAIN) add_custom_command(TARGET ${name} POST_BUILD COMMAND powershell -executionpolicy UnRestricted -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 -targetBinary $ - -installedDir "${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}$<$:/debug>/bin" + -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$:/debug>/bin" -OutVariable out ) endfunction() From ac2e248e8f6c482811e33bcc1f311b0543be2d80 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 28 Sep 2016 12:19:29 -0700 Subject: [PATCH 3/8] Rename variable to CMAKE_TRIPLET_FILE --- scripts/ports.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 5887504d24..be73209ad2 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -16,11 +16,11 @@ set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE}) string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET}) string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET}) -if(NOT EXISTS ${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") +set(CMAKE_TRIPLET_FILE ${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() -set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.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(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools") From fb1130876f228464254e3e818fae42445405f6ed Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 28 Sep 2016 12:39:05 -0700 Subject: [PATCH 4/8] Valiting triplets is now the responsibility of vcpkg_paths --- toolsrc/include/triplet.h | 4 ---- toolsrc/include/vcpkg_paths.h | 1 + toolsrc/src/main.cpp | 6 +++--- toolsrc/src/triplet.cpp | 17 ----------------- toolsrc/src/vcpkg_paths.cpp | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h index 23c1ea4046..f9d1e9483a 100644 --- a/toolsrc/include/triplet.h +++ b/toolsrc/include/triplet.h @@ -4,8 +4,6 @@ namespace vcpkg { - struct vcpkg_paths; - struct triplet { static const triplet X86_WINDOWS; @@ -19,8 +17,6 @@ namespace vcpkg std::string architecture() const; std::string system() const; - - bool validate(const vcpkg_paths& paths) const; }; bool operator==(const triplet& left, const triplet& right); diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h index 72cba01b7f..c444d695ee 100644 --- a/toolsrc/include/vcpkg_paths.h +++ b/toolsrc/include/vcpkg_paths.h @@ -13,6 +13,7 @@ namespace vcpkg fs::path package_dir(const package_spec& spec) const; fs::path port_dir(const package_spec& spec) const; + bool validate_triplet(const triplet& t) const; std::tr2::sys::path root; std::tr2::sys::path packages; diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp index a2f6fa10fa..c7162dce0b 100644 --- a/toolsrc/src/main.cpp +++ b/toolsrc/src/main.cpp @@ -70,14 +70,14 @@ static void inner(const vcpkg_cmd_arguments& args) } triplet default_target_triplet; - if(args.target_triplet != nullptr) + if (args.target_triplet != nullptr) { default_target_triplet = {*args.target_triplet}; } else { 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)}; } @@ -87,7 +87,7 @@ static void inner(const vcpkg_cmd_arguments& args) } } - if(!default_target_triplet.validate(paths)) + if (!paths.validate_triplet(default_target_triplet)) { System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value); TrackProperty("error", "invalid triplet: " + default_target_triplet.value); diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp index 080198f2b7..e3a9359586 100644 --- a/toolsrc/src/triplet.cpp +++ b/toolsrc/src/triplet.cpp @@ -1,6 +1,4 @@ #include "triplet.h" -#include "vcpkg.h" -#include "vcpkg_System.h" #include "vcpkg_Checks.h" namespace vcpkg @@ -49,19 +47,4 @@ namespace vcpkg Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value); return std::string(it + 1, this->value.cend()); } - - 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 (this->value == triplet_file_name) // TODO: fuzzy compare - { - //this->value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare - return true; - } - } - return false; - } } diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp index 30d32a99b8..b3bbcbee1c 100644 --- a/toolsrc/src/vcpkg_paths.cpp +++ b/toolsrc/src/vcpkg_paths.cpp @@ -56,4 +56,19 @@ namespace vcpkg { return this->ports / spec.name; } + + bool vcpkg_paths::validate_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; + } } From 033f577c51c1e830fb27048c561ff76985855b2d Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 28 Sep 2016 15:34:10 -0700 Subject: [PATCH 5/8] Fix formatting --- toolsrc/src/post_build_lint.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 1d4ca0f67f..15e30ed4fa 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -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" " file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)" ); - return - lint_status::ERROR; + return lint_status::ERROR; } - return - lint_status::SUCCESS; + return lint_status::SUCCESS; } static lint_status check_for_files_in_debug_share_directory(const package_spec& spec, const vcpkg_paths& paths) From 8e3ee0523072c9330474a13507782cccb2b2be06 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 29 Sep 2016 12:35:27 -0700 Subject: [PATCH 6/8] Rename validate_triplet to is_valid_triplet --- toolsrc/include/vcpkg_paths.h | 2 +- toolsrc/src/main.cpp | 2 +- toolsrc/src/vcpkg_paths.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h index c444d695ee..d13c73b0bc 100644 --- a/toolsrc/include/vcpkg_paths.h +++ b/toolsrc/include/vcpkg_paths.h @@ -13,7 +13,7 @@ namespace vcpkg fs::path package_dir(const package_spec& spec) const; fs::path port_dir(const package_spec& spec) const; - bool validate_triplet(const triplet& t) const; + bool is_valid_triplet(const triplet& t) const; std::tr2::sys::path root; std::tr2::sys::path packages; diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp index c7162dce0b..a317330ff5 100644 --- a/toolsrc/src/main.cpp +++ b/toolsrc/src/main.cpp @@ -87,7 +87,7 @@ static void inner(const vcpkg_cmd_arguments& args) } } - if (!paths.validate_triplet(default_target_triplet)) + if (!paths.is_valid_triplet(default_target_triplet)) { System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value); TrackProperty("error", "invalid triplet: " + default_target_triplet.value); diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp index b3bbcbee1c..463f62c80e 100644 --- a/toolsrc/src/vcpkg_paths.cpp +++ b/toolsrc/src/vcpkg_paths.cpp @@ -57,7 +57,7 @@ namespace vcpkg return this->ports / spec.name; } - bool vcpkg_paths::validate_triplet(const triplet& t) const + bool vcpkg_paths::is_valid_triplet(const triplet& t) const { auto it = fs::directory_iterator(this->triplets); for (; it != fs::directory_iterator(); ++it) From a4ab4fd24150e0c1341aa05192b6cc9c12c57c49 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 29 Sep 2016 19:25:07 -0700 Subject: [PATCH 7/8] Rename wchar_t overload of format_internal to wformat_internal --- toolsrc/include/vcpkg_Strings.h | 4 ++-- toolsrc/src/vcpkg_Strings.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index f4b9892928..6b48966402 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -31,7 +31,7 @@ namespace vcpkg {namespace Strings {namespace details return s; } - std::wstring format_internal(const wchar_t* fmtstr, ...); + std::wstring wformat_internal(const wchar_t* fmtstr, ...); }}} namespace vcpkg {namespace Strings @@ -47,7 +47,7 @@ namespace vcpkg {namespace Strings std::wstring format(const wchar_t* fmtstr, const Args&...args) { 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); diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index b0312536a2..9a81bbbfd0 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -20,7 +20,7 @@ namespace vcpkg {namespace Strings {namespace details return output; } - std::wstring format_internal(const wchar_t* fmtstr, ...) + std::wstring wformat_internal(const wchar_t* fmtstr, ...) { va_list lst; va_start(lst, fmtstr); From 8ed88af8c9cf2ed2e6fd573b2cd5dc2b41b55625 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 29 Sep 2016 19:28:00 -0700 Subject: [PATCH 8/8] Rename wchar_t overload of Strings::format() to wformat() --- toolsrc/include/vcpkg_Strings.h | 2 +- toolsrc/src/commands_create.cpp | 14 +++++++------- toolsrc/src/commands_edit.cpp | 2 +- toolsrc/src/commands_installation.cpp | 24 ++++++++++++------------ toolsrc/src/commands_integration.cpp | 4 ++-- toolsrc/src/metrics.cpp | 2 +- toolsrc/src/post_build_lint.cpp | 6 +++--- toolsrc/src/vcpkg_Environment.cpp | 22 +++++++++++----------- toolsrc/src/vcpkg_System.cpp | 4 ++-- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index 6b48966402..93e1389f89 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -44,7 +44,7 @@ namespace vcpkg {namespace Strings } template - 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; return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...); diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp index 2712d3e6aa..85b98d667a 100644 --- a/toolsrc/src/commands_create.cpp +++ b/toolsrc/src/commands_create.cpp @@ -28,15 +28,15 @@ namespace vcpkg Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name), R"(Filename cannot contain invalid chars %s, but was %s)", 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")", - Strings::utf8_to_utf16(spec->name), - Strings::utf8_to_utf16(spec->target_triplet.value), - Strings::utf8_to_utf16(args.command_arguments.at(1)), - custom_filename, - paths.ports_cmake.generic_wstring()); + 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->target_triplet.value), + Strings::utf8_to_utf16(args.command_arguments.at(1)), + custom_filename, + paths.ports_cmake.generic_wstring()); exit(System::cmd_execute(cmdline)); } diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp index 71ae8b2c85..fe02bfa266 100644 --- a/toolsrc/src/commands_edit.cpp +++ b/toolsrc/src/commands_edit.cpp @@ -15,7 +15,7 @@ namespace vcpkg env_EDITOR = LR"(C:\Program Files (x86)\Microsoft VS Code\Code.exe)"; 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)); } } diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index e94791efaf..2890184fb2 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -22,12 +22,12 @@ namespace vcpkg 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 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")", - Strings::utf8_to_utf16(spec.target_triplet.architecture()), - Strings::utf8_to_utf16(spec.name), - Strings::utf8_to_utf16(spec.target_triplet.value), - port_dir.generic_wstring(), - ports_cmake_script_path.generic_wstring()); + 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.name), + Strings::utf8_to_utf16(spec.target_triplet.value), + port_dir.generic_wstring(), + ports_cmake_script_path.generic_wstring()); System::Stopwatch timer; timer.start(); @@ -39,12 +39,12 @@ namespace vcpkg { 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" - "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n" - " Package: %s\n" - " Vcpkg version: %s\n" - "\n" - "Additionally, attach any relevant sections from the log files above." - , to_string(spec), version()); + "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n" + " Package: %s\n" + " Vcpkg version: %s\n" + "\n" + "Additionally, attach any relevant sections from the log files above." + , to_string(spec), version()); TrackProperty("error", "build failed"); TrackProperty("build_error", to_string(spec)); exit(EXIT_FAILURE); diff --git a/toolsrc/src/commands_integration.cpp b/toolsrc/src/commands_integration.cpp index aa10e210bd..743a57a70e 100644 --- a/toolsrc/src/commands_integration.cpp +++ b/toolsrc/src/commands_integration.cpp @@ -238,7 +238,7 @@ namespace vcpkg 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); if (exit_code) { @@ -269,7 +269,7 @@ namespace vcpkg std::ofstream(nuspec_file_path) << create_nuspec_file(paths.root, nuget_id, nupkg_version); // 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); diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp index 610c71ed11..ada065fd6b 100644 --- a/toolsrc/src/metrics.cpp +++ b/toolsrc/src/metrics.cpp @@ -419,7 +419,7 @@ true const fs::path vcpkg_metrics_txt_path = temp_folder_path / ("vcpkg" + GenerateRandomUUID() + ".txt"); 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); } } diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 15e30ed4fa..8bd9838c69 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -219,7 +219,7 @@ namespace vcpkg std::vector dlls_with_no_exports; 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); Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); @@ -250,7 +250,7 @@ namespace vcpkg std::vector dlls_with_improper_uwp_bit; 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); Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); @@ -282,7 +282,7 @@ namespace vcpkg std::vector binaries_with_invalid_architecture; 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); Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp index f70f2b893a..d98b0f220c 100644 --- a/toolsrc/src/vcpkg_Environment.cpp +++ b/toolsrc/src/vcpkg_Environment.cpp @@ -48,11 +48,11 @@ namespace vcpkg {namespace Environment void ensure_git_on_path(const vcpkg_paths& paths) { const fs::path downloaded_git = paths.downloads / "PortableGit" / "cmd"; - const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s", - downloaded_git.native(), - System::wdupenv_str(L"PATH"), - default_git_installation_dir.native(), - default_git_installation_dir_x86.native()); + const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s", + downloaded_git.native(), + System::wdupenv_str(L"PATH"), + default_git_installation_dir.native(), + default_git_installation_dir_x86.native()); _wputenv_s(L"PATH", path_buf.c_str()); static constexpr std::array git_version = {2,0,0}; @@ -63,11 +63,11 @@ namespace vcpkg {namespace Environment void ensure_cmake_on_path(const vcpkg_paths& paths) { 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", - downloaded_cmake.native(), - System::wdupenv_str(L"PATH"), - default_cmake_installation_dir.native(), - default_cmake_installation_dir_x86.native()); + const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s", + downloaded_cmake.native(), + System::wdupenv_str(L"PATH"), + default_cmake_installation_dir.native(), + default_cmake_installation_dir_x86.native()); _wputenv_s(L"PATH", path_buf.c_str()); static constexpr std::array cmake_version = {3,5,0}; @@ -77,7 +77,7 @@ namespace vcpkg {namespace Environment 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()); static constexpr std::array nuget_version = {1,0,0}; diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 71b4087d21..4dc37857d3 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -19,14 +19,14 @@ namespace vcpkg {namespace System int cmd_execute(const wchar_t* cmd_line) { // 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()); return exit_code; } 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; char buf[1024];