aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2019-06-19 11:49:57 -0700
committerGitHub <noreply@github.com>2019-06-19 11:49:57 -0700
commite5b92a39116791cfd4e1f4931221c9f69125bae3 (patch)
tree6f868340680f87b5e673688ffcdae8ea8351c8ea
parentdf0b8d9e55bfb6772a9e5c02fd826ab520e5d2f8 (diff)
downloadvcpkg-e5b92a39116791cfd4e1f4931221c9f69125bae3.tar.gz
vcpkg-e5b92a39116791cfd4e1f4931221c9f69125bae3.zip
[vcpkg] Improve vcpkg::Files::Filesystem error handling (#6919)
* [vcpkg] Modify Filesystem::remove and Filesystem::rename to not throw. * [.gitignore] Ignore new VS2019 CMake integration default location * [.gitignore] Ignore CMakeSettings.json in toolsrc * [vcpkg] Time external processes called with System::cmd_execute * [vcpkg] Work around VS2019 CMake bug * [vcpkg] Fix several unused variable warnings. * [vcpkg] Improve error handling in vcpkg::Files::Filesystem Always require either std::error_code or LineInfo to print better errors. * [vcpkg] Fixup missing return value. Drive by fix: silence warnings in tests. * [vcpkg] Fix exiting in error_code overload Drive by fixes for /analyze with VS2019
-rw-r--r--.gitignore3
-rw-r--r--toolsrc/CMakeLists.txt2
-rw-r--r--toolsrc/include/tests.utils.h8
-rw-r--r--toolsrc/include/vcpkg/base/files.h14
-rw-r--r--toolsrc/include/vcpkg/base/graphs.h4
-rw-r--r--toolsrc/include/vcpkg/base/optional.h23
-rw-r--r--toolsrc/include/vcpkg/base/strings.h2
-rw-r--r--toolsrc/src/vcpkg/base/downloads.cpp16
-rw-r--r--toolsrc/src/vcpkg/base/files.cpp61
-rw-r--r--toolsrc/src/vcpkg/base/strings.cpp2
-rw-r--r--toolsrc/src/vcpkg/base/system.cpp13
-rw-r--r--toolsrc/src/vcpkg/build.cpp24
-rw-r--r--toolsrc/src/vcpkg/commands.ci.cpp4
-rw-r--r--toolsrc/src/vcpkg/commands.exportifw.cpp24
-rw-r--r--toolsrc/src/vcpkg/commands.import.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.integrate.cpp22
-rw-r--r--toolsrc/src/vcpkg/dependencies.cpp11
-rw-r--r--toolsrc/src/vcpkg/export.cpp4
-rw-r--r--toolsrc/src/vcpkg/help.cpp2
-rw-r--r--toolsrc/src/vcpkg/install.cpp15
-rw-r--r--toolsrc/src/vcpkg/remove.cpp2
-rw-r--r--toolsrc/src/vcpkg/tools.cpp6
-rw-r--r--toolsrc/src/vcpkg/update.cpp2
-rw-r--r--toolsrc/src/vcpkg/vcpkglib.cpp16
24 files changed, 181 insertions, 101 deletions
diff --git a/.gitignore b/.gitignore
index d0e202f1d..f38bc90a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,9 @@
*.userosscache
*.sln.docstates
+toolsrc/out
+toolsrc/CMakeSettings.json
+
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
diff --git a/toolsrc/CMakeLists.txt b/toolsrc/CMakeLists.txt
index b3ec4d15d..fccf2b7ad 100644
--- a/toolsrc/CMakeLists.txt
+++ b/toolsrc/CMakeLists.txt
@@ -20,7 +20,7 @@ If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
set(CLANG 1)
elseif(MSVC)
- add_compile_options(/std:c++17)
+ add_compile_options(/std:c++17 /FC)
else()
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
diff --git a/toolsrc/include/tests.utils.h b/toolsrc/include/tests.utils.h
index 7f7ec9e88..3e8514e67 100644
--- a/toolsrc/include/tests.utils.h
+++ b/toolsrc/include/tests.utils.h
@@ -13,7 +13,7 @@
namespace Microsoft::VisualStudio::CppUnitTestFramework
{
template<>
- std::wstring ToString<vcpkg::Dependencies::InstallPlanType>(const vcpkg::Dependencies::InstallPlanType& t)
+ inline std::wstring ToString<vcpkg::Dependencies::InstallPlanType>(const vcpkg::Dependencies::InstallPlanType& t)
{
switch (t)
{
@@ -26,7 +26,7 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework
}
template<>
- std::wstring ToString<vcpkg::Dependencies::RequestType>(const vcpkg::Dependencies::RequestType& t)
+ inline std::wstring ToString<vcpkg::Dependencies::RequestType>(const vcpkg::Dependencies::RequestType& t)
{
switch (t)
{
@@ -38,13 +38,13 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework
}
template<>
- std::wstring ToString<vcpkg::PackageSpecParseResult>(const vcpkg::PackageSpecParseResult& t)
+ inline std::wstring ToString<vcpkg::PackageSpecParseResult>(const vcpkg::PackageSpecParseResult& t)
{
return ToString(static_cast<uint32_t>(t));
}
template<>
- std::wstring ToString<vcpkg::PackageSpec>(const vcpkg::PackageSpec& t)
+ inline std::wstring ToString<vcpkg::PackageSpec>(const vcpkg::PackageSpec& t)
{
return ToString(t.to_string());
}
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h
index b07ff25b3..02e2b8db8 100644
--- a/toolsrc/include/vcpkg/base/files.h
+++ b/toolsrc/include/vcpkg/base/files.h
@@ -27,21 +27,25 @@ namespace vcpkg::Files
{
struct Filesystem
{
+ std::string read_contents(const fs::path& file_path, LineInfo linfo) const;
virtual Expected<std::string> read_contents(const fs::path& file_path) const = 0;
virtual Expected<std::vector<std::string>> read_lines(const fs::path& file_path) const = 0;
virtual fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename) const = 0;
virtual std::vector<fs::path> get_files_recursive(const fs::path& dir) const = 0;
virtual std::vector<fs::path> get_files_non_recursive(const fs::path& dir) const = 0;
-
- virtual void write_lines(const fs::path& file_path, const std::vector<std::string>& lines) = 0;
+ void write_lines(const fs::path& file_path, const std::vector<std::string>& lines, LineInfo linfo);
+ virtual void write_lines(const fs::path& file_path,
+ const std::vector<std::string>& lines,
+ std::error_code& ec) = 0;
+ void write_contents(const fs::path& path, const std::string& data, LineInfo linfo);
virtual void write_contents(const fs::path& file_path, const std::string& data, std::error_code& ec) = 0;
- virtual void rename(const fs::path& oldpath, const fs::path& newpath) = 0;
+ void rename(const fs::path& oldpath, const fs::path& newpath, LineInfo linfo);
virtual void rename(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) = 0;
virtual void rename_or_copy(const fs::path& oldpath,
const fs::path& newpath,
StringLiteral temp_suffix,
std::error_code& ec) = 0;
- virtual bool remove(const fs::path& path) = 0;
+ bool remove(const fs::path& path, LineInfo linfo);
virtual bool remove(const fs::path& path, std::error_code& ec) = 0;
virtual std::uintmax_t remove_all(const fs::path& path, std::error_code& ec) = 0;
virtual bool exists(const fs::path& path) const = 0;
@@ -60,8 +64,6 @@ namespace vcpkg::Files
virtual fs::file_status symlink_status(const fs::path& path, std::error_code& ec) const = 0;
virtual std::vector<fs::path> find_from_PATH(const std::string& name) const = 0;
-
- void write_contents(const fs::path& file_path, const std::string& data);
};
Filesystem& get_real_filesystem();
diff --git a/toolsrc/include/vcpkg/base/graphs.h b/toolsrc/include/vcpkg/base/graphs.h
index 46831a911..9901a49a0 100644
--- a/toolsrc/include/vcpkg/base/graphs.h
+++ b/toolsrc/include/vcpkg/base/graphs.h
@@ -44,9 +44,9 @@ namespace vcpkg::Graphs
void shuffle(Container& c, Randomizer* r)
{
if (!r) return;
- for (int i = static_cast<int>(c.size()); i > 1; --i)
+ for (auto i = c.size(); i > 1; --i)
{
- auto j = r->random(i);
+ auto j = r->random(static_cast<int>(i));
if (j != i - 1)
{
std::swap(c[i - 1], c[j]);
diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h
index 4d386a961..2d8c126c6 100644
--- a/toolsrc/include/vcpkg/base/optional.h
+++ b/toolsrc/include/vcpkg/base/optional.h
@@ -19,6 +19,9 @@ namespace vcpkg
template<class T, bool B = std::is_copy_constructible<T>::value>
struct OptionalStorage
{
+#if defined(_WIN32)
+#pragma warning(suppress : 26495)
+#endif
constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {}
constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) {}
constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {}
@@ -28,12 +31,18 @@ namespace vcpkg
if (m_is_present) m_t.~T();
}
+#if defined(_WIN32)
+#pragma warning(suppress : 26495)
+#endif
OptionalStorage(const OptionalStorage& o) : m_is_present(o.m_is_present), m_inactive()
{
if (m_is_present) new (&m_t) T(o.m_t);
}
- OptionalStorage(OptionalStorage&& o) : m_is_present(o.m_is_present), m_inactive()
+#if defined(_WIN32)
+#pragma warning(suppress : 26495)
+#endif
+ OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive()
{
if (m_is_present)
{
@@ -59,7 +68,7 @@ namespace vcpkg
return *this;
}
- OptionalStorage& operator=(OptionalStorage&& o)
+ OptionalStorage& operator=(OptionalStorage&& o) noexcept
{
if (m_is_present && o.m_is_present)
{
@@ -100,6 +109,9 @@ namespace vcpkg
template<class T>
struct OptionalStorage<T, false>
{
+#if defined(_WIN32)
+#pragma warning(suppress : 26495)
+#endif
constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {}
constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {}
@@ -108,7 +120,10 @@ namespace vcpkg
if (m_is_present) m_t.~T();
}
- OptionalStorage(OptionalStorage&& o) : m_is_present(o.m_is_present), m_inactive()
+#if defined(_WIN32)
+#pragma warning(suppress : 26495)
+#endif
+ OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive()
{
if (m_is_present)
{
@@ -116,7 +131,7 @@ namespace vcpkg
}
}
- OptionalStorage& operator=(OptionalStorage&& o)
+ OptionalStorage& operator=(OptionalStorage&& o) noexcept
{
if (m_is_present && o.m_is_present)
{
diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h
index 3a9de97df..d553d1d41 100644
--- a/toolsrc/include/vcpkg/base/strings.h
+++ b/toolsrc/include/vcpkg/base/strings.h
@@ -163,7 +163,7 @@ namespace vcpkg::Strings
std::vector<std::string> split(const std::string& s, const std::string& delimiter);
- std::vector<std::string> split(const std::string& s, const std::string& delimiter, int max_count);
+ std::vector<std::string> split(const std::string& s, const std::string& delimiter, size_t max_count);
std::vector<StringView> find_all_enclosed(StringView input, StringView left_delim, StringView right_delim);
diff --git a/toolsrc/src/vcpkg/base/downloads.cpp b/toolsrc/src/vcpkg/base/downloads.cpp
index 218ff86b3..4bb2178e5 100644
--- a/toolsrc/src/vcpkg/base/downloads.cpp
+++ b/toolsrc/src/vcpkg/base/downloads.cpp
@@ -105,7 +105,7 @@ namespace vcpkg::Downloads
bResults = WinHttpQueryDataAvailable(hRequest, &dwSize);
Checks::check_exit(VCPKG_LINE_INFO, bResults, "WinHttpQueryDataAvailable() failed: %d", GetLastError());
- if (buf.size() < dwSize) buf.resize(dwSize * 2);
+ if (buf.size() < dwSize) buf.resize(static_cast<size_t>(dwSize) * 2);
bResults = WinHttpReadData(hRequest, (LPVOID)buf.data(), dwSize, &downloaded_size);
Checks::check_exit(VCPKG_LINE_INFO, bResults, "WinHttpReadData() failed: %d", GetLastError());
@@ -157,9 +157,10 @@ namespace vcpkg::Downloads
const std::string& sha512)
{
const std::string download_path_part = download_path.u8string() + ".part";
+ auto download_path_part_path = fs::u8path(download_path_part);
std::error_code ec;
fs.remove(download_path, ec);
- fs.remove(download_path_part, ec);
+ fs.remove(download_path_part_path, ec);
#if defined(_WIN32)
auto url_no_proto = url.substr(8); // drop https://
auto path_begin = Util::find(url_no_proto, '/');
@@ -173,14 +174,7 @@ namespace vcpkg::Downloads
Checks::check_exit(VCPKG_LINE_INFO, code == 0, "Could not download %s", url);
#endif
- verify_downloaded_file_hash(fs, url, download_path_part, sha512);
- fs.rename(download_path_part, download_path, ec);
- Checks::check_exit(VCPKG_LINE_INFO,
- !ec,
- "Failed to do post-download rename-in-place.\n"
- "fs.rename(%s, %s, %s)",
- download_path_part,
- download_path.u8string(),
- ec.message());
+ verify_downloaded_file_hash(fs, url, download_path_part_path, sha512);
+ fs.rename(download_path_part_path, download_path, VCPKG_LINE_INFO);
}
}
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp
index 0396a2415..5099795e9 100644
--- a/toolsrc/src/vcpkg/base/files.cpp
+++ b/toolsrc/src/vcpkg/base/files.cpp
@@ -24,12 +24,43 @@ namespace vcpkg::Files
{
static const std::regex FILESYSTEM_INVALID_CHARACTERS_REGEX = std::regex(R"([\/:*?"<>|])");
- void Filesystem::write_contents(const fs::path& file_path, const std::string& data)
+ std::string Filesystem::read_contents(const fs::path& path, LineInfo linfo) const
+ {
+ auto maybe_contents = this->read_contents(path);
+ if (auto p = maybe_contents.get())
+ return std::move(*p);
+ else
+ Checks::exit_with_message(
+ linfo, "error reading file: %s: %s", path.u8string(), 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());
+ }
+ void Filesystem::rename(const fs::path& oldpath, const fs::path& newpath, LineInfo linfo)
+ {
+ std::error_code ec;
+ this->rename(oldpath, newpath, ec);
+ if (ec)
+ Checks::exit_with_message(
+ linfo, "error renaming file: %s: %s: %s", oldpath.u8string(), newpath.u8string(), ec.message());
+ }
+
+ bool Filesystem::remove(const fs::path& path, LineInfo linfo)
{
std::error_code ec;
- write_contents(file_path, data, ec);
- Checks::check_exit(
- VCPKG_LINE_INFO, !ec, "error while writing file: %s: %s", file_path.u8string(), ec.message());
+ auto r = this->remove(path, ec);
+ if (ec) Checks::exit_with_message(linfo, "error removing file: %s: %s", path.u8string(), ec.message());
+ return r;
+ }
+
+ void Filesystem::write_lines(const fs::path& path, const std::vector<std::string>& lines, LineInfo linfo)
+ {
+ 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());
}
struct RealFilesystem final : Filesystem
@@ -147,30 +178,39 @@ namespace vcpkg::Files
return ret;
}
- virtual void write_lines(const fs::path& file_path, const std::vector<std::string>& lines) override
+ virtual void write_lines(const fs::path& file_path,
+ const std::vector<std::string>& lines,
+ std::error_code& ec) override
{
std::fstream output(file_path, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
+ if (!output)
+ {
+ ec.assign(errno, std::generic_category());
+ return;
+ }
for (const std::string& line : lines)
{
output << line << "\n";
+ if (!output)
+ {
+ output.close();
+ ec.assign(errno, std::generic_category());
+ return;
+ }
}
output.close();
}
-
virtual void rename(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) override
{
fs::stdfs::rename(oldpath, newpath, ec);
}
- virtual void rename(const fs::path& oldpath, const fs::path& newpath) override
- {
- fs::stdfs::rename(oldpath, newpath);
- }
virtual void rename_or_copy(const fs::path& oldpath,
const fs::path& newpath,
StringLiteral temp_suffix,
std::error_code& ec) override
{
this->rename(oldpath, newpath, ec);
+ Util::unused(temp_suffix);
#if defined(__linux__) || defined(__APPLE__)
if (ec)
{
@@ -213,7 +253,6 @@ namespace vcpkg::Files
}
#endif
}
- virtual bool remove(const fs::path& path) override { return fs::stdfs::remove(path); }
virtual bool remove(const fs::path& path, std::error_code& ec) override { return fs::stdfs::remove(path, ec); }
virtual std::uintmax_t remove_all(const fs::path& path, std::error_code& ec) override
{
diff --git a/toolsrc/src/vcpkg/base/strings.cpp b/toolsrc/src/vcpkg/base/strings.cpp
index ce634a227..54a74a7a1 100644
--- a/toolsrc/src/vcpkg/base/strings.cpp
+++ b/toolsrc/src/vcpkg/base/strings.cpp
@@ -185,7 +185,7 @@ std::vector<std::string> Strings::split(const std::string& s, const std::string&
return output;
}
-std::vector<std::string> Strings::split(const std::string& s, const std::string& delimiter, int max_count)
+std::vector<std::string> Strings::split(const std::string& s, const std::string& delimiter, size_t max_count)
{
std::vector<std::string> output;
diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp
index 3d89d2fd4..c5ff050f0 100644
--- a/toolsrc/src/vcpkg/base/system.cpp
+++ b/toolsrc/src/vcpkg/base/system.cpp
@@ -388,6 +388,7 @@ namespace vcpkg
// Flush stdout before launching external process
fflush(nullptr);
+ auto timer = Chrono::ElapsedTimer::create_started();
#if defined(_WIN32)
// We are wrap the command line in quotes to cause cmd.exe to correctly process it
auto actual_cmd_line = Strings::concat('"', cmd_line, '"');
@@ -395,11 +396,19 @@ namespace vcpkg
g_ctrl_c_state.transition_to_spawn_process();
const int exit_code = _wsystem(Strings::to_utf16(actual_cmd_line).c_str());
g_ctrl_c_state.transition_from_spawn_process();
- Debug::print("_wsystem() returned ", exit_code, '\n');
+ Debug::print("_wsystem() returned ",
+ exit_code,
+ " after ",
+ Strings::format("%8d", static_cast<int>(timer.microseconds())),
+ " us\n");
#else
Debug::print("_system(", cmd_line, ")\n");
const int exit_code = system(cmd_line.c_str());
- Debug::print("_system() returned ", exit_code, '\n');
+ Debug::print("_system() returned ",
+ exit_code,
+ " after ",
+ Strings::format("%8d", static_cast<int>(timer.microseconds())),
+ " us\n");
#endif
return exit_code;
}
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index 0a7c854b5..daff7e6c8 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -280,7 +280,7 @@ namespace vcpkg::Build
start += "\n" + Strings::serialize(feature);
}
const fs::path binary_control_file = paths.packages / bcf.core_paragraph.dir() / "CONTROL";
- paths.get_filesystem().write_contents(binary_control_file, start);
+ paths.get_filesystem().write_contents(binary_control_file, start, VCPKG_LINE_INFO);
}
static std::vector<FeatureSpec> compute_required_feature_specs(const BuildPackageConfig& config,
@@ -336,16 +336,16 @@ namespace vcpkg::Build
static int get_concurrency()
{
- static int concurrency = []{
- auto user_defined_concurrency = System::get_environment_variable("VCPKG_MAX_CONCURRENCY");
- if (user_defined_concurrency)
- {
- return std::stoi(user_defined_concurrency.value_or_exit(VCPKG_LINE_INFO));
- }
- else
- {
- return System::get_num_logical_cores() + 1;
- }
+ static int concurrency = [] {
+ auto user_defined_concurrency = System::get_environment_variable("VCPKG_MAX_CONCURRENCY");
+ if (user_defined_concurrency)
+ {
+ return std::stoi(user_defined_concurrency.value_or_exit(VCPKG_LINE_INFO));
+ }
+ else
+ {
+ return System::get_num_logical_cores() + 1;
+ }
}();
return concurrency;
@@ -565,7 +565,7 @@ namespace vcpkg::Build
std::error_code ec;
fs.create_directories(paths.buildtrees / name, ec);
const auto abi_file_path = paths.buildtrees / name / (triplet.canonical_name() + ".vcpkg_abi_info.txt");
- fs.write_contents(abi_file_path, full_abi_info);
+ fs.write_contents(abi_file_path, full_abi_info, VCPKG_LINE_INFO);
return AbiTagAndFile{Hash::get_file_hash(fs, abi_file_path, "SHA1"), abi_file_path};
}
diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp
index ff7e7a134..de66d917b 100644
--- a/toolsrc/src/vcpkg/commands.ci.cpp
+++ b/toolsrc/src/vcpkg/commands.ci.cpp
@@ -485,11 +485,11 @@ namespace vcpkg::Commands::CI
System::print2("Total elapsed time: ", result.summary.total_elapsed_time, "\n");
result.summary.print();
}
-
+ auto& fs = paths.get_filesystem();
auto it_xunit = options.settings.find(OPTION_XUNIT);
if (it_xunit != options.settings.end())
{
- paths.get_filesystem().write_contents(fs::u8path(it_xunit->second), xunitTestResults.build_xml());
+ fs.write_contents(fs::u8path(it_xunit->second), xunitTestResults.build_xml(), VCPKG_LINE_INFO);
}
Checks::exit_success(VCPKG_LINE_INFO);
diff --git a/toolsrc/src/vcpkg/commands.exportifw.cpp b/toolsrc/src/vcpkg/commands.exportifw.cpp
index ba9e28233..f0946110c 100644
--- a/toolsrc/src/vcpkg/commands.exportifw.cpp
+++ b/toolsrc/src/vcpkg/commands.exportifw.cpp
@@ -106,7 +106,8 @@ namespace vcpkg::Export::IFW
create_release_date(),
action.spec.name(),
action.spec.triplet().canonical_name(),
- deps));
+ deps),
+ VCPKG_LINE_INFO);
// Return dir path for export package data
return ifw_packages_dir_path /
@@ -138,7 +139,8 @@ namespace vcpkg::Export::IFW
<ReleaseDate>%s</ReleaseDate>
</Package>
)###",
- create_release_date()));
+ create_release_date()),
+ VCPKG_LINE_INFO);
for (const auto& unique_package : unique_packages)
{
@@ -167,7 +169,8 @@ namespace vcpkg::Export::IFW
action.spec.name(),
safe_rich_from_plain_text(binary_paragraph.description),
binary_paragraph.version,
- create_release_date()));
+ create_release_date()),
+ VCPKG_LINE_INFO);
}
}
@@ -195,7 +198,8 @@ namespace vcpkg::Export::IFW
<ReleaseDate>%s</ReleaseDate>
</Package>
)###",
- create_release_date()));
+ create_release_date()),
+ VCPKG_LINE_INFO);
for (const std::string& triplet : unique_triplets)
{
@@ -217,7 +221,8 @@ namespace vcpkg::Export::IFW
</Package>
)###",
triplet,
- create_release_date()));
+ create_release_date()),
+ VCPKG_LINE_INFO);
}
}
@@ -243,7 +248,8 @@ namespace vcpkg::Export::IFW
<ReleaseDate>%s</ReleaseDate>
</Package>
)###",
- create_release_date()));
+ create_release_date()),
+ VCPKG_LINE_INFO);
}
void export_config(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
@@ -283,7 +289,8 @@ namespace vcpkg::Export::IFW
<TargetDir>@RootDir@/src/vcpkg</TargetDir>%s
</Installer>
)###",
- formatted_repo_url));
+ formatted_repo_url),
+ VCPKG_LINE_INFO);
}
void export_maintenance_tool(const fs::path& ifw_packages_dir_path, const VcpkgPaths& paths)
@@ -325,7 +332,8 @@ namespace vcpkg::Export::IFW
<ForcedInstallation>true</ForcedInstallation>
</Package>
)###",
- create_release_date()));
+ create_release_date()),
+ VCPKG_LINE_INFO);
const fs::path script_source = paths.root / "scripts" / "ifw" / "maintenance.qs";
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);
diff --git a/toolsrc/src/vcpkg/commands.import.cpp b/toolsrc/src/vcpkg/commands.import.cpp
index f03140fbd..40f5a434c 100644
--- a/toolsrc/src/vcpkg/commands.import.cpp
+++ b/toolsrc/src/vcpkg/commands.import.cpp
@@ -89,7 +89,7 @@ namespace vcpkg::Commands::Import
place_library_files_in(paths.get_filesystem(), include_directory, project_directory, library_destination_path);
const fs::path control_file_path = library_destination_path / "CONTROL";
- fs.write_contents(control_file_path, Strings::serialize(control_file_data));
+ fs.write_contents(control_file_path, Strings::serialize(control_file_data), VCPKG_LINE_INFO);
}
const CommandStructure COMMAND_STRUCTURE = {
diff --git a/toolsrc/src/vcpkg/commands.integrate.cpp b/toolsrc/src/vcpkg/commands.integrate.cpp
index ef555a844..6921a5390 100644
--- a/toolsrc/src/vcpkg/commands.integrate.cpp
+++ b/toolsrc/src/vcpkg/commands.integrate.cpp
@@ -209,7 +209,7 @@ namespace vcpkg::Commands::Integrate
if (should_install_system)
{
const fs::path sys_src_path = tmp_dir / "vcpkg.system.targets";
- fs.write_contents(sys_src_path, create_system_targets_shortcut());
+ fs.write_contents(sys_src_path, create_system_targets_shortcut(), VCPKG_LINE_INFO);
const std::string param = Strings::format(R"(/c mkdir "%s" & copy "%s" "%s" /Y > nul)",
SYSTEM_WIDE_TARGETS_FILE.parent_path().string(),
@@ -248,7 +248,8 @@ namespace vcpkg::Commands::Integrate
const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets";
fs.write_contents(appdata_src_path,
- create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.u8string()));
+ create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.u8string()),
+ VCPKG_LINE_INFO);
auto appdata_dst_path = get_appdata_targets_path();
const auto rc = fs.copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing, ec);
@@ -268,12 +269,7 @@ namespace vcpkg::Commands::Integrate
const auto pathtxt = get_path_txt_path();
std::error_code ec;
- fs.write_contents(pathtxt, paths.root.generic_u8string(), ec);
- if (ec)
- {
- System::print2(System::Color::error, "Error: Failed to write file: ", pathtxt.u8string(), "\n");
- Checks::exit_fail(VCPKG_LINE_INFO);
- }
+ fs.write_contents(pathtxt, paths.root.generic_u8string(), 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";
@@ -344,9 +340,11 @@ CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=%s"
const std::string nuget_id = get_nuget_id(paths.root);
const std::string nupkg_version = "1.0.0";
- fs.write_contents(targets_file_path, create_nuget_targets_file_contents(paths.buildsystems_msbuild_targets));
- fs.write_contents(props_file_path, create_nuget_props_file_contents());
- fs.write_contents(nuspec_file_path, create_nuspec_file_contents(paths.root, nuget_id, nupkg_version));
+ fs.write_contents(
+ targets_file_path, create_nuget_targets_file_contents(paths.buildsystems_msbuild_targets), VCPKG_LINE_INFO);
+ fs.write_contents(props_file_path, create_nuget_props_file_contents(), VCPKG_LINE_INFO);
+ fs.write_contents(
+ nuspec_file_path, create_nuspec_file_contents(paths.root, nuget_id, nupkg_version), VCPKG_LINE_INFO);
// Using all forward slashes for the command line
const std::string cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" > nul)",
@@ -449,7 +447,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
System::printf("Adding vcpkg completion entry to %s\n", bashrc_path.u8string());
bashrc_content.push_back(Strings::format("source %s", completion_script_path.u8string()));
- fs.write_contents(bashrc_path, Strings::join("\n", bashrc_content) + '\n');
+ fs.write_contents(bashrc_path, Strings::join("\n", bashrc_content) + '\n', VCPKG_LINE_INFO);
Checks::exit_success(VCPKG_LINE_INFO);
}
#endif
diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp
index 8fde28929..f4a05e7dc 100644
--- a/toolsrc/src/vcpkg/dependencies.cpp
+++ b/toolsrc/src/vcpkg/dependencies.cpp
@@ -488,11 +488,12 @@ namespace vcpkg::Dependencies
if (plus) return MarkPlusResult::SUCCESS;
plus = true;
- auto p_source = cluster.source.get();
- Checks::check_exit(VCPKG_LINE_INFO,
- p_source != nullptr,
- "Error: Cannot find definition for package `%s`.",
- cluster.spec.name());
+ const auto p_source = cluster.source.get();
+ if (p_source == nullptr)
+ {
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO, "Error: Cannot find definition for package `%s`.", cluster.spec.name());
+ }
if (feature.empty())
{
diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp
index 433d7a1af..23fc7441a 100644
--- a/toolsrc/src/vcpkg/export.cpp
+++ b/toolsrc/src/vcpkg/export.cpp
@@ -141,12 +141,12 @@ namespace vcpkg::Export
std::error_code ec;
fs.create_directories(paths.buildsystems / "tmp", ec);
- fs.write_contents(targets_redirect, targets_redirect_content);
+ fs.write_contents(targets_redirect, targets_redirect_content, VCPKG_LINE_INFO);
const std::string nuspec_file_content =
create_nuspec_file_contents(raw_exported_dir.string(), targets_redirect.string(), nuget_id, nuget_version);
const fs::path nuspec_file_path = paths.buildsystems / "tmp" / "vcpkg.export.nuspec";
- fs.write_contents(nuspec_file_path, nuspec_file_content);
+ fs.write_contents(nuspec_file_path, nuspec_file_content, VCPKG_LINE_INFO);
// -NoDefaultExcludes is needed for ".vcpkg-root"
const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes > nul)",
diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp
index 84a054e0f..b92e9ca59 100644
--- a/toolsrc/src/vcpkg/help.cpp
+++ b/toolsrc/src/vcpkg/help.cpp
@@ -137,7 +137,7 @@ namespace vcpkg::Help
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- args.parse_arguments(COMMAND_STRUCTURE);
+ Util::unused(args.parse_arguments(COMMAND_STRUCTURE));
if (args.command_arguments.empty())
{
diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp
index adab4249f..88b15fe7a 100644
--- a/toolsrc/src/vcpkg/install.cpp
+++ b/toolsrc/src/vcpkg/install.cpp
@@ -138,7 +138,7 @@ namespace vcpkg::Install
std::sort(output.begin(), output.end());
- fs.write_lines(listfile, output);
+ fs.write_lines(listfile, output, VCPKG_LINE_INFO);
}
static std::vector<file_pack> extract_files_in_triplet(
@@ -364,7 +364,12 @@ namespace vcpkg::Install
const fs::path download_dir = paths.downloads;
std::error_code ec;
for (auto& p : fs.get_files_non_recursive(download_dir))
- if (!fs.is_directory(p)) fs.remove(p);
+ {
+ if (!fs.is_directory(p))
+ {
+ fs.remove(p, VCPKG_LINE_INFO);
+ }
+ }
}
return {code, std::move(bcf)};
@@ -628,6 +633,8 @@ namespace vcpkg::Install
const bool clean_after_build = Util::Sets::contains(options.switches, (OPTION_CLEAN_AFTER_BUILD));
const KeepGoing keep_going = to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING));
+ auto& fs = paths.get_filesystem();
+
// create the plan
StatusParagraphs status_db = database_load_check(paths);
@@ -645,7 +652,7 @@ namespace vcpkg::Install
Build::FailOnTombstone::NO,
};
- auto all_ports = Paragraphs::load_all_ports(paths.get_filesystem(), paths.ports);
+ auto all_ports = Paragraphs::load_all_ports(fs, paths.ports);
std::unordered_map<std::string, SourceControlFile> scf_map;
for (auto&& port : all_ports)
scf_map[port->core_paragraph->name] = std::move(*port);
@@ -703,7 +710,7 @@ namespace vcpkg::Install
xunit_doc += summary.xunit_results();
xunit_doc += "</collection></assembly></assemblies>\n";
- paths.get_filesystem().write_contents(fs::u8path(it_xunit->second), xunit_doc);
+ fs.write_contents(fs::u8path(it_xunit->second), xunit_doc, VCPKG_LINE_INFO);
}
for (auto&& result : summary.results)
diff --git a/toolsrc/src/vcpkg/remove.cpp b/toolsrc/src/vcpkg/remove.cpp
index 685cdfdc3..f997667ac 100644
--- a/toolsrc/src/vcpkg/remove.cpp
+++ b/toolsrc/src/vcpkg/remove.cpp
@@ -111,7 +111,7 @@ namespace vcpkg::Remove
}
}
- fs.remove(paths.listfile_path(ipv.core->package));
+ fs.remove(paths.listfile_path(ipv.core->package), VCPKG_LINE_INFO);
}
for (auto&& spgh : spghs)
diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp
index 2fdfbe0f2..4f4b23055 100644
--- a/toolsrc/src/vcpkg/tools.cpp
+++ b/toolsrc/src/vcpkg/tools.cpp
@@ -131,7 +131,10 @@ namespace vcpkg
virtual const std::string& exe_stem() const = 0;
virtual std::array<int, 3> default_min_version() const = 0;
- virtual void add_special_paths(std::vector<fs::path>& out_candidate_paths) const {}
+ virtual void add_special_paths(std::vector<fs::path>& out_candidate_paths) const
+ {
+ Util::unused(out_candidate_paths);
+ }
virtual Optional<std::string> get_version(const fs::path& path_to_exe) const = 0;
};
@@ -406,6 +409,7 @@ git version 2.17.1.windows.2
virtual void add_special_paths(std::vector<fs::path>& out_candidate_paths) const override
{
+ Util::unused(out_candidate_paths);
// TODO: Uncomment later
// const std::vector<fs::path> from_path = Files::find_from_PATH("installerbase");
// candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend());
diff --git a/toolsrc/src/vcpkg/update.cpp b/toolsrc/src/vcpkg/update.cpp
index 344192d59..2c52d5952 100644
--- a/toolsrc/src/vcpkg/update.cpp
+++ b/toolsrc/src/vcpkg/update.cpp
@@ -52,7 +52,7 @@ namespace vcpkg::Update
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- args.parse_arguments(COMMAND_STRUCTURE);
+ Util::unused(args.parse_arguments(COMMAND_STRUCTURE));
System::print2("Using local portfile versions. To update the local portfiles, use `git pull`.\n");
const StatusParagraphs status_db = database_load_check(paths);
diff --git a/toolsrc/src/vcpkg/vcpkglib.cpp b/toolsrc/src/vcpkg/vcpkglib.cpp
index c8e95dab1..2a52111a6 100644
--- a/toolsrc/src/vcpkg/vcpkglib.cpp
+++ b/toolsrc/src/vcpkg/vcpkglib.cpp
@@ -21,7 +21,7 @@ namespace vcpkg
return StatusParagraphs();
}
- fs.rename(vcpkg_dir_status_file_old, vcpkg_dir_status_file);
+ fs.rename(vcpkg_dir_status_file_old, vcpkg_dir_status_file, VCPKG_LINE_INFO);
}
auto pghs = Paragraphs::get_paragraphs(fs, vcpkg_dir_status_file).value_or_exit(VCPKG_LINE_INFO);
@@ -72,15 +72,15 @@ namespace vcpkg
}
}
- fs.write_contents(status_file_new, Strings::serialize(current_status_db));
+ fs.write_contents(status_file_new, Strings::serialize(current_status_db), VCPKG_LINE_INFO);
- fs.rename(status_file_new, status_file);
+ fs.rename(status_file_new, status_file, VCPKG_LINE_INFO);
for (auto&& file : update_files)
{
if (!fs.is_regular_file(file)) continue;
- fs.remove(file);
+ fs.remove(file, VCPKG_LINE_INFO);
}
return current_status_db;
@@ -95,8 +95,8 @@ namespace vcpkg
const auto tmp_update_filename = paths.vcpkg_dir_updates / "incomplete";
const auto update_filename = paths.vcpkg_dir_updates / Strings::format("%010d", my_update_id);
- fs.write_contents(tmp_update_filename, Strings::serialize(p));
- fs.rename(tmp_update_filename, update_filename);
+ fs.write_contents(tmp_update_filename, Strings::serialize(p), VCPKG_LINE_INFO);
+ fs.rename(tmp_update_filename, update_filename, VCPKG_LINE_INFO);
}
static void upgrade_to_slash_terminated_sorted_format(Files::Filesystem& fs,
@@ -165,8 +165,8 @@ namespace vcpkg
// Replace the listfile on disk
const fs::path updated_listfile_path = listfile_path.generic_string() + "_updated";
- fs.write_lines(updated_listfile_path, *lines);
- fs.rename(updated_listfile_path, listfile_path);
+ fs.write_lines(updated_listfile_path, *lines, VCPKG_LINE_INFO);
+ fs.rename(updated_listfile_path, listfile_path, VCPKG_LINE_INFO);
}
std::vector<InstalledPackageView> get_installed_ports(const StatusParagraphs& status_db)