mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 11:21:12 +08:00
Prompt rebuild if external hash changes
This commit is contained in:
parent
459908ae14
commit
2f2a45595f
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user