Distributed under the LGPL
*/
-#include <iomanip>
-#include <iostream>
-#include <sstream>
#include <msp/fs/utils.h>
+#include <msp/io/print.h>
#include "analyzer.h"
#include "builder.h"
#include "install.h"
#include "objectfile.h"
#include "package.h"
+#include "sourcefile.h"
#include "target.h"
using namespace std;
void Analyzer::analyze()
{
+ table.clear();
+
TableRow row;
row.push_back("Name");
row.push_back("Package");
if(mode!=REBUILD && mode!=ALLDEPS)
{
// Skip trivial targets
- 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);
+ if(ObjectFile *obj=dynamic_cast<ObjectFile *>(&tgt))
+ return build_depend_table(obj->get_source(), depth);
+ else if(Install *inst=dynamic_cast<Install *>(&tgt))
+ return build_depend_table(inst->get_source(), depth);
}
else if(mode==REBUILD && !tgt.get_rebuild())
/* All targets that depend on to-be-built targets will be rebuilt
void Analyzer::print_table() const
{
- vector<unsigned> col_width;
+ vector<string::size_type> col_width;
// Determine column widths
for(Table::const_iterator i=table.begin(); i!=table.end(); ++i)
for(Table::const_iterator i=table.begin(); i!=table.end(); ++i)
{
- ostringstream ss;
- ss<<left;
+ string line;
for(unsigned j=0; j<i->size(); ++j)
{
if(j>0)
- ss<<" ";
- ss<<setw(col_width[j])<<(*i)[j];
+ line+=" ";
+ line+=lexical_cast((*i)[j], Fmt("%-s").width(col_width[j]));
}
- cout<<ss.str()<<'\n';
+ IO::print("%s\n", line);
}
}