add needs_rebuild, should probably be moved to somewhere else

This commit is contained in:
Curtis.Bezault 2019-07-18 13:24:31 -07:00
parent f18ffe9968
commit d39bd70d53
2 changed files with 27 additions and 0 deletions

View File

@ -62,6 +62,8 @@ namespace vcpkg
/// <returns>`true` if installed, `false` if not or not found.</returns>
bool is_installed(const FeatureSpec& spec) const;
bool needs_rebuild(const PackageSpec& spec);
iterator insert(std::unique_ptr<StatusParagraph>);
friend void serialize(const StatusParagraphs& pgh, std::string& out_str);

View File

@ -118,6 +118,31 @@ namespace vcpkg
return it != end() && (*it)->is_installed();
}
bool vcpkg::StatusParagraphs::needs_rebuild(const PackageSpec& spec)
{
auto it = find(spec);
if (it != end())
{
for (const std::string& dep : (*it)->package.depends)
{
PackageSpec dep_spec =
PackageSpec::from_name_and_triplet(
dep,
spec.triplet()).value_or_exit(VCPKG_LINE_INFO);
if (needs_rebuild(dep_spec))
{
(*it)->state = InstallState::NEEDS_REBUILD;
return true;
}
}
return (*it)->needs_rebuild();
}
return false;
}
StatusParagraphs::iterator StatusParagraphs::insert(std::unique_ptr<StatusParagraph> pgh)
{
Checks::check_exit(VCPKG_LINE_INFO, pgh != nullptr, "Inserted null paragraph");