X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanalyzer.cpp;h=e2b25bd6260bfdce4ede32c615dad72a6079b10b;hb=55b6c1dba6f02a399d98080c23a75098e8a080f7;hp=a4780fd697dd451fae6afa5ddc6efce020f9be9a;hpb=0d80cabf649b931b26e7055385156c75a7385d35;p=builder.git diff --git a/source/analyzer.cpp b/source/analyzer.cpp index a4780fd..e2b25bd 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -14,10 +14,14 @@ using namespace Msp; Analyzer::Analyzer(Builder &b): builder(b), + mode(DEPS), max_depth(0), full_paths(false) { } +/** +Performs the analysis and prints out the resulting dependency tree. +*/ void Analyzer::analyze() { TableRow row; @@ -32,16 +36,25 @@ void Analyzer::analyze() print_table(); } +/** +Adds rows to the table for the given target and it' dependencies. + +@param tgt Target to be processed +@param depth Recursion level of the target (top level is 0) +*/ void Analyzer::build_depend_table(Target &tgt, unsigned depth) { - if(mode!=REBUILD) + if(mode!=REBUILD && mode!=ALLDEPS) { + // Skip trivial targets if(dynamic_cast(&tgt)) return build_depend_table(*tgt.get_depends().front(), depth); else if(dynamic_cast(&tgt)) return build_depend_table(*tgt.get_depends().front(), depth); } - else if(!tgt.get_rebuild()) + else if(mode==REBUILD && !tgt.get_rebuild()) + /* All targets that depend on to-be-built targets will be rebuilt + themselves, so we cn stop here. */ return; TableRow row; @@ -73,17 +86,22 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) if(!max_depth || depth &depends=tgt.get_depends(); + const TargetList &depends=tgt.get_depends(); + //XXX If we want to sort the targets, we need to take the value of full_paths into account //depends.sort(target_order); - for(list::const_iterator i=depends.begin(); i!=depends.end(); ++i) + for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i) build_depend_table(**i, depth+1); } } +/** +Prints out the table that resulted from the analysis. +*/ void Analyzer::print_table() const { vector col_width; + // Determine column widths for(Table::const_iterator i=table.begin(); i!=table.end(); ++i) { if(col_width.size()size())