]> git.tdb.fi Git - builder.git/blobdiff - source/analyzer.cpp
Rework the Target class hierarchy
[builder.git] / source / analyzer.cpp
index f694edb96198494aadcceeb258950417bb708c90..6664477598d653aa3d4a05950a08c62a808e6a42 100644 (file)
@@ -1,20 +1,20 @@
 /* $Id$
 
 This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2006-200 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
 #include <iomanip>
 #include <iostream>
 #include <sstream>
-#include <msp/path/path.h>
-#include <msp/path/utils.h>
+#include <msp/fs/utils.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;
@@ -27,9 +27,6 @@ Analyzer::Analyzer(Builder &b):
        full_paths(false)
 { }
 
-/**
-Performs the analysis and prints out the resulting dependency tree.
-*/
 void Analyzer::analyze()
 {
        TableRow row;
@@ -44,25 +41,19 @@ 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<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
-                  themselves, so we cn stop here. */
+               themselves, so we cn stop here. */
                return;
        
        TableRow row;
@@ -71,7 +62,7 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth)
        if(full_paths)
                fn=tgt.get_name();
        else
-               fn=basename(tgt.get_name());
+               fn=FS::basename(tgt.get_name());
        row.push_back(string(depth*2, ' ')+fn);
 
        const Package *pkg=tgt.get_package();
@@ -102,9 +93,6 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth)
        }
 }
 
-/**
-Prints out the table that resulted from the analysis.
-*/
 void Analyzer::print_table() const
 {
        vector<unsigned> col_width;