X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanalyzer.cpp;h=94f7782e2848632906b78360384ad1ed365295c8;hb=aa053d637e8259755af7d2e4b510a242f4d29c7b;hp=2c9cf058d7a565d3849acca028e150d878f4e85c;hpb=55269a63b0875be0b172453714f9190d30fb1dff;p=builder.git diff --git a/source/analyzer.cpp b/source/analyzer.cpp index 2c9cf05..94f7782 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "analyzer.h" @@ -24,15 +25,12 @@ void Analyzer::analyze() if(mode==RDEPS) { rdepends.clear(); - const BuildGraph::TargetMap &targets = builder.get_build_graph().get_targets(); - for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) + for(const auto &kvp: builder.get_build_graph().get_targets()) { - const Target::Dependencies &depends = i->second->get_dependencies(); - for(Target::Dependencies::const_iterator j=depends.begin(); j!=depends.end(); ++j) - rdepends[*j].insert(i->second); - const Target::Dependencies &tdepends = i->second->get_transitive_dependencies(); - for(Target::Dependencies::const_iterator j=tdepends.begin(); j!=tdepends.end(); ++j) - rdepends[*j].insert(i->second); + for(Target *d: kvp.second->get_dependencies()) + rdepends[d].insert(kvp.second); + for(Target *d: kvp.second->get_transitive_dependencies()) + rdepends[d].insert(kvp.second); } } @@ -49,9 +47,8 @@ void Analyzer::analyze() Target &goals = builder.get_build_graph().get_goals(); if(mode==RDEPS) { - const Target::Dependencies &deps = goals.get_dependencies(); - for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i) - build_depend_table(**i, 0); + for(Target *d: goals.get_dependencies()) + build_depend_table(*d, 0); } else build_depend_table(goals, 0); @@ -118,10 +115,10 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) depends.insert(depends.end(), tdeps.begin(), tdeps.end()); } - depends.sort(full_paths ? target_order_full : target_order); + sort(depends, (full_paths ? target_order_full : target_order)); - for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) - build_depend_table(**i, depth+1); + for(Target *d: depends) + build_depend_table(*d, depth+1); } } @@ -130,22 +127,22 @@ void Analyzer::print_table() const vector col_width; // Determine column widths - for(Table::const_iterator i=table.begin(); i!=table.end(); ++i) + for(const vector &r: table) { - if(col_width.size()size()) - col_width.resize(i->size(), 0); - for(unsigned j=0; jsize(); ++j) - col_width[j] = max(col_width[j], (*i)[j].size()); + if(col_width.size() &r: table) { string line; - for(unsigned j=0; jsize(); ++j) + for(unsigned j=0; j0) line += " "; - line += lexical_cast((*i)[j], Fmt("%-s").width(col_width[j])); + line += lexical_cast(r[j], Fmt("%-s").width(col_width[j])); } IO::print("%s\n", line); }