X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanalyzer.cpp;h=0db55c76b637942ba997bff9b2ee90d05237e58b;hb=7aeaa4ba965f596edad438c02e345a8843f7469a;hp=21ed52cec64b2cf463a62a1d9823870ea5917283;hpb=1a46151c99a406123c4ddfc797a7841baf3e4cc2;p=builder.git diff --git a/source/analyzer.cpp b/source/analyzer.cpp index 21ed52c..0db55c7 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of builder +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include #include @@ -14,10 +21,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 +43,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 && 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(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; @@ -74,16 +94,21 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) if(!max_depth || depth col_width; + // Determine column widths for(Table::const_iterator i=table.begin(); i!=table.end(); ++i) { if(col_width.size()size())