]> git.tdb.fi Git - builder.git/blobdiff - source/analyzer.cpp
Refactor transitive dependencies to work on all targets
[builder.git] / source / analyzer.cpp
diff --git a/source/analyzer.cpp b/source/analyzer.cpp
deleted file mode 100644 (file)
index 21ed52c..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#include <iomanip>
-#include <iostream>
-#include <sstream>
-#include <msp/path/path.h>
-#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),
-       max_depth(0),
-       full_paths(false)
-{ }
-
-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();
-}
-
-void Analyzer::build_depend_table(Target &tgt, unsigned depth)
-{
-       if(mode!=REBUILD && mode!=ALLDEPS)
-       {
-               if(dynamic_cast<ObjectFile *>(&tgt))
-                       return build_depend_table(*tgt.get_depends().front(), depth);
-               else if(dynamic_cast<Install *>(&tgt))
-                       return build_depend_table(*tgt.get_depends().front(), depth);
-       }
-       else if(mode==REBUILD && !tgt.get_rebuild())
-               return;
-       
-       TableRow row;
-
-       string fn;
-       if(full_paths)
-               fn=tgt.get_name();
-       else
-               fn=Path::Path(tgt.get_name())[-1];
-       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<max_depth-1)
-       {
-               const TargetList &depends=tgt.get_depends();
-               //depends.sort(target_order);
-               for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i)
-                       build_depend_table(**i, depth+1);
-       }
-}
-
-void Analyzer::print_table() const
-{
-       vector<unsigned> col_width;
-
-       for(Table::const_iterator i=table.begin(); i!=table.end(); ++i)
-       {
-               if(col_width.size()<i->size())
-                       col_width.resize(i->size(), 0);
-               for(unsigned j=0; j<i->size(); ++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<<left;
-               for(unsigned j=0; j<i->size(); ++j)
-               {
-                       if(j>0)
-                               ss<<"  ";
-                       ss<<setw(col_width[j])<<(*i)[j];
-               }
-               cout<<ss.str()<<'\n';
-       }
-}
-
-bool Analyzer::target_order(Target *t1, Target *t2)
-{ return t1->get_name()<t2->get_name(); }