diff options
| author | Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> | 2020-08-18 09:23:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-18 09:23:01 -0700 |
| commit | 0bb8780a60e67320a966421e2923595fa57cbf22 (patch) | |
| tree | 494b4a99592f5bd17195397ae3acd37d38fa9dc6 | |
| parent | d6285bc24b2e48da2f5e057fc759aff7c2b3b0af (diff) | |
| download | vcpkg-0bb8780a60e67320a966421e2923595fa57cbf22.tar.gz vcpkg-0bb8780a60e67320a966421e2923595fa57cbf22.zip | |
[vcpkg] Use std::filesystem when Visual Studio is greater than 2015 (#12774)
Co-authored-by: Nicole Mazzuca <mazzucan@outlook.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
44 files changed, 390 insertions, 364 deletions
diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h index f92792411..c8ca1ea7c 100644 --- a/toolsrc/include/pch.h +++ b/toolsrc/include/pch.h @@ -2,6 +2,7 @@ #include <vcpkg/base/system_headers.h> +#include <vcpkg/base/files.h> #include <vcpkg/base/pragmas.h> #if defined(_WIN32) @@ -23,14 +24,6 @@ #include <cctype> #include <chrono> #include <codecvt> - -#if VCPKG_USE_STD_FILESYSTEM -#include <filesystem> -#else -#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING -#include <experimental/filesystem> -#endif - #include <fstream> #include <functional> #include <iomanip> diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index a202bfdef..e0a555024 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -2,11 +2,17 @@ #include <vcpkg/base/expected.h> #include <vcpkg/base/ignore_errors.h> +#include <vcpkg/base/pragmas.h> + +#include <string.h> + +#if !defined(VCPKG_USE_STD_FILESYSTEM) +#error The build system must set VCPKG_USE_STD_FILESYSTEM. +#endif // !defined(VCPKG_USE_STD_FILESYSTEM) #if VCPKG_USE_STD_FILESYSTEM #include <filesystem> #else -#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include <experimental/filesystem> #endif @@ -22,7 +28,28 @@ namespace fs using stdfs::directory_iterator; using stdfs::path; using stdfs::perms; - using stdfs::u8path; + + path u8path(vcpkg::StringView s); + inline path u8path(const char* first, const char* last) { return u8path(vcpkg::StringView{first, last}); } + inline path u8path(const char* s) { return u8path(vcpkg::StringView{s, s + ::strlen(s)}); } + +#if defined(_MSC_VER) + inline path u8path(std::string::const_iterator first, std::string::const_iterator last) + { + if (first == last) + { + return path{}; + } + else + { + auto firstp = &*first; + return u8path(vcpkg::StringView{firstp, firstp + (last - first)}); + } + } +#endif + + std::string u8string(const path& p); + std::string generic_u8string(const path& p); #if defined(_WIN32) enum class file_type diff --git a/toolsrc/include/vcpkg/base/system.process.h b/toolsrc/include/vcpkg/base/system.process.h index b9184c05c..4bbcba717 100644 --- a/toolsrc/include/vcpkg/base/system.process.h +++ b/toolsrc/include/vcpkg/base/system.process.h @@ -25,7 +25,7 @@ namespace vcpkg::System struct CmdLineBuilder { - CmdLineBuilder& path_arg(const fs::path& p) { return string_arg(p.u8string()); } + CmdLineBuilder& path_arg(const fs::path& p) { return string_arg(fs::u8string(p)); } CmdLineBuilder& string_arg(StringView s); CmdLineBuilder& ampersand() { diff --git a/toolsrc/src/vcpkg-test/commands.build.cpp b/toolsrc/src/vcpkg-test/commands.build.cpp index 88749e7fe..76b205426 100644 --- a/toolsrc/src/vcpkg-test/commands.build.cpp +++ b/toolsrc/src/vcpkg-test/commands.build.cpp @@ -21,11 +21,11 @@ TEST_CASE ("build smoke test", "[commands-build]") VcpkgCmdArguments args = VcpkgCmdArguments::create_from_arg_sequence(std::begin(args_raw), std::end(args_raw)); args.binary_caching = false; args.buildtrees_root_dir = - std::make_unique<std::string>((Test::base_temporary_directory() / fs::u8path("buildtrees")).u8string()); + std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("buildtrees"))); args.install_root_dir = - std::make_unique<std::string>((Test::base_temporary_directory() / fs::u8path("installed")).u8string()); + std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("installed"))); args.packages_root_dir = - std::make_unique<std::string>((Test::base_temporary_directory() / fs::u8path("packages")).u8string()); + std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("packages"))); VcpkgPaths paths(fs_wrapper, args); if (fs_wrapper.exists(paths.buildtrees)) fs_wrapper.remove_all_inside(paths.buildtrees, VCPKG_LINE_INFO); if (fs_wrapper.exists(paths.packages)) fs_wrapper.remove_all_inside(paths.packages, VCPKG_LINE_INFO); diff --git a/toolsrc/src/vcpkg-test/files.cpp b/toolsrc/src/vcpkg-test/files.cpp index bc617d326..255c87d69 100644 --- a/toolsrc/src/vcpkg-test/files.cpp +++ b/toolsrc/src/vcpkg-test/files.cpp @@ -125,7 +125,7 @@ namespace { // regular symlink auto base_link = base; - base_link.replace_filename(base.filename().u8string() + "-orig"); + base_link.replace_filename(fs::u8string(base.filename()) + "-orig"); fs.write_contents(base_link, "", ec); CHECK_EC_ON_FILE(base_link, ec); vcpkg::Test::create_symlink(base_link, base, ec); diff --git a/toolsrc/src/vcpkg-test/manifests.cpp b/toolsrc/src/vcpkg-test/manifests.cpp index 95a0b149b..9a0ca94e2 100644 --- a/toolsrc/src/vcpkg-test/manifests.cpp +++ b/toolsrc/src/vcpkg-test/manifests.cpp @@ -264,7 +264,7 @@ TEST_CASE ("Serialize all the ports", "[manifests]") if (fs.exists(control)) { auto contents = fs.read_contents(control, VCPKG_LINE_INFO); - auto pghs = Paragraphs::parse_paragraphs(contents, control.u8string()); + auto pghs = Paragraphs::parse_paragraphs(contents, fs::u8string(control)); REQUIRE(pghs); scfs.push_back(std::move( diff --git a/toolsrc/src/vcpkg/archives.cpp b/toolsrc/src/vcpkg/archives.cpp index c90706928..41a70e996 100644 --- a/toolsrc/src/vcpkg/archives.cpp +++ b/toolsrc/src/vcpkg/archives.cpp @@ -9,7 +9,7 @@ namespace vcpkg::Archives void extract_archive(const VcpkgPaths& paths, const fs::path& archive, const fs::path& to_path) { Files::Filesystem& fs = paths.get_filesystem(); - const fs::path to_path_partial = to_path.u8string() + ".partial" + const fs::path to_path_partial = fs::u8string(to_path) + ".partial" #if defined(_WIN32) + "." + std::to_string(GetCurrentProcessId()) #endif @@ -29,7 +29,7 @@ namespace vcpkg::Archives recursion_limiter_sevenzip_old = true; const auto nuget_exe = paths.get_tool_exe(Tools::NUGET); - const std::string stem = archive.stem().u8string(); + const std::string stem = fs::u8string(archive.stem()); // assuming format of [name].[version in the form d.d.d] // This assumption may not always hold std::smatch match; @@ -37,23 +37,23 @@ namespace vcpkg::Archives Checks::check_exit(VCPKG_LINE_INFO, has_match, "Could not deduce nuget id and version from filename: %s", - archive.u8string()); + fs::u8string(archive)); const std::string nugetid = match[1]; const std::string version = match[2]; const auto code_and_output = System::cmd_execute_and_capture_output(Strings::format( R"("%s" install %s -Version %s -OutputDirectory "%s" -Source "%s" -nocache -DirectDownload -NonInteractive -ForceEnglishOutput -PackageSaveMode nuspec)", - nuget_exe.u8string(), + fs::u8string(nuget_exe), nugetid, version, - to_path_partial.u8string(), - paths.downloads.u8string())); + fs::u8string(to_path_partial), + fs::u8string(paths.downloads))); Checks::check_exit(VCPKG_LINE_INFO, code_and_output.exit_code == 0, "Failed to extract '%s' with message:\n%s", - archive.u8string(), + fs::u8string(archive), code_and_output.output); recursion_limiter_sevenzip_old = false; } @@ -63,12 +63,15 @@ namespace vcpkg::Archives Checks::check_exit(VCPKG_LINE_INFO, !recursion_limiter_sevenzip); recursion_limiter_sevenzip = true; const auto seven_zip = paths.get_tool_exe(Tools::SEVEN_ZIP); - const auto code_and_output = System::cmd_execute_and_capture_output(Strings::format( - R"("%s" x "%s" -o"%s" -y)", seven_zip.u8string(), archive.u8string(), to_path_partial.u8string())); + const auto code_and_output = + System::cmd_execute_and_capture_output(Strings::format(R"("%s" x "%s" -o"%s" -y)", + fs::u8string(seven_zip), + fs::u8string(archive), + fs::u8string(to_path_partial))); Checks::check_exit(VCPKG_LINE_INFO, code_and_output.exit_code == 0, "7zip failed while extracting '%s' with message:\n%s", - archive.u8string(), + fs::u8string(archive), code_and_output.output); recursion_limiter_sevenzip = false; } @@ -76,18 +79,18 @@ namespace vcpkg::Archives if (ext == ".gz" && ext.extension() != ".tar") { const auto code = System::cmd_execute( - Strings::format(R"(cd '%s' && tar xzf '%s')", to_path_partial.u8string(), archive.u8string())); - Checks::check_exit(VCPKG_LINE_INFO, code == 0, "tar failed while extracting %s", archive.u8string()); + Strings::format(R"(cd '%s' && tar xzf '%s')", fs::u8string(to_path_partial), fs::u8string(archive))); + Checks::check_exit(VCPKG_LINE_INFO, code == 0, "tar failed while extracting %s", fs::u8string(archive)); } else if (ext == ".zip") { const auto code = System::cmd_execute( - Strings::format(R"(cd '%s' && unzip -qqo '%s')", to_path_partial.u8string(), archive.u8string())); - Checks::check_exit(VCPKG_LINE_INFO, code == 0, "unzip failed while extracting %s", archive.u8string()); + Strings::format(R"(cd '%s' && unzip -qqo '%s')", fs::u8string(to_path_partial), fs::u8string(archive))); + Checks::check_exit(VCPKG_LINE_INFO, code == 0, "unzip failed while extracting %s", fs::u8string(archive)); } else { - Checks::exit_with_message(VCPKG_LINE_INFO, "Unexpected archive extension: %s", ext.u8string()); + Checks::exit_with_message(VCPKG_LINE_INFO, "Unexpected archive extension: %s", fs::u8string(ext)); } #endif @@ -105,8 +108,8 @@ namespace vcpkg::Archives !ec, "Failed to do post-extract rename-in-place.\n" "fs.rename(%s, %s, %s)", - to_path_partial.u8string(), - to_path.u8string(), + fs::u8string(to_path_partial), + fs::u8string(to_path), ec.message()); } } diff --git a/toolsrc/src/vcpkg/base/downloads.cpp b/toolsrc/src/vcpkg/base/downloads.cpp index 596697499..40f0494f9 100644 --- a/toolsrc/src/vcpkg/base/downloads.cpp +++ b/toolsrc/src/vcpkg/base/downloads.cpp @@ -20,7 +20,7 @@ namespace vcpkg::Downloads const auto dir = fs::path(target_file_path.c_str()).parent_path(); std::error_code ec; fs.create_directories(dir, ec); - Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directories %s", dir.u8string()); + Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directories %s", fs::u8string(dir)); FILE* f = nullptr; const errno_t err = fopen_s(&f, target_file_path.c_str(), "wb"); @@ -162,7 +162,7 @@ namespace vcpkg::Downloads " Expected hash : [ %s ]\n" " Actual hash : [ %s ]\n", url, - path.u8string(), + fs::u8string(path), sha512, actual_hash); } @@ -172,7 +172,7 @@ namespace vcpkg::Downloads const fs::path& download_path, const std::string& sha512) { - const std::string download_path_part = download_path.u8string() + ".part"; + const std::string download_path_part = fs::u8string(download_path) + ".part"; auto download_path_part_path = fs::u8path(download_path_part); std::error_code ec; fs.remove(download_path, ec); diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index e4c821eae..c6c7a0dee 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -18,6 +18,32 @@ #include <copyfile.h> #endif // ^^^ defined(__APPLE__) +fs::path fs::u8path(vcpkg::StringView s) +{ +#if defined(_WIN32) + return fs::path(vcpkg::Strings::to_utf16(s)); +#else + return fs::path(s.begin(), s.end()); +#endif +} + +std::string fs::u8string(const fs::path& p) +{ +#if defined(_WIN32) + return vcpkg::Strings::to_utf8(p.native()); +#else + return p.native(); +#endif +} +std::string fs::generic_u8string(const fs::path& p) +{ +#if defined(_WIN32) + return vcpkg::Strings::to_utf8(p.generic_wstring()); +#else + return p.generic_string(); +#endif +} + namespace vcpkg::Files { static const std::regex FILESYSTEM_INVALID_CHARACTERS_REGEX = std::regex(R"([\/:*?"<>|])"); @@ -131,7 +157,7 @@ namespace vcpkg::Files CloseHandle(handle); return target; } -#endif // ^^^ !defined(_WIN32) || VCPKG_USE_STD_FILESYSTEM +#endif // ^^^ defined(_WIN32) && !VCPKG_USE_STD_FILESYSTEM void copy_symlink_implementation(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) { @@ -205,13 +231,13 @@ namespace vcpkg::Files return std::move(*p); else Checks::exit_with_message( - linfo, "error reading file: %s: %s", path.u8string(), maybe_contents.error().message()); + linfo, "error reading file: %s: %s", fs::u8string(path), maybe_contents.error().message()); } void Filesystem::write_contents(const fs::path& path, const std::string& data, LineInfo linfo) { std::error_code ec; this->write_contents(path, data, ec); - if (ec) Checks::exit_with_message(linfo, "error writing file: %s: %s", path.u8string(), ec.message()); + if (ec) Checks::exit_with_message(linfo, "error writing file: %s: %s", fs::u8string(path), ec.message()); } void Filesystem::rename(const fs::path& oldpath, const fs::path& newpath, LineInfo linfo) { @@ -219,14 +245,14 @@ namespace vcpkg::Files this->rename(oldpath, newpath, ec); if (ec) Checks::exit_with_message( - linfo, "error renaming file: %s: %s: %s", oldpath.u8string(), newpath.u8string(), ec.message()); + linfo, "error renaming file: %s: %s: %s", fs::u8string(oldpath), fs::u8string(newpath), ec.message()); } bool Filesystem::remove(const fs::path& path, LineInfo linfo) { std::error_code ec; auto r = this->remove(path, ec); - if (ec) Checks::exit_with_message(linfo, "error removing file: %s: %s", path.u8string(), ec.message()); + if (ec) Checks::exit_with_message(linfo, "error removing file: %s: %s", fs::u8string(path), ec.message()); return r; } @@ -245,7 +271,8 @@ namespace vcpkg::Files { std::error_code ec; auto result = this->exists(path, ec); - if (ec) Checks::exit_with_message(li, "error checking existence of file %s: %s", path.u8string(), ec.message()); + if (ec) + Checks::exit_with_message(li, "error checking existence of file %s: %s", fs::u8string(path), ec.message()); return result; } @@ -267,7 +294,7 @@ namespace vcpkg::Files bool result = this->create_directory(path, ec); if (ec) { - vcpkg::Checks::exit_with_message(li, "error creating directory %s", path.u8string(), ec.message()); + vcpkg::Checks::exit_with_message(li, "error creating directory %s", fs::u8string(path), ec.message()); } return result; @@ -285,7 +312,7 @@ namespace vcpkg::Files bool result = this->create_directories(path, ec); if (ec) { - vcpkg::Checks::exit_with_message(li, "error creating directories %s", path.u8string(), ec.message()); + vcpkg::Checks::exit_with_message(li, "error creating directories %s", fs::u8string(path), ec.message()); } return result; @@ -297,7 +324,7 @@ namespace vcpkg::Files this->copy_file(oldpath, newpath, opts, ec); if (ec) vcpkg::Checks::exit_with_message( - li, "error copying file from %s to %s: %s", oldpath.u8string(), newpath.u8string(), ec.message()); + li, "error copying file from %s to %s: %s", fs::u8string(oldpath), fs::u8string(newpath), ec.message()); } fs::file_status Filesystem::status(vcpkg::LineInfo li, const fs::path& p) const noexcept @@ -334,7 +361,7 @@ namespace vcpkg::Files { std::error_code ec; this->write_lines(path, lines, ec); - if (ec) Checks::exit_with_message(linfo, "error writing lines: %s: %s", path.u8string(), ec.message()); + if (ec) Checks::exit_with_message(linfo, "error writing lines: %s: %s", fs::u8string(path), ec.message()); } void Filesystem::remove_all(const fs::path& path, LineInfo li) @@ -708,7 +735,7 @@ namespace vcpkg::Files fs::stdfs::remove(current_path, ec); if (check_ec(ec, current_path, err)) return; } -#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv +#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv #if defined(_WIN32) else if (path_type == fs::file_type::directory_symlink) { @@ -900,7 +927,7 @@ namespace vcpkg::Files { #if VCPKG_USE_STD_FILESYSTEM return fs::stdfs::absolute(path, ec); -#else // ^^^ VCPKG_USE_STD_FILESYSTEM / !VCPKG_USE_STD_FILESYSTEM vvv +#else // ^^^ VCPKG_USE_STD_FILESYSTEM / !VCPKG_USE_STD_FILESYSTEM vvv #if defined(_WIN32) // absolute was called system_complete in experimental filesystem return fs::stdfs::system_complete(path, ec); @@ -1017,7 +1044,7 @@ namespace vcpkg::Files return res; } - System::printf("Waiting to take filesystem lock on %s...\n", path.u8string()); + System::printf("Waiting to take filesystem lock on %s...\n", fs::u8string(path)); const auto wait = std::chrono::milliseconds(1000); for (;;) { @@ -1039,7 +1066,7 @@ namespace vcpkg::Files return res; } - Debug::print("Waiting to take filesystem lock on ", path.u8string(), "...\n"); + Debug::print("Waiting to take filesystem lock on ", fs::u8string(path), "...\n"); auto wait = std::chrono::milliseconds(100); // waits, at most, a second and a half. while (wait < std::chrono::milliseconds(1000)) @@ -1092,7 +1119,7 @@ namespace vcpkg::Files if (Util::find(ret, p) == ret.end() && this->exists(p, ec)) { ret.push_back(p); - Debug::print("Found path: ", p.u8string(), '\n'); + Debug::print("Found path: ", fs::u8string(p), '\n'); } } } diff --git a/toolsrc/src/vcpkg/base/json.cpp b/toolsrc/src/vcpkg/base/json.cpp index 0a9422d66..62f50f9d0 100644 --- a/toolsrc/src/vcpkg/base/json.cpp +++ b/toolsrc/src/vcpkg/base/json.cpp @@ -1005,7 +1005,7 @@ namespace vcpkg::Json ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<Parse::IParseError>> parse(StringView json, const fs::path& filepath) noexcept { - return Parser::parse(json, filepath.generic_u8string()); + return Parser::parse(json, fs::generic_u8string(filepath)); } // } auto parse() diff --git a/toolsrc/src/vcpkg/base/system.process.cpp b/toolsrc/src/vcpkg/base/system.process.cpp index ee2dd1b3f..c78838caf 100644 --- a/toolsrc/src/vcpkg/base/system.process.cpp +++ b/toolsrc/src/vcpkg/base/system.process.cpp @@ -173,7 +173,7 @@ namespace vcpkg { } System::CMakeVariable::CMakeVariable(const StringView varname, const fs::path& path) - : CMakeVariable(varname, path.generic_u8string()) + : CMakeVariable(varname, fs::generic_u8string(path)) { } diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp index 2c6f0fe98..2cd9d1101 100644 --- a/toolsrc/src/vcpkg/binarycaching.cpp +++ b/toolsrc/src/vcpkg/binarycaching.cpp @@ -26,14 +26,16 @@ namespace std::error_code ec; fs.create_directories(pkg_path, ec); auto files = fs.get_files_non_recursive(pkg_path); - Checks::check_exit(VCPKG_LINE_INFO, files.empty(), "unable to clear path: %s", pkg_path.u8string()); + Checks::check_exit(VCPKG_LINE_INFO, files.empty(), "unable to clear path: %s", fs::u8string(pkg_path)); #if defined(_WIN32) auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP); - auto cmd = Strings::format( - R"("%s" x "%s" -o"%s" -y)", seven_zip_exe.u8string(), archive_path.u8string(), pkg_path.u8string()); + auto cmd = Strings::format(R"("%s" x "%s" -o"%s" -y)", + fs::u8string(seven_zip_exe), + fs::u8string(archive_path), + fs::u8string(pkg_path)); #else - auto cmd = Strings::format(R"(unzip -qq "%s" "-d%s")", archive_path.u8string(), pkg_path.u8string()); + auto cmd = Strings::format(R"(unzip -qq "%s" "-d%s")", fs::u8string(archive_path), fs::u8string(pkg_path)); #endif return System::cmd_execute_and_capture_output(cmd, System::get_clean_environment()); } @@ -47,17 +49,17 @@ namespace fs.remove(destination, ec); Checks::check_exit( - VCPKG_LINE_INFO, !fs.exists(destination), "Could not remove file: %s", destination.u8string()); + VCPKG_LINE_INFO, !fs.exists(destination), "Could not remove file: %s", fs::u8string(destination)); #if defined(_WIN32) auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP); System::cmd_execute_and_capture_output( Strings::format( - R"("%s" a "%s" "%s\*")", seven_zip_exe.u8string(), destination.u8string(), source.u8string()), + R"("%s" a "%s" "%s\*")", fs::u8string(seven_zip_exe), fs::u8string(destination), fs::u8string(source)), System::get_clean_environment()); #else System::cmd_execute_clean( - Strings::format(R"(cd '%s' && zip --quiet -r '%s' *)", source.u8string(), destination.u8string())); + Strings::format(R"(cd '%s' && zip --quiet -r '%s' *)", fs::u8string(source), fs::u8string(destination))); #endif } @@ -82,7 +84,7 @@ namespace const fs::path archive_path = archives_root_dir / archive_subpath; if (fs.exists(archive_path)) { - System::print2("Using cached binary package: ", archive_path.u8string(), "\n"); + System::print2("Using cached binary package: ", fs::u8string(archive_path), "\n"); int archive_result = decompress_archive(paths, spec, archive_path).exit_code; @@ -105,7 +107,7 @@ namespace } } - System::printf("Could not locate cached archive: %s\n", archive_path.u8string()); + System::printf("Could not locate cached archive: %s\n", fs::u8string(archive_path)); } return RestoreResult::missing; @@ -136,11 +138,11 @@ namespace { System::printf(System::Color::warning, "Failed to store binary cache %s: %s\n", - archive_path.u8string(), + fs::u8string(archive_path), ec.message()); } else - System::printf("Stored binary cache: %s\n", archive_path.u8string()); + System::printf("Stored binary cache: %s\n", fs::u8string(archive_path)); } if (m_write_dirs.size() > 1) fs.remove(tmp_archive_path, ignore_errors); } @@ -322,7 +324,7 @@ namespace Checks::check_exit(VCPKG_LINE_INFO, !fs.exists(nupkg_path, ignore_errors), "Unable to remove nupkg after restoring: %s", - nupkg_path.u8string()); + fs::u8string(nupkg_path)); m_restored.emplace(nuget_ref.first); ++num_restored; return true; @@ -431,7 +433,7 @@ namespace if (!m_interactive) cmd.string_arg("-NonInteractive"); System::print2( - "Uploading binaries for ", spec, " using NuGet config ", write_cfg.u8string(), ".\n"); + "Uploading binaries for ", spec, " using NuGet config ", fs::u8string(write_cfg), ".\n"); auto rc = [&] { if (Debug::g_debugging) @@ -444,7 +446,7 @@ namespace { System::print2(System::Color::error, "Pushing NuGet with ", - write_cfg.u8string(), + fs::u8string(write_cfg), " failed. Use --debug for more information.\n"); } } @@ -668,15 +670,15 @@ namespace const auto path = fs::u8path(*p_str); const auto status = fs::stdfs::status(path); if (!fs::stdfs::exists(status)) - return {"Path to VCPKG_DEFAULT_BINARY_CACHE does not exist: " + path.u8string(), + return {"Path to VCPKG_DEFAULT_BINARY_CACHE does not exist: " + fs::u8string(path), expected_right_tag}; if (!fs::stdfs::is_directory(status)) return {"Value of environment variable VCPKG_DEFAULT_BINARY_CACHE is not a directory: " + - path.u8string(), + fs::u8string(path), expected_right_tag}; if (!path.is_absolute()) return {"Value of environment variable VCPKG_DEFAULT_BINARY_CACHE is not absolute: " + - path.u8string(), + fs::u8string(path), expected_right_tag}; return ExpectedS<fs::path>(path); } @@ -687,11 +689,11 @@ namespace } else { - return {"default path was not absolute: " + p.u8string(), expected_right_tag}; + return {"default path was not absolute: " + fs::u8string(p), expected_right_tag}; } }); if (cachepath.has_value()) - Debug::print("Default binary cache path is: ", cachepath.get()->u8string(), '\n'); + Debug::print("Default binary cache path is: ", fs::u8string(*cachepath.get()), '\n'); else Debug::print("No binary cache path. Reason: ", cachepath.error(), '\n'); return cachepath; @@ -1007,7 +1009,7 @@ std::string vcpkg::generate_nuspec(const VcpkgPaths& paths, xml.close_tag("metadata").line_break(); xml.open_tag("files"); xml.start_complex_open_tag("file") - .text_attr("src", (paths.package_dir(spec) / fs::u8path("**")).u8string()) + .text_attr("src", fs::u8string(paths.package_dir(spec) / fs::u8path("**"))) .text_attr("target", "") .finish_self_closing_complex_tag(); xml.close_tag("files").line_break(); @@ -1052,7 +1054,7 @@ void vcpkg::help_topic_binary_caching(const VcpkgPaths&) auto p_preferred = *p; System::print2( "\nBased on your system settings, the default path to store binaries is\n ", - p_preferred.make_preferred().u8string(), + fs::u8string(p_preferred.make_preferred()), "\n\nThis consults %LOCALAPPDATA%/%APPDATA% on Windows and $XDG_CACHE_HOME or $HOME on other platforms."); } } diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 2eb188cc1..4c78b7b1d 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -332,8 +332,8 @@ namespace vcpkg::Build powershell_exe_path, powershell_exe_path.parent_path() / "powershell.exe", fs::copy_options::none); } - auto clean_env = System::get_modified_clean_environment(base_env.env_map, - powershell_exe_path.parent_path().u8string() + ";"); + auto clean_env = System::get_modified_clean_environment( + base_env.env_map, fs::u8string(powershell_exe_path.parent_path()) + ";"); if (build_env_cmd.empty()) return clean_env; else @@ -390,7 +390,7 @@ namespace vcpkg::Build 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")", - toolset.vcvarsall.u8string(), + fs::u8string(toolset.vcvarsall), Strings::join(" ", toolset.vcvarsall_options), arch, target, @@ -452,7 +452,7 @@ namespace vcpkg::Build std::initializer_list<System::CMakeVariable>{ {"CMD", "BUILD"}, {"TARGET_TRIPLET", triplet.canonical_name()}, - {"TARGET_TRIPLET_FILE", paths.get_triplet_file_path(triplet).u8string()}, + {"TARGET_TRIPLET_FILE", fs::u8string(paths.get_triplet_file_path(triplet))}, {"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()}, {"DOWNLOADS", paths.downloads}, {"VCPKG_CONCURRENCY", std::to_string(get_concurrency())}, @@ -493,12 +493,12 @@ namespace vcpkg::Build Checks::check_exit(VCPKG_LINE_INFO, !err.value(), "Failed to create directory '%s', code: %d", - buildpath.u8string(), + fs::u8string(buildpath), err.value()); } auto stdoutlog = buildpath / ("stdout-" + triplet.canonical_name() + ".log"); std::ofstream out_file(stdoutlog.native().c_str(), std::ios::out | std::ios::binary | std::ios::trunc); - Checks::check_exit(VCPKG_LINE_INFO, out_file, "Failed to open '%s' for writing", stdoutlog.u8string()); + Checks::check_exit(VCPKG_LINE_INFO, out_file, "Failed to open '%s' for writing", fs::u8string(stdoutlog)); std::string compiler_hash; System::cmd_execute_and_stream_lines( command, @@ -511,7 +511,7 @@ namespace vcpkg::Build Debug::print(s, '\n'); out_file.write(s.data(), s.size()).put('\n'); Checks::check_exit( - VCPKG_LINE_INFO, out_file, "Error occurred while writing '%s'", stdoutlog.u8string()); + VCPKG_LINE_INFO, out_file, "Error occurred while writing '%s'", fs::u8string(stdoutlog)); }, env); out_file.close(); @@ -582,7 +582,7 @@ namespace vcpkg::Build if (fs.is_regular_file(port_config_path)) { - port_configs.emplace_back(port_config_path.u8string()); + port_configs.emplace_back(fs::u8string(port_config_path)); } } @@ -651,22 +651,22 @@ namespace vcpkg::Build auto&& scfl = action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO); Triplet triplet = action.spec.triplet(); - const auto& triplet_file_path = paths.get_triplet_file_path(triplet).u8string(); + const auto& triplet_file_path = fs::u8string(paths.get_triplet_file_path(triplet)); - if (Strings::case_insensitive_ascii_starts_with(triplet_file_path, paths.community_triplets.u8string())) + if (Strings::case_insensitive_ascii_starts_with(triplet_file_path, fs::u8string(paths.community_triplets))) { System::printf(vcpkg::System::Color::warning, "-- Using community triplet %s. This triplet configuration is not guaranteed to succeed.\n", triplet.canonical_name()); System::printf("-- [COMMUNITY] Loading triplet configuration from: %s\n", triplet_file_path); } - else if (!Strings::case_insensitive_ascii_starts_with(triplet_file_path, paths.triplets.u8string())) + else if (!Strings::case_insensitive_ascii_starts_with(triplet_file_path, fs::u8string(paths.triplets))) { System::printf("-- [OVERLAY] Loading triplet configuration from: %s\n", triplet_file_path); } - auto u8portdir = scfl.source_location.u8string(); - if (!Strings::case_insensitive_ascii_starts_with(u8portdir, paths.ports.u8string())) + auto u8portdir = fs::u8string(scfl.source_location); + if (!Strings::case_insensitive_ascii_starts_with(u8portdir, fs::u8string(paths.ports))) { System::printf("-- Installing port from location: %s\n", u8portdir); } @@ -685,19 +685,19 @@ namespace vcpkg::Build Checks::check_exit(VCPKG_LINE_INFO, !err.value(), "Failed to create directory '%s', code: %d", - buildpath.u8string(), + fs::u8string(buildpath), err.value()); } auto stdoutlog = buildpath / ("stdout-" + action.spec.triplet().canonical_name() + ".log"); std::ofstream out_file(stdoutlog.native().c_str(), std::ios::out | std::ios::binary | std::ios::trunc); - Checks::check_exit(VCPKG_LINE_INFO, out_file, "Failed to open '%s' for writing", stdoutlog.u8string()); + Checks::check_exit(VCPKG_LINE_INFO, out_file, "Failed to open '%s' for writing", fs::u8string(stdoutlog)); const int return_code = System::cmd_execute_and_stream_data( command, [&](StringView sv) { System::print2(sv); out_file.write(sv.data(), sv.size()); Checks::check_exit( - VCPKG_LINE_INFO, out_file, "Error occurred while writing '%s'", stdoutlog.u8string()); + VCPKG_LINE_INFO, out_file, "Error occurred while writing '%s'", fs::u8string(stdoutlog)); }, env); out_file.close(); @@ -836,7 +836,7 @@ namespace vcpkg::Build if (fs::is_regular_file(fs.status(VCPKG_LINE_INFO, port_file))) { abi_tag_entries.emplace_back( - port_file.path().filename().u8string(), + fs::u8string(port_file.path().filename()), vcpkg::Hash::get_file_hash(VCPKG_LINE_INFO, fs, port_file, Hash::Algorithm::Sha1)); ++port_file_count; @@ -1042,7 +1042,7 @@ namespace vcpkg::Build fs.create_directories(abi_package_dir, ec); fs.copy_file(abi_file, abi_file_in_package, fs::copy_options::none, ec); - Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not copy into file: %s", abi_file_in_package.u8string()); + Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not copy into file: %s", fs::u8string(abi_file_in_package)); if (action.build_options.editable == Build::Editable::NO && result.code == BuildResult::SUCCEEDED) { diff --git a/toolsrc/src/vcpkg/cmakevars.cpp b/toolsrc/src/vcpkg/cmakevars.cpp index 7c5078d3b..ef9906a08 100644 --- a/toolsrc/src/vcpkg/cmakevars.cpp +++ b/toolsrc/src/vcpkg/cmakevars.cpp @@ -76,7 +76,7 @@ namespace vcpkg::CMakeVars Files::Filesystem& fs = paths.get_filesystem(); static int tag_extract_id = 0; - std::string extraction_file("include(\"" + get_tags_path.generic_u8string() + "\")\n\n"); + std::string extraction_file("include(\"" + fs::generic_u8string(get_tags_path) + "\")\n\n"); std::map<Triplet, int> emitted_triplets; int emitted_triplet_id = 0; @@ -124,7 +124,7 @@ namespace vcpkg::CMakeVars static int dep_info_id = 0; Files::Filesystem& fs = paths.get_filesystem(); - std::string extraction_file("include(\"" + get_dep_info_path.generic_u8string() + "\")\n\n"); + std::string extraction_file("include(\"" + fs::generic_u8string(get_dep_info_path) + "\")\n\n"); std::map<Triplet, int> emitted_triplets; int emitted_triplet_id = 0; @@ -258,7 +258,7 @@ namespace vcpkg::CMakeVars { auto& scfl = port_provider.get_control_file(spec.package_spec.name()).value_or_exit(VCPKG_LINE_INFO); const fs::path override_path = scfl.source_location / "vcpkg-abi-settings.cmake"; - spec_abi_settings.emplace_back(&spec, override_path.generic_u8string()); + spec_abi_settings.emplace_back(&spec, fs::generic_u8string(override_path)); } std::vector<std::vector<std::pair<std::string, std::string>>> vars(spec_abi_settings.size()); diff --git a/toolsrc/src/vcpkg/commands.ciclean.cpp b/toolsrc/src/vcpkg/commands.ciclean.cpp index 21ae756ed..c26bd12fc 100644 --- a/toolsrc/src/vcpkg/commands.ciclean.cpp +++ b/toolsrc/src/vcpkg/commands.ciclean.cpp @@ -14,12 +14,12 @@ namespace using vcpkg::System::print2; if (fs.is_directory(target)) { - print2("Clearing contents of ", target.u8string(), "\n"); + print2("Clearing contents of ", fs::u8string(target), "\n"); fs.remove_all_inside(target, VCPKG_LINE_INFO); } else { - print2("Skipping clearing contents of ", target.u8string(), " because it was not a directory\n"); + print2("Skipping clearing contents of ", fs::u8string(target), " because it was not a directory\n"); } } } diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp index b66e8c680..067b753de 100644 --- a/toolsrc/src/vcpkg/commands.edit.cpp +++ b/toolsrc/src/vcpkg/commands.edit.cpp @@ -121,16 +121,16 @@ namespace vcpkg::Commands::Edit std::string package_paths; for (auto&& package : packages) { - if (Strings::case_insensitive_ascii_starts_with(package.filename().u8string(), pattern)) + if (Strings::case_insensitive_ascii_starts_with(fs::u8string(package.filename()), pattern)) { - package_paths.append(Strings::format(" \"%s\"", package.u8string())); + package_paths.append(Strings::format(" \"%s\"", fs::u8string(package))); } } return Strings::format(R"###("%s" "%s" "%s"%s)###", - portpath.u8string(), - portfile.u8string(), - buildtrees_current_dir.u8string(), + fs::u8string(portpath), + fs::u8string(portfile), + fs::u8string(buildtrees_current_dir), package_paths); }); } @@ -138,14 +138,14 @@ namespace vcpkg::Commands::Edit if (Util::Sets::contains(options.switches, OPTION_BUILDTREES)) { return Util::fmap(ports, [&](const std::string& port_name) -> std::string { - return Strings::format(R"###("%s")###", paths.build_dir(port_name).u8string()); + return Strings::format(R"###("%s")###", fs::u8string(paths.build_dir(port_name))); }); } return Util::fmap(ports, [&](const std::string& port_name) -> std::string { const auto portpath = paths.ports / port_name; const auto portfile = portpath / "portfile.cmake"; - return Strings::format(R"###("%s" "%s")###", portpath.u8string(), portfile.u8string()); + return Strings::format(R"###("%s" "%s")###", fs::u8string(portpath), fs::u8string(portfile)); }); } @@ -252,9 +252,9 @@ namespace vcpkg::Commands::Edit const fs::path env_editor = *it; const std::vector<std::string> arguments = create_editor_arguments(paths, options, ports); const auto args_as_string = Strings::join(" ", arguments); - const auto cmd_line = Strings::format(R"("%s" %s -n)", env_editor.u8string(), args_as_string); + const auto cmd_line = Strings::format(R"("%s" %s -n)", fs::u8string(env_editor), args_as_string); - auto editor_exe = env_editor.filename().u8string(); + auto editor_exe = fs::u8string(env_editor.filename()); #ifdef _WIN32 if (editor_exe == "Code.exe" || editor_exe == "Code - Insiders.exe") diff --git a/toolsrc/src/vcpkg/commands.env.cpp b/toolsrc/src/vcpkg/commands.env.cpp index a82523060..fc6a82ef1 100644 --- a/toolsrc/src/vcpkg/commands.env.cpp +++ b/toolsrc/src/vcpkg/commands.env.cpp @@ -56,20 +56,22 @@ namespace vcpkg::Commands::Env const bool add_python = Util::Sets::contains(options.switches, OPTION_PYTHON); std::vector<std::string> path_vars; - if (add_bin) path_vars.push_back((paths.installed / triplet.to_string() / "bin").u8string()); - if (add_debug_bin) path_vars.push_back((paths.installed / triplet.to_string() / "debug" / "bin").u8string()); - if (add_include) extra_env.emplace("INCLUDE", (paths.installed / triplet.to_string() / "include").u8string()); + if (add_bin) path_vars.push_back(fs::u8string(paths.installed / triplet.to_string() / "bin")); + if (add_debug_bin) path_vars.push_back(fs::u8string(paths.installed / triplet.to_string() / "debug" / "bin")); + if (add_include) extra_env.emplace("INCLUDE", fs::u8string(paths.installed / triplet.to_string() / "include")); if (add_tools) { auto tools_dir = paths.installed / triplet.to_string() / "tools"; auto tool_files = fs.get_files_non_recursive(tools_dir); - path_vars.push_back(tools_dir.u8string()); + path_vars.push_back(fs::u8string(tools_dir)); for (auto&& tool_dir : tool_files) { - if (fs.is_directory(tool_dir)) path_vars.push_back(tool_dir.u8string()); + if (fs.is_directory(tool_dir)) path_vars.push_back(fs::u8string(tool_dir)); } } - if (add_python) extra_env.emplace("PYTHONPATH", (paths.installed / triplet.to_string() / "python").u8string()); + if (add_python) + extra_env.emplace("PYTHONPATH", + fs::u8string(paths.installed / fs::u8path(triplet.to_string()) / fs::u8path("python"))); if (path_vars.size() > 0) extra_env.emplace("PATH", Strings::join(";", path_vars)); auto env = [&] { diff --git a/toolsrc/src/vcpkg/commands.fetch.cpp b/toolsrc/src/vcpkg/commands.fetch.cpp index e6e59a30c..313d90b4f 100644 --- a/toolsrc/src/vcpkg/commands.fetch.cpp +++ b/toolsrc/src/vcpkg/commands.fetch.cpp @@ -18,7 +18,7 @@ namespace vcpkg::Commands::Fetch const std::string tool = args.command_arguments[0]; const fs::path tool_path = paths.get_tool_exe(tool); - System::print2(tool_path.u8string(), '\n'); + System::print2(fs::u8string(tool_path), '\n'); Checks::exit_success(VCPKG_LINE_INFO); } diff --git a/toolsrc/src/vcpkg/commands.format-manifest.cpp b/toolsrc/src/vcpkg/commands.format-manifest.cpp index 656e17996..61465b13e 100644 --- a/toolsrc/src/vcpkg/commands.format-manifest.cpp +++ b/toolsrc/src/vcpkg/commands.format-manifest.cpp @@ -22,7 +22,7 @@ namespace Optional<ToWrite> read_manifest(Files::Filesystem& fs, fs::path&& manifest_path) { - auto path_string = manifest_path.u8string(); + auto path_string = fs::u8string(manifest_path); Debug::print("Reading ", path_string, "\n"); auto contents = fs.read_contents(manifest_path, VCPKG_LINE_INFO); auto parsed_json_opt = Json::parse(contents, manifest_path); @@ -59,7 +59,7 @@ namespace Optional<ToWrite> read_control_file(Files::Filesystem& fs, fs::path&& control_path) { std::error_code ec; - auto control_path_string = control_path.u8string(); + auto control_path_string = fs::u8string(control_path); Debug::print("Reading ", control_path_string, "\n"); auto manifest_path = control_path.parent_path(); @@ -95,8 +95,8 @@ namespace void write_file(Files::Filesystem& fs, const ToWrite& data) { - auto original_path_string = data.original_path.u8string(); - auto file_to_write_string = data.file_to_write.u8string(); + auto original_path_string = fs::u8string(data.original_path); + auto file_to_write_string = fs::u8string(data.file_to_write); if (data.file_to_write == data.original_path) { Debug::print("Formatting ", file_to_write_string, "\n"); @@ -251,7 +251,7 @@ namespace vcpkg::Commands::FormatManifest Checks::check_exit(VCPKG_LINE_INFO, !manifest_exists || !control_exists, "Both a manifest file and a CONTROL file exist in port directory: %s", - dir.path().u8string()); + fs::u8string(dir.path())); if (manifest_exists) { diff --git a/toolsrc/src/vcpkg/commands.integrate.cpp b/toolsrc/src/vcpkg/commands.integrate.cpp index 1aa7d5864..75d39c954 100644 --- a/toolsrc/src/vcpkg/commands.integrate.cpp +++ b/toolsrc/src/vcpkg/commands.integrate.cpp @@ -75,7 +75,7 @@ namespace vcpkg::Commands::Integrate #if defined(_WIN32) static std::string get_nuget_id(const fs::path& vcpkg_root_dir) { - std::string dir_id = vcpkg_root_dir.generic_u8string(); + std::string dir_id = fs::generic_u8string(vcpkg_root_dir); std::replace(dir_id.begin(), dir_id.end(), '/', '.'); dir_id.erase(1, 1); // Erasing the ":" @@ -253,7 +253,7 @@ namespace vcpkg::Commands::Integrate const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets"; fs.write_contents(appdata_src_path, - create_appdata_shortcut(paths.buildsystems_msbuild_targets.u8string()), + create_appdata_shortcut(fs::u8string(paths.buildsystems_msbuild_targets)), VCPKG_LINE_INFO); auto appdata_dst_path = get_appdata_targets_path(); @@ -263,16 +263,16 @@ namespace vcpkg::Commands::Integrate { System::print2(System::Color::error, "Error: Failed to copy file: ", - appdata_src_path.u8string(), + fs::u8string(appdata_src_path), " -> ", - appdata_dst_path.u8string(), + fs::u8string(appdata_dst_path), "\n"); Checks::exit_fail(VCPKG_LINE_INFO); } const fs::path appdata_src_path2 = tmp_dir / "vcpkg.user.props"; fs.write_contents(appdata_src_path2, - create_appdata_shortcut(paths.buildsystems_msbuild_props.u8string()), + create_appdata_shortcut(fs::u8string(paths.buildsystems_msbuild_props)), VCPKG_LINE_INFO); auto appdata_dst_path2 = get_appdata_props_path(); @@ -283,9 +283,9 @@ namespace vcpkg::Commands::Integrate { System::print2(System::Color::error, "Error: Failed to copy file: ", - appdata_src_path2.u8string(), + fs::u8string(appdata_src_path2), " -> ", - appdata_dst_path2.u8string(), + fs::u8string(appdata_dst_path2), "\n"); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -294,7 +294,7 @@ namespace vcpkg::Commands::Integrate const auto pathtxt = get_path_txt_path(); std::error_code ec; - fs.write_contents(pathtxt, paths.root.generic_u8string(), VCPKG_LINE_INFO); + fs.write_contents(pathtxt, fs::generic_u8string(paths.root), VCPKG_LINE_INFO); System::print2(System::Color::success, "Applied user-wide integration for this vcpkg root.\n"); const fs::path cmake_toolchain = paths.buildsystems / "vcpkg.cmake"; @@ -307,13 +307,13 @@ Installing new libraries will make them instantly available. CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=%s" )", - cmake_toolchain.generic_u8string()); + fs::generic_u8string(cmake_toolchain)); #else System::printf( R"( CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=%s" )", - cmake_toolchain.generic_u8string()); + fs::generic_u8string(cmake_toolchain)); #endif Checks::exit_success(VCPKG_LINE_INFO); @@ -378,9 +378,9 @@ CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=%s" // Using all forward slashes for the command line const std::string cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s")", - nuget_exe.u8string(), - buildsystems_dir.u8string(), - nuspec_file_path.u8string()); + fs::u8string(nuget_exe), + fs::u8string(buildsystems_dir), + fs::u8string(nuspec_file_path)); const int exit_code = System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code; @@ -388,9 +388,9 @@ CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=%s" const fs::path nuget_package = buildsystems_dir / Strings::format("%s.%s.nupkg", nuget_id, nupkg_version); Checks::check_exit( VCPKG_LINE_INFO, exit_code == 0 && fs.exists(nuget_package), "Error: NuGet package creation failed"); - System::print2(System::Color::success, "Created nupkg: ", nuget_package.u8string(), '\n'); + System::print2(System::Color::success, "Created nupkg: ", fs::u8string(nuget_package), '\n'); - auto source_path = buildsystems_dir.u8string(); + auto source_path = fs::u8string(buildsystems_dir); source_path = Strings::replace_all(std::move(source_path), "`", "``"); System::printf(R"( @@ -412,8 +412,9 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console const fs::path script_path = paths.scripts / "addPoshVcpkgToPowershellProfile.ps1"; const auto& ps = paths.get_tool_exe("powershell-core"); - const std::string cmd = Strings::format( - R"("%s" -NoProfile -ExecutionPolicy Bypass -Command "& {& '%s' }")", ps.u8string(), script_path.u8string()); + const std::string cmd = Strings::format(R"("%s" -NoProfile -ExecutionPolicy Bypass -Command "& {& '%s' }")", + fs::u8string(ps), + fs::u8string(script_path)); const int rc = System::cmd_execute(cmd); if (rc) { @@ -422,7 +423,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console "Could not run:\n" " '%s'\n", TITLE, - script_path.generic_u8string()); + fs::generic_u8string(script_path)); { auto locked_metrics = Metrics::g_metrics.lock(); @@ -444,7 +445,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console Expected<std::vector<std::string>> maybe_bashrc_content = fs.read_lines(bashrc_path); Checks::check_exit( - VCPKG_LINE_INFO, maybe_bashrc_content.has_value(), "Unable to read %s", bashrc_path.u8string()); + VCPKG_LINE_INFO, maybe_bashrc_content.has_value(), "Unable to read %s", fs::u8string(bashrc_path)); std::vector<std::string> bashrc_content = maybe_bashrc_content.value_or_exit(VCPKG_LINE_INFO); @@ -464,13 +465,13 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console "The following entries were found:\n" " %s\n" "Please make sure you have started a new bash shell for the changes to take effect.\n", - bashrc_path.u8string(), + fs::u8string(bashrc_path), Strings::join("\n ", matches)); Checks::exit_success(VCPKG_LINE_INFO); } - System::printf("Adding vcpkg completion entry to %s\n", bashrc_path.u8string()); - bashrc_content.push_back(Strings::format("source %s", completion_script_path.u8string())); + System::printf("Adding vcpkg completion entry to %s\n", fs::u8string(bashrc_path)); + bashrc_content.push_back(Strings::format("source %s", fs::u8string(completion_script_path))); fs.write_contents(bashrc_path, Strings::join("\n", bashrc_content) + '\n', VCPKG_LINE_INFO); Checks::exit_success(VCPKG_LINE_INFO); } diff --git a/toolsrc/src/vcpkg/commands.porthistory.cpp b/toolsrc/src/vcpkg/commands.porthistory.cpp index 6f45e26ed..b54da5974 100644 --- a/toolsrc/src/vcpkg/commands.porthistory.cpp +++ b/toolsrc/src/vcpkg/commands.porthistory.cpp @@ -21,7 +21,7 @@ namespace vcpkg::Commands::PortHistory const fs::path dot_git_dir = paths.root / ".git"; const std::string full_cmd = - Strings::format(R"("%s" --git-dir="%s" %s)", git_exe.u8string(), dot_git_dir.u8string(), cmd); + Strings::format(R"("%s" --git-dir="%s" %s)", fs::u8string(git_exe), fs::u8string(dot_git_dir), cmd); auto output = System::cmd_execute_and_capture_output(full_cmd); Checks::check_exit(VCPKG_LINE_INFO, output.exit_code == 0, "Failed to run command: %s", full_cmd); diff --git a/toolsrc/src/vcpkg/commands.portsdiff.cpp b/toolsrc/src/vcpkg/commands.portsdiff.cpp index ad27599fb..509713d94 100644 --- a/toolsrc/src/vcpkg/commands.portsdiff.cpp +++ b/toolsrc/src/vcpkg/commands.portsdiff.cpp @@ -82,7 +82,7 @@ namespace vcpkg::Commands::PortsDiff auto& fs = paths.get_filesystem(); const fs::path& git_exe = paths.get_tool_exe(Tools::GIT); const fs::path dot_git_dir = paths.root / ".git"; - const std::string ports_dir_name_as_string = paths.ports.filename().u8string(); + const std::string ports_dir_name_as_string = fs::u8string(paths.ports.filename()); const fs::path temp_checkout_path = paths.root / Strings::format("%s-%s", ports_dir_name_as_string, git_commit_id); fs.create_directory(temp_checkout_path, ec); @@ -90,14 +90,14 @@ namespace vcpkg::Commands::PortsDiff 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)", - git_exe.u8string(), - dot_git_dir.u8string(), - temp_checkout_path.u8string(), + fs::u8string(git_exe), + fs::u8string(dot_git_dir), + fs::u8string(temp_checkout_path), git_commit_id, checkout_this_dir, ".vcpkg-root"); System::cmd_execute_and_capture_output(cmd, System::get_clean_environment()); - System::cmd_execute_and_capture_output(Strings::format(R"("%s" reset)", git_exe.u8string()), + System::cmd_execute_and_capture_output(Strings::format(R"("%s" reset)", fs::u8string(git_exe)), System::get_clean_environment()); const auto all_ports = Paragraphs::load_all_ports(paths.get_filesystem(), temp_checkout_path / ports_dir_name_as_string); @@ -115,7 +115,7 @@ namespace vcpkg::Commands::PortsDiff { static const std::string VALID_COMMIT_OUTPUT = "commit\n"; - const auto cmd = Strings::format(R"("%s" cat-file -t %s)", git_exe.u8string(), git_commit_id); + const auto cmd = Strings::format(R"("%s" cat-file -t %s)", fs::u8string(git_exe), git_commit_id); const System::ExitCodeAndOutput output = System::cmd_execute_and_capture_output(cmd); Checks::check_exit( VCPKG_LINE_INFO, output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", git_commit_id); diff --git a/toolsrc/src/vcpkg/commands.setinstalled.cpp b/toolsrc/src/vcpkg/commands.setinstalled.cpp index 6ef5099dc..e6fc05971 100644 --- a/toolsrc/src/vcpkg/commands.setinstalled.cpp +++ b/toolsrc/src/vcpkg/commands.setinstalled.cpp @@ -93,7 +93,7 @@ namespace vcpkg::Commands::SetInstalled auto pkgsconfig_path = Files::combine(paths.original_cwd, *p_pkgsconfig); auto pkgsconfig_contents = generate_nuget_packages_config(action_plan); fs.write_contents(pkgsconfig_path, pkgsconfig_contents, VCPKG_LINE_INFO); - System::print2("Wrote NuGet packages config information to ", pkgsconfig_path.u8string(), "\n"); + System::print2("Wrote NuGet packages config information to ", fs::u8string(pkgsconfig_path), "\n"); } if (dry_run == DryRun::Yes) diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp index f7671ceef..e4d45e888 100644 --- a/toolsrc/src/vcpkg/dependencies.cpp +++ b/toolsrc/src/vcpkg/dependencies.cpp @@ -302,16 +302,16 @@ namespace vcpkg::Dependencies const fs::path& install_port_path, const fs::path& default_port_path) { - if (!default_port_path.empty() && - !Strings::case_insensitive_ascii_starts_with(install_port_path.u8string(), default_port_path.u8string())) + if (!default_port_path.empty() && !Strings::case_insensitive_ascii_starts_with(fs::u8string(install_port_path), + fs::u8string(default_port_path))) { const char* const from_head = options.use_head_version == Build::UseHeadVersion::YES ? " (from HEAD)" : ""; switch (request_type) { case RequestType::AUTO_SELECTED: - return Strings::format(" * %s%s -- %s", s, from_head, install_port_path.u8string()); + return Strings::format(" * %s%s -- %s", s, from_head, fs::u8string(install_port_path)); case RequestType::USER_REQUESTED: - return Strings::format(" %s%s -- %s", s, from_head, install_port_path.u8string()); + return Strings::format(" %s%s -- %s", s, from_head, fs::u8string(install_port_path)); default: Checks::unreachable(VCPKG_LINE_INFO); } } diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index abaea6921..099bcf400 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -219,9 +219,9 @@ if (Test-Path $installedDir) 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)", - nuget_exe.u8string(), - exported_dir_path.u8string(), - nuspec_file_path.u8string()); + fs::u8string(nuget_exe), + fs::u8string(exported_dir_path), + fs::u8string(nuspec_file_path)); const int exit_code = System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code; diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index f8691aa04..967534863 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -54,9 +54,9 @@ namespace vcpkg::Export nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@RAW_EXPORTED_DIR@", raw_exported_dir); nuspec_file_content = Strings::replace_all( - std::move(nuspec_file_content), "@TARGETS_REDIRECT_PATH@", targets_redirect_path.u8string()); + std::move(nuspec_file_content), "@TARGETS_REDIRECT_PATH@", fs::u8string(targets_redirect_path)); nuspec_file_content = Strings::replace_all( - std::move(nuspec_file_content), "@PROPS_REDIRECT_PATH@", props_redirect_path.u8string()); + std::move(nuspec_file_content), "@PROPS_REDIRECT_PATH@", fs::u8string(props_redirect_path)); return nuspec_file_content; } @@ -206,7 +206,7 @@ namespace vcpkg::Export { const fs::path& cmake_exe = paths.get_tool_exe(Tools::CMAKE); - const std::string exported_dir_filename = raw_exported_dir.filename().u8string(); + const std::string exported_dir_filename = fs::u8string(raw_exported_dir.filename()); const std::string exported_archive_filename = Strings::format("%s.%s", exported_dir_filename, format.extension()); const fs::path exported_archive_path = (output_dir / exported_archive_filename); @@ -556,7 +556,7 @@ namespace vcpkg::Export System::printf(System::Color::success, R"(Files exported at: "%s")" "\n", - raw_exported_dir_path.u8string()); + fs::u8string(raw_exported_dir_path)); print_next_step_info(raw_exported_dir_path); } @@ -568,7 +568,7 @@ namespace vcpkg::Export const std::string nuget_version = opts.maybe_nuget_version.value_or("1.0.0"); const fs::path output_path = do_nuget_export(paths, nuget_id, nuget_version, raw_exported_dir_path, opts.output_dir); - System::print2(System::Color::success, "NuGet package exported at: ", output_path.u8string(), "\n"); + System::print2(System::Color::success, "NuGet package exported at: ", fs::u8string(output_path), "\n"); System::printf(R"( With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste: @@ -576,7 +576,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console )" "\n\n", nuget_id, - output_path.parent_path().u8string()); + fs::u8string(output_path.parent_path())); } if (opts.zip) @@ -584,7 +584,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console System::print2("Creating zip archive...\n"); const fs::path output_path = do_archive_export(paths, raw_exported_dir_path, opts.output_dir, ArchiveFormatC::ZIP); - System::print2(System::Color::success, "Zip archive exported at: ", output_path.u8string(), "\n"); + System::print2(System::Color::success, "Zip archive exported at: ", fs::u8string(output_path), "\n"); print_next_step_info("[...]"); } @@ -593,7 +593,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console System::print2("Creating 7zip archive...\n"); const fs::path output_path = do_archive_export(paths, raw_exported_dir_path, opts.output_dir, ArchiveFormatC::SEVEN_ZIP); - System::print2(System::Color::success, "7zip archive exported at: ", output_path.u8string(), "\n"); + System::print2(System::Color::success, "7zip archive exported at: ", fs::u8string(output_path), "\n"); print_next_step_info("[...]"); } diff --git a/toolsrc/src/vcpkg/export.ifw.cpp b/toolsrc/src/vcpkg/export.ifw.cpp index 45b600801..9726a93f9 100644 --- a/toolsrc/src/vcpkg/export.ifw.cpp +++ b/toolsrc/src/vcpkg/export.ifw.cpp @@ -91,7 +91,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + fs::generic_u8string(package_xml_file_path)); auto deps = Strings::join( ",", binary_paragraph.dependencies, [](const std::string& dep) { return "packages." + dep + ":"; }); @@ -137,7 +137,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + fs::generic_u8string(package_xml_file_path)); fs.write_contents(package_xml_file_path, Strings::format( R"###(<?xml version="1.0"?> @@ -162,7 +162,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + fs::generic_u8string(package_xml_file_path)); fs.write_contents(package_xml_file_path, Strings::format( @@ -196,7 +196,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + fs::generic_u8string(package_xml_file_path)); fs.write_contents(package_xml_file_path, Strings::format( R"###(<?xml version="1.0"?> @@ -218,7 +218,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + fs::generic_u8string(package_xml_file_path)); fs.write_contents(package_xml_file_path, Strings::format( R"###(<?xml version="1.0"?> @@ -245,7 +245,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + fs::generic_u8string(package_xml_file_path)); fs.write_contents(package_xml_file_path, Strings::format( @@ -272,7 +272,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for configuration file %s", - config_xml_file_path.generic_u8string()); + fs::generic_u8string(config_xml_file_path)); std::string formatted_repo_url; std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); @@ -314,10 +314,10 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - tempmaintenancetool.generic_u8string()); + fs::generic_u8string(tempmaintenancetool)); fs.copy_file(installerbase_exe, tempmaintenancetool, fs::copy_options::overwrite_existing, ec); Checks::check_exit( - VCPKG_LINE_INFO, !ec, "Could not write package file %s", tempmaintenancetool.generic_u8string()); + VCPKG_LINE_INFO, !ec, "Could not write package file %s", fs::generic_u8string(tempmaintenancetool)); fs::path package_xml_file_path = ifw_packages_dir_path / "maintenance" / "meta" / "package.xml"; fs::path package_xml_dir_path = package_xml_file_path.parent_path(); @@ -325,7 +325,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + fs::generic_u8string(package_xml_file_path)); fs.write_contents(package_xml_file_path, Strings::format( R"###(<?xml version="1.0"?> @@ -346,7 +346,7 @@ namespace vcpkg::Export::IFW const fs::path script_destination = ifw_packages_dir_path / "maintenance" / "meta" / "maintenance.qs"; fs.copy_file(script_source, script_destination, fs::copy_options::overwrite_existing, ec); Checks::check_exit( - VCPKG_LINE_INFO, !ec, "Could not write package file %s", script_destination.generic_u8string()); + VCPKG_LINE_INFO, !ec, "Could not write package file %s", fs::generic_u8string(script_destination)); System::print2("Exporting maintenance tool... done\n"); } @@ -357,7 +357,7 @@ namespace vcpkg::Export::IFW const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths); const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); - System::print2("Generating repository ", repository_dir.generic_u8string(), "...\n"); + System::print2("Generating repository ", fs::generic_u8string(repository_dir), "...\n"); std::error_code ec; fs::path failure_point; @@ -367,20 +367,20 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not remove outdated repository directory %s due to file %s", - repository_dir.generic_u8string(), + fs::generic_u8string(repository_dir), failure_point.string()); const auto cmd_line = Strings::format(R"("%s" --packages "%s" "%s")", - repogen_exe.u8string(), - packages_dir.u8string(), - repository_dir.u8string()); + fs::u8string(repogen_exe), + fs::u8string(packages_dir), + fs::u8string(repository_dir)); const int exit_code = System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code; Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW repository generating failed"); System::printf( - System::Color::success, "Generating repository %s... done.\n", repository_dir.generic_u8string()); + System::Color::success, "Generating repository %s... done.\n", fs::generic_u8string(repository_dir)); } void do_installer(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) @@ -391,7 +391,7 @@ namespace vcpkg::Export::IFW const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); const fs::path installer_file = get_installer_file_path(export_id, ifw_options, paths); - System::printf("Generating installer %s...\n", installer_file.generic_u8string()); + System::printf("Generating installer %s...\n", fs::generic_u8string(installer_file)); std::string cmd_line; @@ -399,18 +399,18 @@ namespace vcpkg::Export::IFW if (!ifw_repo_url.empty()) { cmd_line = Strings::format(R"("%s" --online-only --config "%s" --repository "%s" "%s")", - binarycreator_exe.u8string(), - config_file.u8string(), - repository_dir.u8string(), - installer_file.u8string()); + fs::u8string(binarycreator_exe), + fs::u8string(config_file), + fs::u8string(repository_dir), + fs::u8string(installer_file)); } else { cmd_line = Strings::format(R"("%s" --config "%s" --packages "%s" "%s")", - binarycreator_exe.u8string(), - config_file.u8string(), - packages_dir.u8string(), - installer_file.u8string()); + fs::u8string(binarycreator_exe), + fs::u8string(config_file), + fs::u8string(packages_dir), + fs::u8string(installer_file)); } const int exit_code = @@ -418,7 +418,7 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed"); System::printf( - System::Color::success, "Generating installer %s... done.\n", installer_file.generic_u8string()); + System::Color::success, "Generating installer %s... done.\n", fs::generic_u8string(installer_file)); } } @@ -438,17 +438,19 @@ namespace vcpkg::Export::IFW Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not remove outdated packages directory %s due to file %s", - ifw_packages_dir_path.generic_u8string(), + fs::generic_u8string(ifw_packages_dir_path), failure_point.string()); fs.create_directory(ifw_packages_dir_path, ec); - Checks::check_exit( - VCPKG_LINE_INFO, !ec, "Could not create packages directory %s", ifw_packages_dir_path.generic_u8string()); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create packages directory %s", + fs::generic_u8string(ifw_packages_dir_path)); // Export maintenance tool export_maintenance_tool(ifw_packages_dir_path, paths); - System::printf("Exporting packages %s...\n", ifw_packages_dir_path.generic_u8string()); + System::printf("Exporting packages %s...\n", fs::generic_u8string(ifw_packages_dir_path)); // execute the plan std::map<std::string, const ExportPlanAction*> unique_packages; @@ -479,11 +481,11 @@ namespace vcpkg::Export::IFW Install::install_package_and_write_listfile(paths, action.spec, dirs); } - System::printf("Exporting packages %s... done\n", ifw_packages_dir_path.generic_u8string()); + System::printf("Exporting packages %s... done\n", fs::generic_u8string(ifw_packages_dir_path)); const fs::path config_file = get_config_file_path(export_id, ifw_options, paths); - System::printf("Generating configuration %s...\n", config_file.generic_u8string()); + System::printf("Generating configuration %s...\n", fs::generic_u8string(config_file)); // Unique packages export_unique_packages(ifw_packages_dir_path, unique_packages, fs); @@ -499,7 +501,7 @@ namespace vcpkg::Export::IFW // Configuration export_config(export_id, ifw_options, paths); - System::printf("Generating configuration %s... done.\n", config_file.generic_u8string()); + System::printf("Generating configuration %s... done.\n", fs::generic_u8string(config_file)); // Do repository (optional) std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); diff --git a/toolsrc/src/vcpkg/export.prefab.cpp b/toolsrc/src/vcpkg/export.prefab.cpp index 51ac868c7..a1a6eb5f1 100644 --- a/toolsrc/src/vcpkg/export.prefab.cpp +++ b/toolsrc/src/vcpkg/export.prefab.cpp @@ -202,17 +202,17 @@ namespace vcpkg::Export::Prefab fs.remove(destination, ec); Checks::check_exit( - VCPKG_LINE_INFO, !fs.exists(destination), "Could not remove file: %s", destination.u8string()); + VCPKG_LINE_INFO, !fs.exists(destination), "Could not remove file: %s", fs::u8string(destination)); #if defined(_WIN32) auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP); System::cmd_execute_and_capture_output( Strings::format( - R"("%s" a "%s" "%s\*")", seven_zip_exe.u8string(), destination.u8string(), source.u8string()), + R"("%s" a "%s" "%s\*")", fs::u8string(seven_zip_exe), fs::u8string(destination), fs::u8string(source)), System::get_clean_environment()); #else System::cmd_execute_clean( - Strings::format(R"(cd '%s' && zip --quiet -r '%s' *)", source.u8string(), destination.u8string())); + Strings::format(R"(cd '%s' && zip --quiet -r '%s' *)", fs::u8string(source), fs::u8string(destination))); #endif } @@ -226,9 +226,10 @@ namespace vcpkg::Export::Prefab ? R"("%s" "install:install-file" "-Dfile=%s" "-DpomFile=%s")" : R"("%s" "-q" "install:install-file" "-Dfile=%s" "-DpomFile=%s")"; - const auto cmd_line = Strings::format(cmd_line_format, Tools::MAVEN, aar.u8string(), pom.u8string()); + const auto cmd_line = Strings::format(cmd_line_format, Tools::MAVEN, fs::u8string(aar), fs::u8string(pom)); const int exit_code = System::cmd_execute_clean(cmd_line); - Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: %s installing maven file", aar.generic_u8string()); + Checks::check_exit( + VCPKG_LINE_INFO, exit_code == 0, "Error: %s installing maven file", fs::generic_u8string(aar)); } static std::unique_ptr<Build::PreBuildInfo> build_info_from_triplet( @@ -311,13 +312,13 @@ namespace vcpkg::Export::Prefab Checks::check_exit(VCPKG_LINE_INFO, utils.exists(ndk_location), "Error: ANDROID_NDK_HOME Directory does not exists %s", - ndk_location.generic_u8string()); + fs::generic_u8string(ndk_location)); const fs::path source_properties_location = ndk_location / "source.properties"; Checks::check_exit(VCPKG_LINE_INFO, utils.exists(ndk_location), "Error: source.properties missing in ANDROID_NDK_HOME directory %s", - source_properties_location.generic_u8string()); + fs::generic_u8string(source_properties_location)); std::string content = utils.read_contents(source_properties_location, VCPKG_LINE_INFO); @@ -326,7 +327,7 @@ namespace vcpkg::Export::Prefab Checks::check_exit(VCPKG_LINE_INFO, version_opt.has_value(), "Error: NDK version missing %s", - source_properties_location.generic_u8string()); + fs::generic_u8string(source_properties_location)); NdkVersion version = to_version(version_opt.value_or_exit(VCPKG_LINE_INFO)).value_or_exit(VCPKG_LINE_INFO); @@ -498,8 +499,8 @@ namespace vcpkg::Export::Prefab { System::print2( Strings::format("[DEBUG]\n\tWriting manifest\n\tTo %s\n\tWriting prefab meta data\n\tTo %s\n\n", - manifest_path.generic_u8string(), - prefab_path.generic_u8string())); + fs::generic_u8string(manifest_path), + fs::generic_u8string(prefab_path))); } utils.write_contents(manifest_path, manifest, VCPKG_LINE_INFO); @@ -527,7 +528,7 @@ namespace vcpkg::Export::Prefab "Error: Packages not installed %s:%s %s", name, triplet, - listfile.generic_u8string()); + fs::generic_u8string(listfile)); fs::path libs = installed_dir / fs::u8path("lib"); @@ -566,8 +567,8 @@ namespace vcpkg::Export::Prefab { for (const auto& module : modules) { - std::string module_name = module.stem().generic_u8string(); - std::string extension = module.extension().generic_u8string(); + std::string module_name = fs::generic_u8string(module.stem()); + std::string extension = fs::generic_u8string(module.extension()); ABIMetadata ab; ab.abi = triplet_abi_map[triplet]; @@ -596,7 +597,7 @@ namespace vcpkg::Export::Prefab if (prefab_options.enable_debug) { System::print2( - Strings::format("\tWriting abi metadata\n\tTo %s\n", abi_path.generic_u8string())); + Strings::format("\tWriting abi metadata\n\tTo %s\n", fs::generic_u8string(abi_path))); } utils.write_contents(abi_path, ab.to_string(), VCPKG_LINE_INFO); @@ -610,8 +611,8 @@ namespace vcpkg::Export::Prefab if (prefab_options.enable_debug) { System::print2(Strings::format("\tCopying libs\n\tFrom %s\n\tTo %s\n", - installed_module_path.generic_u8string(), - exported_module_path.generic_u8string())); + fs::generic_u8string(installed_module_path), + fs::generic_u8string(exported_module_path))); } fs::path installed_headers_dir = installed_dir / "include"; fs::path exported_headers_dir = module_libs_dir / "include"; @@ -619,8 +620,8 @@ namespace vcpkg::Export::Prefab if (prefab_options.enable_debug) { System::print2(Strings::format("\tCopying headers\n\tFrom %s\n\tTo %s\n", - installed_headers_dir.generic_u8string(), - exported_headers_dir.generic_u8string())); + fs::generic_u8string(installed_headers_dir), + fs::generic_u8string(exported_headers_dir))); } utils.copy(installed_headers_dir, exported_headers_dir, fs::copy_options::recursive); @@ -632,7 +633,7 @@ namespace vcpkg::Export::Prefab if (prefab_options.enable_debug) { System::print2(Strings::format("\tWriting module metadata\n\tTo %s\n\n", - module_meta_path.generic_u8string())); + fs::generic_u8string(module_meta_path))); } utils.write_contents(module_meta_path, meta.to_json(), VCPKG_LINE_INFO); @@ -646,8 +647,8 @@ namespace vcpkg::Export::Prefab if (prefab_options.enable_debug) { System::print2(Strings::format("[DEBUG] Exporting AAR And POM\n\tAAR Path %s\n\tPOM Path %s\n", - exported_archive_path.generic_u8string(), - pom_path.generic_u8string())); + fs::generic_u8string(exported_archive_path), + fs::generic_u8string(pom_path))); } compress_directory(paths, package_directory, exported_archive_path); @@ -708,7 +709,7 @@ namespace vcpkg::Export::Prefab } System::print2( System::Color::success, - Strings::format("Successfuly exported %s. Checkout %s \n", name, paths.prefab.generic_u8string())); + Strings::format("Successfuly exported %s. Checkout %s \n", name, fs::generic_u8string(paths.prefab))); } } } diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp index 1719e5f6c..de39c7a86 100644 --- a/toolsrc/src/vcpkg/help.cpp +++ b/toolsrc/src/vcpkg/help.cpp @@ -78,24 +78,24 @@ namespace vcpkg::Help vcpkg::Util::group_by(paths.get_available_triplets(), &triplets_per_location, [](const VcpkgPaths::TripletFile& triplet_file) -> std::string { - return triplet_file.location.u8string(); + return fs::u8string(triplet_file.location); }); System::print2("Available architecture triplets\n"); System::print2("VCPKG built-in triplets:\n"); - for (auto* triplet : triplets_per_location[paths.triplets.u8string()]) + for (auto* triplet : triplets_per_location[fs::u8string(paths.triplets)]) { System::print2(" ", triplet->name, '\n'); } - triplets_per_location.erase(paths.triplets.u8string()); + triplets_per_location.erase(fs::u8string(paths.triplets)); System::print2("\nVCPKG community triplets:\n"); - for (auto* triplet : triplets_per_location[paths.community_triplets.u8string()]) + for (auto* triplet : triplets_per_location[fs::u8string(paths.community_triplets)]) { System::print2(" ", triplet->name, '\n'); } - triplets_per_location.erase(paths.community_triplets.u8string()); + triplets_per_location.erase(fs::u8string(paths.community_triplets)); for (auto&& kv_pair : triplets_per_location) { diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 03ae77d98..08c160f89 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -48,7 +48,7 @@ namespace vcpkg::Install auto& fs = paths.get_filesystem(); auto source_dir = paths.package_dir(spec); Checks::check_exit( - VCPKG_LINE_INFO, fs.exists(source_dir), "Source directory %s does not exist", source_dir.u8string()); + VCPKG_LINE_INFO, fs.exists(source_dir), "Source directory %s does not exist", fs::u8string(source_dir)); auto files = fs.get_files_recursive(source_dir); install_files_and_write_listfile(fs, source_dir, files, destination_dir); } @@ -60,16 +60,17 @@ namespace vcpkg::Install std::vector<std::string> output; std::error_code ec; - const size_t prefix_length = source_dir.generic_u8string().size(); + const size_t prefix_length = fs::generic_u8string(source_dir).size(); const fs::path& destination = destination_dir.destination(); const std::string& destination_subdirectory = destination_dir.destination_subdirectory(); const fs::path& listfile = destination_dir.listfile(); fs.create_directories(destination, ec); - Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create destination directory %s", destination.u8string()); + Checks::check_exit( + VCPKG_LINE_INFO, !ec, "Could not create destination directory %s", fs::u8string(destination)); const fs::path listfile_parent = listfile.parent_path(); fs.create_directories(listfile_parent, ec); - Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for listfile %s", listfile.u8string()); + Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for listfile %s", fs::u8string(listfile)); output.push_back(Strings::format(R"(%s/)", destination_subdirectory)); for (auto&& file : files) @@ -77,11 +78,11 @@ namespace vcpkg::Install const auto status = fs.symlink_status(file, ec); if (ec) { - System::print2(System::Color::error, "failed: ", file.u8string(), ": ", ec.message(), "\n"); + System::print2(System::Color::error, "failed: ", fs::u8string(file), ": ", ec.message(), "\n"); continue; } - const std::string filename = file.filename().generic_u8string(); + const std::string filename = fs::generic_u8string(file.filename()); if (fs::is_regular_file(status) && (Strings::case_insensitive_ascii_equals(filename, "CONTROL") || Strings::case_insensitive_ascii_equals(filename, "vcpkg.json") || Strings::case_insensitive_ascii_equals(filename, "BUILD_INFO"))) @@ -90,7 +91,7 @@ namespace vcpkg::Install continue; } - const std::string suffix = file.generic_u8string().substr(prefix_length + 1); + const std::string suffix = fs::generic_u8string(file).substr(prefix_length + 1); const fs::path target = destination / suffix; switch (status.type()) @@ -100,7 +101,7 @@ namespace vcpkg::Install fs.create_directory(target, ec); if (ec) { - System::printf(System::Color::error, "failed: %s: %s\n", target.u8string(), ec.message()); + System::printf(System::Color::error, "failed: %s: %s\n", fs::u8string(target), ec.message()); } // Trailing backslash for directories @@ -113,13 +114,13 @@ namespace vcpkg::Install { System::print2(System::Color::warning, "File ", - target.u8string(), + fs::u8string(target), " was already present and will be overwritten\n"); } fs.copy_file(file, target, fs::copy_options::overwrite_existing, ec); if (ec) { - System::printf(System::Color::error, "failed: %s: %s\n", target.u8string(), ec.message()); + System::printf(System::Color::error, "failed: %s: %s\n", fs::u8string(target), ec.message()); } output.push_back(Strings::format(R"(%s/%s)", destination_subdirectory, suffix)); break; @@ -130,19 +131,19 @@ namespace vcpkg::Install { System::print2(System::Color::warning, "File ", - target.u8string(), + fs::u8string(target), " was already present and will be overwritten\n"); } fs.copy_symlink(file, target, ec); if (ec) { - System::printf(System::Color::error, "failed: %s: %s\n", target.u8string(), ec.message()); + System::printf(System::Color::error, "failed: %s: %s\n", fs::u8string(target), ec.message()); } output.push_back(Strings::format(R"(%s/%s)", destination_subdirectory, suffix)); break; } default: - System::printf(System::Color::error, "failed: %s: cannot handle file type\n", file.u8string()); + System::printf(System::Color::error, "failed: %s: cannot handle file type\n", fs::u8string(file)); break; } } @@ -619,7 +620,7 @@ namespace vcpkg::Install // CMake file is inside the share folder auto path = paths.installed / suffix; auto maybe_contents = fs.read_contents(path); - auto find_package_name = path.parent_path().filename().u8string(); + auto find_package_name = fs::u8string(path.parent_path().filename()); if (auto p_contents = maybe_contents.get()) { std::sregex_iterator next(p_contents->begin(), p_contents->end(), cmake_library_regex); @@ -635,7 +636,7 @@ namespace vcpkg::Install } } - auto filename = fs::u8path(suffix).filename().u8string(); + auto filename = fs::u8string(fs::u8path(suffix).filename()); if (Strings::ends_with(filename, "Config.cmake")) { @@ -795,12 +796,12 @@ namespace vcpkg::Install if (ec) { Checks::exit_with_message( - VCPKG_LINE_INFO, "Failed to read manifest %s: %s", manifest_path.u8string(), ec.message()); + VCPKG_LINE_INFO, "Failed to read manifest %s: %s", fs::u8string(manifest_path), ec.message()); } else if (!maybe_manifest_scf) { print_error_message(maybe_manifest_scf.error()); - Checks::exit_with_message(VCPKG_LINE_INFO, "Failed to read manifest %s.", manifest_path.u8string()); + Checks::exit_with_message(VCPKG_LINE_INFO, "Failed to read manifest %s.", fs::u8string(manifest_path)); } auto& manifest_scf = *maybe_manifest_scf.value_or_exit(VCPKG_LINE_INFO); @@ -933,7 +934,7 @@ namespace vcpkg::Install auto pkgsconfig_path = Files::combine(paths.original_cwd, fs::u8path(it_pkgsconfig->second)); auto pkgsconfig_contents = generate_nuget_packages_config(action_plan); fs.write_contents(pkgsconfig_path, pkgsconfig_contents, VCPKG_LINE_INFO); - System::print2("Wrote NuGet packages config information to ", pkgsconfig_path.u8string(), "\n"); + System::print2("Wrote NuGet packages config information to ", fs::u8string(pkgsconfig_path), "\n"); } if (dry_run) diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp index 79a33a0d7..9a88f2ae8 100644 --- a/toolsrc/src/vcpkg/metrics.cpp +++ b/toolsrc/src/vcpkg/metrics.cpp @@ -525,11 +525,11 @@ namespace vcpkg::Metrics #if defined(_WIN32) const std::string cmd_line = Strings::format("cmd /c \"start \"vcpkgmetricsuploader.exe\" \"%s\" \"%s\"\"", - temp_folder_path_exe.u8string(), - vcpkg_metrics_txt_path.u8string()); + fs::u8string(temp_folder_path_exe), + fs::u8string(vcpkg_metrics_txt_path)); System::cmd_execute_no_wait(cmd_line); #else - auto escaped_path = Strings::escape_string(vcpkg_metrics_txt_path.u8string(), '\'', '\\'); + auto escaped_path = Strings::escape_string(fs::u8string(vcpkg_metrics_txt_path), '\'', '\\'); const std::string cmd_line = Strings::format( 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') &)", escaped_path, diff --git a/toolsrc/src/vcpkg/paragraphs.cpp b/toolsrc/src/vcpkg/paragraphs.cpp index a1d697063..37f919b63 100644 --- a/toolsrc/src/vcpkg/paragraphs.cpp +++ b/toolsrc/src/vcpkg/paragraphs.cpp @@ -232,7 +232,7 @@ namespace vcpkg::Paragraphs const Expected<std::string> contents = fs.read_contents(control_path); if (auto spgh = contents.get()) { - return parse_single_paragraph(*spgh, control_path.u8string()); + return parse_single_paragraph(*spgh, fs::u8string(control_path)); } return contents.error().message(); @@ -243,7 +243,7 @@ namespace vcpkg::Paragraphs const Expected<std::string> contents = fs.read_contents(control_path); if (auto spgh = contents.get()) { - return parse_paragraphs(*spgh, control_path.u8string()); + return parse_paragraphs(*spgh, fs::u8string(control_path)); } return contents.error().message(); @@ -298,16 +298,16 @@ namespace vcpkg::Paragraphs vcpkg::Checks::check_exit(VCPKG_LINE_INFO, !fs.exists(path_to_control), "Found both manifest and CONTROL file in port %s; please rename one or the other", - path.u8string()); + fs::u8string(path)); std::error_code ec; - auto res = try_load_manifest(fs, path.filename().u8string(), path_to_manifest, ec); + auto res = try_load_manifest(fs, fs::u8string(path.filename()), path_to_manifest, ec); if (ec) { auto error_info = std::make_unique<ParseControlErrorInfo>(); - error_info->name = path.filename().u8string(); + error_info->name = fs::u8string(path.filename()); error_info->error = Strings::format( - "Failed to load manifest file for port: %s\n", path_to_manifest.u8string(), ec.message()); + "Failed to load manifest file for port: %s\n", fs::u8string(path_to_manifest), ec.message()); } return res; @@ -318,7 +318,7 @@ namespace vcpkg::Paragraphs return SourceControlFile::parse_control_file(path_to_control, std::move(*vector_pghs)); } auto error_info = std::make_unique<ParseControlErrorInfo>(); - error_info->name = path.filename().u8string(); + error_info->name = fs::u8string(path.filename()); error_info->error = pghs.error(); return error_info; } diff --git a/toolsrc/src/vcpkg/portfileprovider.cpp b/toolsrc/src/vcpkg/portfileprovider.cpp index 1376ad3bc..0e9b355de 100644 --- a/toolsrc/src/vcpkg/portfileprovider.cpp +++ b/toolsrc/src/vcpkg/portfileprovider.cpp @@ -42,7 +42,7 @@ namespace vcpkg::PortFileProvider overlay = fs.canonical(VCPKG_LINE_INFO, paths.original_cwd / overlay); } - Debug::print("Using overlay: ", overlay.u8string(), "\n"); + Debug::print("Using overlay: ", fs::u8string(overlay), "\n"); Checks::check_exit( VCPKG_LINE_INFO, filesystem.exists(overlay), "Error: Path \"%s\" does not exist", overlay.string()); @@ -86,7 +86,7 @@ namespace vcpkg::PortFileProvider { vcpkg::print_error_message(maybe_scf.error()); Checks::exit_with_message( - VCPKG_LINE_INFO, "Error: Failed to load port %s from %s", spec, ports_dir.u8string()); + VCPKG_LINE_INFO, "Error: Failed to load port %s from %s", spec, fs::u8string(ports_dir)); } continue; @@ -107,7 +107,7 @@ namespace vcpkg::PortFileProvider } Checks::exit_with_message(VCPKG_LINE_INFO, "Error: Failed to load port from %s: names did not match: '%s' != '%s'", - (ports_dir / spec).u8string(), + fs::u8string(ports_dir / spec), spec, scf->get()->core_paragraph->name); } @@ -115,7 +115,7 @@ namespace vcpkg::PortFileProvider { vcpkg::print_error_message(found_scf.error()); Checks::exit_with_message( - VCPKG_LINE_INFO, "Error: Failed to load port from %s", spec, ports_dir.u8string()); + VCPKG_LINE_INFO, "Error: Failed to load port from %s", spec, fs::u8string(ports_dir)); } } } @@ -150,7 +150,7 @@ namespace vcpkg::PortFileProvider { vcpkg::print_error_message(maybe_scf.error()); Checks::exit_with_message( - VCPKG_LINE_INFO, "Error: Failed to load port from %s", ports_dir.u8string()); + VCPKG_LINE_INFO, "Error: Failed to load port from %s", fs::u8string(ports_dir)); } continue; } diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index a384cea0a..78fa993a2 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -157,7 +157,7 @@ namespace vcpkg::PostBuildLint restricted_sys_filenames, restricted_crt_filenames, restricted_general_filenames}; const fs::path include_dir = package_dir / "include"; auto files = fs.get_files_non_recursive(include_dir); - auto filenames_v = Util::fmap(files, [](const auto& file) { return file.filename().u8string(); }); + auto filenames_v = Util::fmap(files, [](const auto& file) { return fs::u8string(file.filename()); }); std::set<std::string> filenames_s(filenames_v.begin(), filenames_v.end()); std::vector<fs::path> violations; @@ -391,7 +391,7 @@ namespace vcpkg::PostBuildLint for (const fs::path& dll : dlls) { const std::string cmd_line = - Strings::format(R"("%s" /exports "%s")", dumpbin_exe.u8string(), dll.u8string()); + 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); Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line); @@ -429,7 +429,7 @@ namespace vcpkg::PostBuildLint for (const fs::path& dll : dlls) { const std::string cmd_line = - Strings::format(R"("%s" /headers "%s")", dumpbin_exe.u8string(), dll.u8string()); + 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); Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line); @@ -480,7 +480,7 @@ namespace vcpkg::PostBuildLint for (const FileAndArch& b : binaries_with_invalid_architecture) { System::print2(" ", - b.file.u8string(), + fs::u8string(b.file), "\n" "Expected ", expected_architecture, @@ -616,7 +616,7 @@ namespace vcpkg::PostBuildLint if (lib_count == 0 && dll_count != 0) { - System::print2(System::Color::warning, "Import libs were not present in ", lib_dir.u8string(), "\n"); + System::print2(System::Color::warning, "Import libs were not present in ", fs::u8string(lib_dir), "\n"); System::printf(System::Color::warning, "If this is intended, add the following line in the portfile:\n" " SET(%s enabled)\n", @@ -643,7 +643,7 @@ namespace vcpkg::PostBuildLint System::printf(System::Color::warning, R"(There should be no bin\ directory in a static build, but %s is present.)" "\n", - bin.u8string()); + fs::u8string(bin)); } if (fs.exists(debug_bin)) @@ -651,7 +651,7 @@ namespace vcpkg::PostBuildLint System::printf(System::Color::warning, R"(There should be no debug\bin\ directory in a static build, but %s is present.)" "\n", - debug_bin.u8string()); + fs::u8string(debug_bin)); } System::print2( @@ -679,7 +679,7 @@ namespace vcpkg::PostBuildLint if (!empty_directories.empty()) { - System::print2(System::Color::warning, "There should be no empty directories in ", dir.u8string(), "\n"); + System::print2(System::Color::warning, "There should be no empty directories in ", fs::u8string(dir), "\n"); System::print2("The following empty directories were found:\n"); Files::print_paths(empty_directories); System::print2( @@ -717,7 +717,7 @@ namespace vcpkg::PostBuildLint for (const fs::path& lib : libs) { const std::string cmd_line = - Strings::format(R"("%s" /directives "%s")", dumpbin_exe.u8string(), lib.u8string()); + 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); Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, @@ -771,7 +771,8 @@ namespace vcpkg::PostBuildLint for (const fs::path& dll : dlls) { - const auto cmd_line = Strings::format(R"("%s" /dependents "%s")", dumpbin_exe.u8string(), dll.u8string()); + const auto cmd_line = + 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); Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line); @@ -790,7 +791,7 @@ namespace vcpkg::PostBuildLint System::print2(System::Color::warning, "Detected outdated dynamic CRT in the following files:\n\n"); for (const OutdatedDynamicCrtAndFile& btf : dlls_with_outdated_crt) { - System::print2(" ", btf.file.u8string(), ": ", btf.outdated_crt.name, "\n"); + System::print2(" ", fs::u8string(btf.file), ": ", btf.outdated_crt.name, "\n"); } System::print2("\n"); @@ -818,7 +819,7 @@ namespace vcpkg::PostBuildLint if (!misplaced_files.empty()) { - System::print2(System::Color::warning, "The following files are placed in\n", dir.u8string(), ":\n"); + System::print2(System::Color::warning, "The following files are placed in\n", fs::u8string(dir), ":\n"); Files::print_paths(misplaced_files); System::print2(System::Color::warning, "Files cannot be present in those directories.\n\n"); return LintStatus::ERROR_DETECTED; @@ -965,7 +966,7 @@ namespace vcpkg::PostBuildLint "Found ", error_count, " error(s). Please correct the portfile:\n ", - portfile.u8string(), + fs::u8string(portfile), "\n"); } diff --git a/toolsrc/src/vcpkg/remove.cpp b/toolsrc/src/vcpkg/remove.cpp index 0d5b84280..8561003a8 100644 --- a/toolsrc/src/vcpkg/remove.cpp +++ b/toolsrc/src/vcpkg/remove.cpp @@ -58,7 +58,7 @@ namespace vcpkg::Remove if (ec) { System::print2( - System::Color::error, "failed: status(", target.u8string(), "): ", ec.message(), "\n"); + System::Color::error, "failed: status(", fs::u8string(target), "): ", ec.message(), "\n"); continue; } @@ -78,21 +78,22 @@ namespace vcpkg::Remove if (ec) { System::printf( - System::Color::error, "failed: remove(%s): %s\n", target.u8string(), ec.message()); + System::Color::error, "failed: remove(%s): %s\n", fs::u8string(target), ec.message()); } #else System::printf( - System::Color::error, "failed: remove(%s): %s\n", target.u8string(), ec.message()); + System::Color::error, "failed: remove(%s): %s\n", fs::u8string(target), ec.message()); #endif } } else if (!fs::exists(status)) { - System::printf(System::Color::warning, "Warning: %s: file not found\n", target.u8string()); + System::printf(System::Color::warning, "Warning: %s: file not found\n", fs::u8string(target)); } else { - System::printf(System::Color::warning, "Warning: %s: cannot handle file type\n", target.u8string()); + System::printf( + System::Color::warning, "Warning: %s: cannot handle file type\n", fs::u8string(target)); } } diff --git a/toolsrc/src/vcpkg/sourceparagraph.cpp b/toolsrc/src/vcpkg/sourceparagraph.cpp index a336db7d1..e10e485a7 100644 --- a/toolsrc/src/vcpkg/sourceparagraph.cpp +++ b/toolsrc/src/vcpkg/sourceparagraph.cpp @@ -359,7 +359,7 @@ namespace vcpkg static ParseExpected<SourceParagraph> parse_source_paragraph(const fs::path& path_to_control, Paragraph&& fields) { - auto origin = path_to_control.u8string(); + auto origin = fs::u8string(path_to_control); ParagraphParser parser(std::move(fields)); @@ -422,7 +422,7 @@ namespace vcpkg static ParseExpected<FeatureParagraph> parse_feature_paragraph(const fs::path& path_to_control, Paragraph&& fields) { - auto origin = path_to_control.u8string(); + auto origin = fs::u8string(path_to_control); ParagraphParser parser(std::move(fields)); auto fpgh = std::make_unique<FeatureParagraph>(); @@ -448,7 +448,7 @@ namespace vcpkg if (control_paragraphs.size() == 0) { auto ret = std::make_unique<Parse::ParseControlErrorInfo>(); - ret->name = path_to_control.u8string(); + ret->name = fs::u8string(path_to_control); return ret; } @@ -965,7 +965,7 @@ namespace vcpkg } err = {}; auto visit = Json::Reader{&err}; - err.pcei.name = path_to_manifest.u8string(); + err.pcei.name = fs::u8string(path_to_manifest); { auto extra_fields = invalid_json_fields(manifest, get_list_of_manifest_fields()); if (!extra_fields.empty()) diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp index 1d5a682c6..04577261a 100644 --- a/toolsrc/src/vcpkg/tools.cpp +++ b/toolsrc/src/vcpkg/tools.cpp @@ -68,11 +68,11 @@ namespace vcpkg has_xml_version, R"(Could not find <tools version="%s"> in %s)", XML_VERSION, - XML_PATH.u8string()); + fs::u8string(XML_PATH)); Checks::check_exit(VCPKG_LINE_INFO, XML_VERSION == match_xml_version[1], "Expected %s version: [%s], but was [%s]. Please re-run bootstrap-vcpkg.", - XML_PATH.u8string(), + fs::u8string(XML_PATH), XML_VERSION, match_xml_version[1]); @@ -84,7 +84,7 @@ namespace vcpkg return Strings::format("Could not automatically acquire %s because there is no entry in %s for os=%s. You " "may be able to install %s via your system package manager.", tool, - XML_PATH.u8string(), + fs::u8string(XML_PATH), OS_STRING, tool); } @@ -191,7 +191,7 @@ namespace vcpkg if (!fs.exists(tool_data.download_path)) { System::print2("Downloading ", tool_name, "...\n"); - System::print2(" ", tool_data.url, " -> ", tool_data.download_path.u8string(), "\n"); + System::print2(" ", tool_data.url, " -> ", fs::u8string(tool_data.download_path), "\n"); Downloads::download_file(fs, tool_data.url, tool_data.download_path, tool_data.sha512); } else @@ -214,7 +214,7 @@ namespace vcpkg Checks::check_exit(VCPKG_LINE_INFO, fs.exists(tool_data.exe_path), "Expected %s to exist after fetching", - tool_data.exe_path.u8string()); + fs::u8string(tool_data.exe_path)); return tool_data.exe_path; } @@ -288,7 +288,7 @@ namespace vcpkg } virtual Optional<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override { - const std::string cmd = Strings::format(R"("%s" --version)", path_to_exe.u8string()); + const std::string cmd = Strings::format(R"("%s" --version)", fs::u8string(path_to_exe)); const auto rc = System::cmd_execute_and_capture_output(cmd); if (rc.exit_code != 0) { @@ -314,7 +314,7 @@ CMake suite maintained and supported by Kitware (kitware.com/cmake). virtual Optional<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override { - const std::string cmd = Strings::format(R"("%s" --version)", path_to_exe.u8string()); + const std::string cmd = Strings::format(R"("%s" --version)", fs::u8string(path_to_exe)); const auto rc = System::cmd_execute_and_capture_output(cmd); if (rc.exit_code != 0) { @@ -386,7 +386,7 @@ Type 'NuGet help <command>' for help on a specific command. virtual Optional<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override { - const std::string cmd = Strings::format(R"("%s" --version)", path_to_exe.u8string()); + const std::string cmd = Strings::format(R"("%s" --version)", fs::u8string(path_to_exe)); const auto rc = System::cmd_execute_and_capture_output(cmd); if (rc.exit_code != 0) { @@ -453,7 +453,7 @@ Mono JIT compiler version 6.8.0.105 (Debian 6.8.0.105+dfsg-2 Wed Feb 26 23:23:50 virtual Optional<std::string> get_version(const VcpkgPaths&, const fs::path& path_to_exe) const override { - const std::string cmd = Strings::format(R"("%s" --framework-version)", path_to_exe.u8string()); + const std::string cmd = Strings::format(R"("%s" --framework-version)", fs::u8string(path_to_exe)); const auto rc = System::cmd_execute_and_capture_output(cmd); if (rc.exit_code != 0) { diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index 4f7ef7141..660c180e2 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -37,7 +37,7 @@ namespace Files::Filesystem& filesystem, const fs::path& root, std::string* option, StringLiteral name, LineInfo li) { auto result = process_input_directory_impl(filesystem, root, option, name, li); - Debug::print("Using ", name, "-root: ", result.u8string(), '\n'); + Debug::print("Using ", name, "-root: ", fs::u8string(result), '\n'); return result; } @@ -59,7 +59,7 @@ namespace Files::Filesystem& filesystem, const fs::path& root, std::string* option, StringLiteral name, LineInfo li) { auto result = process_output_directory_impl(filesystem, root, option, name, li); - Debug::print("Using ", name, "-root: ", result.u8string(), '\n'); + Debug::print("Using ", name, "-root: ", fs::u8string(result), '\n'); return result; } @@ -126,7 +126,7 @@ namespace vcpkg } uppercase_win32_drive_letter(root); Checks::check_exit(VCPKG_LINE_INFO, !root.empty(), "Error: Could not detect vcpkg-root."); - Debug::print("Using vcpkg-root: ", root.u8string(), '\n'); + Debug::print("Using vcpkg-root: ", fs::u8string(root), '\n'); std::error_code ec; bool manifest_mode_on = args.manifest_mode.value_or(args.manifest_root_dir != nullptr); @@ -142,7 +142,7 @@ namespace vcpkg if (!manifest_root_dir.empty() && manifest_mode_on) { - Debug::print("Using manifest-root: ", manifest_root_dir.u8string(), '\n'); + Debug::print("Using manifest-root: ", fs::u8string(manifest_root_dir), '\n'); installed = process_output_directory( filesystem, manifest_root_dir, args.install_root_dir.get(), "vcpkg_installed", VCPKG_LINE_INFO); @@ -158,7 +158,7 @@ namespace vcpkg if (ec) { System::printf( - System::Color::error, "Failed to take the filesystem lock on %s:\n", vcpkg_lock.u8string()); + System::Color::error, "Failed to take the filesystem lock on %s:\n", fs::u8string(vcpkg_lock)); System::printf(System::Color::error, " %s\n", ec.message()); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -170,7 +170,7 @@ namespace vcpkg { System::print2(System::Color::warning, "Warning: manifest-root detected at ", - manifest_root_dir.generic_u8string(), + fs::generic_u8string(manifest_root_dir), ", but manifests are not enabled.\n"); System::printf(System::Color::warning, R"(If you wish to use manifest mode, you may do one of the following: @@ -281,7 +281,7 @@ If you wish to silence this error and use classic mode, you can: { if (fs::is_regular_file(fs.status(VCPKG_LINE_INFO, path))) { - output.emplace_back(TripletFile(path.stem().filename().u8string(), triplets_dir)); + output.emplace_back(TripletFile(fs::u8string(path.stem().filename()), triplets_dir)); } } } @@ -301,7 +301,7 @@ If you wish to silence this error and use classic mode, you can: auto stem = file.stem(); if (stem != common_functions) { - helpers.emplace(stem.u8string(), + helpers.emplace(fs::u8string(stem), Hash::get_file_hash(VCPKG_LINE_INFO, fs, file, Hash::Algorithm::Sha1)); } } @@ -375,7 +375,7 @@ If you wish to silence this error and use classic mode, you can: Checks::check_exit(VCPKG_LINE_INFO, !candidates.empty(), "Could not find Visual Studio instance at %s with %s toolset.", - vsp->u8string(), + fs::u8string(*vsp), *tsv); Checks::check_exit(VCPKG_LINE_INFO, candidates.size() == 1); diff --git a/toolsrc/src/vcpkg/visualstudio.cpp b/toolsrc/src/vcpkg/visualstudio.cpp index 023844d0b..7c9331da5 100644 --- a/toolsrc/src/vcpkg/visualstudio.cpp +++ b/toolsrc/src/vcpkg/visualstudio.cpp @@ -66,7 +66,8 @@ namespace vcpkg::VisualStudio std::string to_string() const { - return Strings::format("%s, %s, %s", root_path.u8string(), version, release_type_to_string(release_type)); + return Strings::format( + "%s, %s, %s", fs::u8string(root_path), version, release_type_to_string(release_type)); } std::string major_version() const { return version.substr(0, 2); } @@ -84,7 +85,7 @@ namespace vcpkg::VisualStudio if (fs.exists(vswhere_exe)) { const auto code_and_output = System::cmd_execute_and_capture_output( - Strings::format(R"("%s" -all -prerelease -legacy -products * -format xml)", vswhere_exe.u8string())); + Strings::format(R"("%s" -all -prerelease -legacy -products * -format xml)", fs::u8string(vswhere_exe))); Checks::check_exit(VCPKG_LINE_INFO, code_and_output.exit_code == 0, "Running vswhere.exe failed with message:\n%s", @@ -233,7 +234,7 @@ namespace vcpkg::VisualStudio for (const fs::path& subdir : msvc_subdirectories) { - auto toolset_version_full = subdir.filename().u8string(); + auto toolset_version_full = fs::u8string(subdir.filename()); auto toolset_version_prefix = toolset_version_full.substr(0, 4); CStringView toolset_version; std::string vcvars_option; @@ -350,7 +351,7 @@ namespace vcpkg::VisualStudio "Warning: The following VS instances are excluded because the English language pack is unavailable.\n"); for (const Toolset& toolset : excluded_toolsets) { - System::print2(" ", toolset.visual_studio_root_path.u8string(), '\n'); + System::print2(" ", fs::u8string(toolset.visual_studio_root_path), '\n'); } System::print2(System::Color::warning, "Please install the English language pack.\n"); } @@ -361,7 +362,7 @@ namespace vcpkg::VisualStudio System::print2("The following paths were examined:\n"); for (const fs::path& path : paths_examined) { - System::print2(" ", path.u8string(), '\n'); + System::print2(" ", fs::u8string(path), '\n'); } Checks::exit_fail(VCPKG_LINE_INFO); } diff --git a/toolsrc/windows-bootstrap/vcpkg.props b/toolsrc/windows-bootstrap/vcpkg.props new file mode 100644 index 000000000..1d9478660 --- /dev/null +++ b/toolsrc/windows-bootstrap/vcpkg.props @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="latest" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <PlatformToolset Condition="'$(PlatformToolset)'==''">$(DefaultPlatformToolset)</PlatformToolset>
+ </PropertyGroup>
+ <Choose>
+ <When Condition="'$(PlatformToolset)' == 'v140'">
+ <PropertyGroup>
+ <VcpkgUseStdFilesystem>0</VcpkgUseStdFilesystem>
+ </PropertyGroup>
+ </When>
+ <Otherwise>
+ <PropertyGroup>
+ <VcpkgUseStdFilesystem>1</VcpkgUseStdFilesystem>
+ </PropertyGroup>
+ </Otherwise>
+ </Choose>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <PreprocessorDefinitions>VCPKG_USE_STD_FILESYSTEM=$(VcpkgUseStdFilesystem);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ </ItemDefinitionGroup>
+</Project>
diff --git a/toolsrc/windows-bootstrap/vcpkg.sln b/toolsrc/windows-bootstrap/vcpkg.sln deleted file mode 100644 index 51dc3649e..000000000 --- a/toolsrc/windows-bootstrap/vcpkg.sln +++ /dev/null @@ -1,56 +0,0 @@ -
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30330.147
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkg", "vcpkg\vcpkg.vcxproj", "{34671B80-54F9-46F5-8310-AC429C11D4FB}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkglib", "vcpkglib\vcpkglib.vcxproj", "{B98C92B7-2874-4537-9D46-D14E5C237F04}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkgmetricsuploader", "vcpkgmetricsuploader\vcpkgmetricsuploader.vcxproj", "{7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E4FAF582-0DB7-4CF5-BAE0-E2D38C48593B}"
- ProjectSection(SolutionItems) = preProject
- ..\vcpkg.natvis = ..\vcpkg.natvis
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x64.ActiveCfg = Debug|x64
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x64.Build.0 = Debug|x64
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x86.ActiveCfg = Debug|Win32
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x86.Build.0 = Debug|Win32
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x64.ActiveCfg = Release|x64
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x64.Build.0 = Release|x64
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x86.ActiveCfg = Release|Win32
- {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x86.Build.0 = Release|Win32
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x64.ActiveCfg = Debug|x64
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x64.Build.0 = Debug|x64
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x86.ActiveCfg = Debug|Win32
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x86.Build.0 = Debug|Win32
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x64.ActiveCfg = Release|x64
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x64.Build.0 = Release|x64
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x86.ActiveCfg = Release|Win32
- {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x86.Build.0 = Release|Win32
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x64.ActiveCfg = Debug|x64
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x64.Build.0 = Debug|x64
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x86.ActiveCfg = Debug|Win32
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x86.Build.0 = Debug|Win32
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x64.ActiveCfg = Release|x64
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x64.Build.0 = Release|x64
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x86.ActiveCfg = Release|Win32
- {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {030760DE-1214-461B-B241-39608AD6FB66}
- EndGlobalSection
-EndGlobal
diff --git a/toolsrc/windows-bootstrap/vcpkg/vcpkg.vcxproj b/toolsrc/windows-bootstrap/vcpkg/vcpkg.vcxproj index b6229d9a3..244173ca5 100644 --- a/toolsrc/windows-bootstrap/vcpkg/vcpkg.vcxproj +++ b/toolsrc/windows-bootstrap/vcpkg/vcpkg.vcxproj @@ -21,10 +21,9 @@ <PropertyGroup Label="Globals">
<ProjectGuid>{34671B80-54F9-46F5-8310-AC429C11D4FB}</ProjectGuid>
<RootNamespace>vcpkg</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
- <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <Import Project="$(MSBuildThisFileDirectory)..\vcpkg.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
diff --git a/toolsrc/windows-bootstrap/vcpkglib/vcpkglib.vcxproj b/toolsrc/windows-bootstrap/vcpkglib/vcpkglib.vcxproj index 909f6e870..334532a36 100644 --- a/toolsrc/windows-bootstrap/vcpkglib/vcpkglib.vcxproj +++ b/toolsrc/windows-bootstrap/vcpkglib/vcpkglib.vcxproj @@ -21,10 +21,9 @@ <PropertyGroup Label="Globals">
<ProjectGuid>{B98C92B7-2874-4537-9D46-D14E5C237F04}</ProjectGuid>
<RootNamespace>vcpkglib</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
- <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <Import Project="$(MSBuildThisFileDirectory)..\vcpkg.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
diff --git a/toolsrc/windows-bootstrap/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj b/toolsrc/windows-bootstrap/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj index 027ef1917..8413922ce 100644 --- a/toolsrc/windows-bootstrap/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj +++ b/toolsrc/windows-bootstrap/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj @@ -21,10 +21,9 @@ <PropertyGroup Label="Globals">
<ProjectGuid>{7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}</ProjectGuid>
<RootNamespace>vcpkgmetricsuploader</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
- <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <Import Project="$(MSBuildThisFileDirectory)..\vcpkg.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
|
