diff options
| author | Curtis.Bezault <curtbezault@gmail.com> | 2019-07-23 15:26:13 -0700 |
|---|---|---|
| committer | Curtis.Bezault <curtbezault@gmail.com> | 2019-07-23 15:26:13 -0700 |
| commit | 2f2a45595fa925edeace250b694d70095c42b5fa (patch) | |
| tree | ea8e21720d232f4396a99631e159b8d03bfd44eb | |
| parent | 459908ae14458a615bb0a8c278c799cabd34e558 (diff) | |
| download | vcpkg-2f2a45595fa925edeace250b694d70095c42b5fa.tar.gz vcpkg-2f2a45595fa925edeace250b694d70095c42b5fa.zip | |
Prompt rebuild if external hash changes
| -rw-r--r-- | toolsrc/include/vcpkg/binaryparagraph.h | 11 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/binaryparagraph.cpp | 27 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/build.cpp | 12 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/dependencies.cpp | 8 |
4 files changed, 52 insertions, 6 deletions
diff --git a/toolsrc/include/vcpkg/binaryparagraph.h b/toolsrc/include/vcpkg/binaryparagraph.h index ec14f8a97..a95a68090 100644 --- a/toolsrc/include/vcpkg/binaryparagraph.h +++ b/toolsrc/include/vcpkg/binaryparagraph.h @@ -7,6 +7,13 @@ namespace vcpkg { + enum class ConsistencyState : unsigned + { + UNKNOWN = 0, + CONSISTENT, + INCONSISTENT, + }; + /// <summary> /// Built package metadata /// </summary> @@ -23,6 +30,8 @@ namespace vcpkg std::string dir() const; + bool is_consistent() const; + PackageSpec spec; std::string version; std::string description; @@ -33,6 +42,8 @@ namespace vcpkg std::string abi; SourceParagraph::TYPE type; std::unordered_map<std::string, std::string> external_files; + + mutable ConsistencyState consistency = ConsistencyState::UNKNOWN; }; struct BinaryControlFile diff --git a/toolsrc/src/vcpkg/binaryparagraph.cpp b/toolsrc/src/vcpkg/binaryparagraph.cpp index 2e9415dab..88d257e7e 100644 --- a/toolsrc/src/vcpkg/binaryparagraph.cpp +++ b/toolsrc/src/vcpkg/binaryparagraph.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include <vcpkg/base/checks.h> +#include <vcpkg/base/hash.h> #include <vcpkg/base/system.print.h> #include <vcpkg/base/util.h> #include <vcpkg/binaryparagraph.h> @@ -27,6 +28,32 @@ namespace vcpkg static const std::string EXTERNALFILES = "External-Files"; } + bool BinaryParagraph::is_consistent() const + { + switch (consistency) + { + case ConsistencyState::UNKNOWN : + for (const auto& file_hash : external_files) + { + const auto& realfs = Files::get_real_filesystem(); + + if (realfs.is_regular_file(file_hash.first) && + Hash::get_file_hash(realfs, file_hash.first, "SHA1") != file_hash.second) + { + consistency = ConsistencyState::INCONSISTENT; + return false; + } + } + + consistency = ConsistencyState::CONSISTENT; + return true; + case ConsistencyState::CONSISTENT : return true; + case ConsistencyState::INCONSISTENT : return false; + } + + Checks::unreachable(VCPKG_LINE_INFO); + } + BinaryParagraph::BinaryParagraph() = default; BinaryParagraph::BinaryParagraph(std::unordered_map<std::string, std::string> fields) diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 110a571b0..1f0dda590 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -475,11 +475,15 @@ namespace vcpkg::Build {
hashes.emplace_back(external_file, it_hash->second);
}
- else if (fs.is_regular_file(external_file))
+ else if (Files::get_real_filesystem().is_regular_file(external_file))
{
- auto emp = s_hash_cache.emplace(external_file.u8string(),
- Hash::get_file_hash(fs, external_file, "SHA1"));
- hashes.emplace_back(external_file, emp.first->second);
+ auto emp = s_hash_cache.emplace(
+ external_file.u8string(),
+ Hash::get_file_hash(
+ Files::get_real_filesystem(),
+ external_file, "SHA1"));
+
+ hashes.emplace_back(external_file.u8string(), emp.first->second);
}
else
{
diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp index b604c9acf..50c310dbb 100644 --- a/toolsrc/src/vcpkg/dependencies.cpp +++ b/toolsrc/src/vcpkg/dependencies.cpp @@ -664,13 +664,17 @@ namespace vcpkg::Dependencies if (auto p_installed = cluster.installed.get()) { - if (p_installed->original_features.find(feature) != p_installed->original_features.end()) + if (p_installed->original_features.find(feature) != p_installed->original_features.end() && + p_installed->ipv.core->package.is_consistent()) { return MarkPlusResult::SUCCESS; } } - // This feature was or will be uninstalled, therefore we need to rebuild + //The feature was not previously installed or the external files of the + //port are no longer consistent with the last installation of this port + //(they've either been modified or removed). Mark the cluster + //(aka the entire port) to be removed before re-adding it. mark_minus(cluster, graph, graph_plan, prevent_default_features); return follow_plus_dependencies(feature, cluster, graph, graph_plan, prevent_default_features); |
