Skip to content

Commit

Permalink
[vcpkg] Improve error messages when failing to find a backing port
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Feb 6, 2020
1 parent aaddcb1 commit 5162592
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
21 changes: 10 additions & 11 deletions toolsrc/src/vcpkg/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,11 @@ namespace vcpkg::Dependencies
m_port_provider.get_control_file(ipv.spec().name());

if (!maybe_scfl)
Checks::exit_with_message(VCPKG_LINE_INFO,
"We could not find a CONTROL file for ",
ipv.spec().to_string(),
". Please run \"vcpkg remove ",
ipv.spec().to_string(),
"\" and re-attempt.");
Checks::exit_with_message(
VCPKG_LINE_INFO,
"We could not find a CONTROL file for '%s'. Please run \"vcpkg remove %s\" and re-attempt.",
ipv.spec().to_string(),
ipv.spec().to_string());

return m_graph
.emplace(std::piecewise_construct,
Expand Down Expand Up @@ -684,8 +683,8 @@ namespace vcpkg::Dependencies
}

// And it has at least one qualified dependency
if (paragraph_depends && Util::any_of(*paragraph_depends,
[](auto&& dep) { return !dep.qualifier.empty(); }))
if (paragraph_depends &&
Util::any_of(*paragraph_depends, [](auto&& dep) { return !dep.qualifier.empty(); }))
{
// Add it to the next batch run
qualified_dependencies.emplace_back(spec);
Expand Down Expand Up @@ -864,9 +863,9 @@ namespace vcpkg::Dependencies
continue;
}
auto&& dep_clust = m_graph->get(fspec.spec());
const auto& default_features =
[&]{
if (dep_clust.m_install_info.has_value()) return dep_clust.m_scfl.source_control_file->core_paragraph->default_features;
const auto& default_features = [&] {
if (dep_clust.m_install_info.has_value())
return dep_clust.m_scfl.source_control_file->core_paragraph->default_features;
if (auto p = dep_clust.m_installed.get()) return p->ipv.core->package.default_features;
Checks::unreachable(VCPKG_LINE_INFO);
}();
Expand Down
28 changes: 21 additions & 7 deletions toolsrc/src/vcpkg/portfileprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,29 @@ namespace vcpkg::PortFileProvider
}
}

auto found_scf = Paragraphs::try_load_port(filesystem, ports_dir / spec);
if (auto scf = found_scf.get())
if (filesystem.exists(ports_dir / spec / "CONTROL"))
{
if (scf->get()->core_paragraph->name == spec)
auto found_scf = Paragraphs::try_load_port(filesystem, ports_dir / spec);
if (auto scf = found_scf.get())
{
auto it = cache.emplace(std::piecewise_construct,
std::forward_as_tuple(spec),
std::forward_as_tuple(std::move(*scf), ports_dir / spec));
return it.first->second;
if (scf->get()->core_paragraph->name == spec)
{
auto it = cache.emplace(std::piecewise_construct,
std::forward_as_tuple(spec),
std::forward_as_tuple(std::move(*scf), ports_dir / spec));
return it.first->second;
}
Checks::exit_with_message(VCPKG_LINE_INFO,
"Error: Failed to load port from %s: names did not match: '%s' != '%s'",
(ports_dir / spec).u8string(),
spec,
scf->get()->core_paragraph->name);
}
else
{
vcpkg::print_error_message(found_scf.error());
Checks::exit_with_message(
VCPKG_LINE_INFO, "Error: Failed to load port from %s", spec, ports_dir.u8string());
}
}
}
Expand Down

0 comments on commit 5162592

Please sign in to comment.