vector<string> Builder::collect_problems() const
{
+ vector<string> target_problems;
vector<string> problems;
- set<const Package *> broken_packages;
- set<const Component *> broken_components;
- set<const Tool *> broken_tools;
+ vector<const Package *> broken_packages;
+ vector<const Component *> broken_components;
+ vector<const Tool *> broken_tools;
for(const auto &kvp: build_graph.get_targets())
if(kvp.second->is_broken())
{
- for(const string &p: kvp.second->get_problems())
- problems.push_back(format("%s: %s", kvp.second->get_name(), p));
-
const Package *package = kvp.second->get_package();
- if(package && !package->get_problems().empty())
- broken_packages.insert(package);
+ if(package && package->is_broken())
+ collect_broken_packages(*package, broken_packages);
const Component *component = kvp.second->get_component();
- if(component && !component->get_problems().empty())
- broken_components.insert(component);
+ if(component && component->is_broken() && !any_equals(broken_components, component))
+ {
+ broken_components.push_back(component);
+ collect_broken_packages(component->get_package(), broken_packages);
+ for(const Package *r: component->get_required_packages())
+ if(r->is_broken())
+ collect_broken_packages(*r, broken_packages);
+ }
const Tool *tool = kvp.second->get_tool();
- if(tool && !tool->get_problems().empty())
- broken_tools.insert(tool);
+ if(tool && tool->is_broken() && !any_equals(broken_tools, tool))
+ {
+ broken_tools.push_back(tool);
+ for(const string &p: tool->get_problems())
+ problems.push_back(format("%s: %s", tool->get_tag(), p));
+ }
+
+ for(const string &p: kvp.second->get_problems())
+ target_problems.push_back(format("%s: %s", kvp.second->get_name(), p));
}
- // TODO Sort components after their packages, and targets last
for(const Package *p: broken_packages)
+ {
for(const string &b: p->get_problems())
problems.push_back(format("%s: %s", p->get_name(), b));
- for(const Component *c: broken_components)
- for(const string &b: c->get_problems())
- problems.push_back(format("%s/%s: %s", c->get_package().get_name(), c->get_name(), b));
+ for(const Component *c: broken_components)
+ if(&c->get_package()==p)
+ {
+ for(const string &b: c->get_problems())
+ problems.push_back(format("%s/%s: %s", p->get_name(), c->get_name(), b));
+ }
+ }
- for(const Tool *t: broken_tools)
- for(const string &b: t->get_problems())
- problems.push_back(format("%s: %s", t->get_tag(), b));
+ problems.insert(problems.end(), make_move_iterator(target_problems.begin()), make_move_iterator(target_problems.end()));
return problems;
}
+void Builder::collect_broken_packages(const Package &pkg, vector<const Package *> &broken) const
+{
+ if(any_equals(broken, &pkg))
+ return;
+
+ broken.push_back(&pkg);
+
+ for(const Package *r: pkg.get_required_packages())
+ if(r->is_broken())
+ collect_broken_packages(*r, broken);
+}
+
void Builder::load_build_file(const FS::Path &fn, const Config::InputOptions *opts, bool all)
{
IO::BufferedFile in(fn.str());