X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanalyzer.cpp;h=2c9cf058d7a565d3849acca028e150d878f4e85c;hb=HEAD;hp=a86a9a219125d3458a22d349bfead7ed2aedc5e5;hpb=a2adbd9c0a8d7a7567848c4c6bdbf0de6ba32bb1;p=builder.git diff --git a/source/analyzer.cpp b/source/analyzer.cpp deleted file mode 100644 index a86a9a2..0000000 --- a/source/analyzer.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include -#include -#include -#include -#include "analyzer.h" -#include "builder.h" -#include "install.h" -#include "objectfile.h" -#include "package.h" -#include "target.h" - -using namespace std; -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; - row.push_back("Name"); - row.push_back("Package"); - row.push_back("Type"); - row.push_back("Rebuild"); - table.push_back(row); - - build_depend_table(*builder.get_target("cmdline"), 0); - - 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; - - string fn; - if(full_paths) - fn=tgt.get_name(); - else - fn=FS::basename(tgt.get_name()); - row.push_back(string(depth*2, ' ')+fn); - - const Package *pkg=tgt.get_package(); - if(pkg) - row.push_back(pkg->get_name()); - else - row.push_back(""); - - row.push_back(tgt.get_type()); - - if(tgt.get_rebuild()) - { - if(tgt.get_rebuild_reason().empty()) - row.push_back("Yes (no reason)"); - else - row.push_back(tgt.get_rebuild_reason()); - } - - table.push_back(row); - - 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()) - col_width.resize(i->size(), 0); - for(unsigned j=0; jsize(); ++j) - col_width[j]=max(col_width[j], (*i)[j].size()); - } - - for(Table::const_iterator i=table.begin(); i!=table.end(); ++i) - { - ostringstream ss; - ss<size(); ++j) - { - if(j>0) - ss<<" "; - ss<get_name()get_name(); }