Prompt rebuild if external hash changes
MODIFY
include/vcpkg/binaryparagraph.h
include/vcpkg/binaryparagraph.h
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

MODIFY
src/vcpkg/binaryparagraph.cpp
src/vcpkg/binaryparagraph.cpp
#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)

MODIFY
src/vcpkg/build.cpp
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
{

MODIFY
src/vcpkg/dependencies.cpp
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);

Prompt rebuild if external hash changes