]> git.tdb.fi Git - builder.git/blobdiff - source/target.cpp
Add command line options (not all of them work yet)
[builder.git] / source / target.cpp
index b3dc50904717450c938f65f47add7b490073a317..d4c243120bbeb693f54abd6ff9674543f640b84b 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/path/utils.h>
+#include <msp/time/utils.h>
 #include "action.h"
 #include "builder.h"
 #include "package.h"
@@ -42,6 +43,23 @@ void Target::prepare()
        check_rebuild();
 }
 
+unsigned Target::count_rebuild()
+{
+       if(counted)
+               return 0;
+
+       counted=true;
+       unsigned count=rebuild;
+       for(list<Target *>::iterator i=depends.begin(); i!=depends.end(); ++i)
+               count+=(*i)->count_rebuild();
+       return count;
+}
+
+void Target::touch()
+{
+       mtime=Time::now();
+}
+
 Target::Target(Builder &b, const Package *p, const string &n):
        builder(b),
        package(p),
@@ -49,14 +67,12 @@ Target::Target(Builder &b, const Package *p, const string &n):
        building(false),
        rebuild(false),
        prepared(false),
-       buildable(false)
+       buildable(false),
+       counted(false)
 {
        struct stat st;
        if(!Path::stat(name, st))
-       {
                mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
-               vmtime=mtime;
-       }
 }
 
 void Target::mark_rebuild(const std::string &reason)
@@ -76,10 +92,10 @@ void Target::check_rebuild()
        {
                for(list<Target *>::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
                {
-                       if((*i)->get_virtual_mtime()>mtime)
-                               mark_rebuild((*i)->get_name()+" has changed");
+                       if((*i)->get_mtime()>mtime)
+                               mark_rebuild(Path::basename((*i)->get_name())+" has changed");
                        else if((*i)->get_rebuild())
-                               mark_rebuild((*i)->get_name()+" needs rebuilding");
+                               mark_rebuild(Path::basename((*i)->get_name())+" needs rebuilding");
                }
        }
        if(!rebuild && package && package->get_config().get_mtime()>mtime)