X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanalyzer.cpp;h=94f7782e2848632906b78360384ad1ed365295c8;hb=aa053d637e8259755af7d2e4b510a242f4d29c7b;hp=39cc7e183974ff6e2894289386127bd5c902bebc;hpb=373e9bb43c24d38316c5bb0393f4a369563319d3;p=builder.git diff --git a/source/analyzer.cpp b/source/analyzer.cpp index 39cc7e1..94f7782 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "analyzer.h" @@ -24,12 +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); + 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); } } @@ -43,15 +44,14 @@ void Analyzer::analyze() row.push_back("Rebuild"); table.push_back(row); - Target &cmdline = *builder.get_build_graph().get_target("cmdline"); + Target &goals = builder.get_build_graph().get_goals(); if(mode==RDEPS) { - const Target::Dependencies &deps = cmdline.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(cmdline, 0); + build_depend_table(goals, 0); print_table(); } @@ -109,12 +109,16 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) depends.assign(rdeps.begin(), rdeps.end()); } else + { depends = tgt.get_dependencies(); + const Target::Dependencies &tdeps = tgt.get_transitive_dependencies(); + 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); } } @@ -123,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); }