mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 04:29:01 +08:00
Improve error message on invalid dependency of package
This commit is contained in:
parent
705c8f2012
commit
d540915a3a
@ -22,6 +22,10 @@ namespace vcpkg
|
||||
|
||||
static std::vector<PackageSpec> to_package_specs(const std::vector<std::string>& ports, const Triplet& triplet);
|
||||
|
||||
static std::vector<PackageSpec> from_dependencies_of_port(const std::string& port,
|
||||
const std::vector<std::string>& dependencies,
|
||||
const Triplet& triplet);
|
||||
|
||||
const std::string& name() const;
|
||||
|
||||
const Triplet& triplet() const;
|
||||
|
@ -114,19 +114,19 @@ namespace vcpkg::Dependencies
|
||||
{
|
||||
if (const auto p = this->status_paragraph.get())
|
||||
{
|
||||
return PackageSpec::to_package_specs(p->package.depends, triplet);
|
||||
return PackageSpec::from_dependencies_of_port(p->package.spec.name(), p->package.depends, triplet);
|
||||
}
|
||||
|
||||
if (const auto p = this->binary_control_file.get())
|
||||
{
|
||||
auto deps = Util::fmap_flatten(p->features, [](const BinaryParagraph& pgh) { return pgh.depends; });
|
||||
deps.insert(deps.end(), p->core_paragraph.depends.cbegin(), p->core_paragraph.depends.cend());
|
||||
return PackageSpec::to_package_specs(deps, triplet);
|
||||
return PackageSpec::from_dependencies_of_port(p->core_paragraph.spec.name(), deps, triplet);
|
||||
}
|
||||
|
||||
if (const auto p = this->source_paragraph.get())
|
||||
{
|
||||
return PackageSpec::to_package_specs(filter_dependencies(p->depends, triplet), triplet);
|
||||
return PackageSpec::from_dependencies_of_port(p->name, filter_dependencies(p->depends, triplet), triplet);
|
||||
}
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
|
@ -96,8 +96,8 @@ namespace vcpkg
|
||||
std::vector<PackageSpec> PackageSpec::to_package_specs(const std::vector<std::string>& ports,
|
||||
const Triplet& triplet)
|
||||
{
|
||||
return Util::fmap(ports, [&](const std::string& s) -> PackageSpec {
|
||||
auto maybe_spec = PackageSpec::from_name_and_triplet(s, triplet);
|
||||
return Util::fmap(ports, [&](const std::string& spec_as_string) -> PackageSpec {
|
||||
auto maybe_spec = PackageSpec::from_name_and_triplet(spec_as_string, triplet);
|
||||
if (auto spec = maybe_spec.get())
|
||||
{
|
||||
return std::move(*spec);
|
||||
@ -107,7 +107,28 @@ namespace vcpkg
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Invalid package: %s\n"
|
||||
"%s",
|
||||
s,
|
||||
spec_as_string,
|
||||
vcpkg::to_string(error_type));
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<PackageSpec> PackageSpec::from_dependencies_of_port(const std::string& port,
|
||||
const std::vector<std::string>& dependencies,
|
||||
const Triplet& triplet)
|
||||
{
|
||||
return Util::fmap(dependencies, [&](const std::string& spec_as_string) -> PackageSpec {
|
||||
auto maybe_spec = PackageSpec::from_name_and_triplet(spec_as_string, triplet);
|
||||
if (auto spec = maybe_spec.get())
|
||||
{
|
||||
return std::move(*spec);
|
||||
}
|
||||
|
||||
const PackageSpecParseResult error_type = maybe_spec.error();
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Invalid dependency [%s] in package [%s]\n"
|
||||
"%s",
|
||||
spec_as_string,
|
||||
port,
|
||||
vcpkg::to_string(error_type));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user