]> git.tdb.fi Git - builder.git/commitdiff
Make Target::build virtual and move the unlink call to FileTarget
authorMikko Rasa <tdb@tdb.fi>
Sun, 15 Jul 2012 12:10:37 +0000 (15:10 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 15 Jul 2012 14:05:48 +0000 (17:05 +0300)
source/filetarget.cpp
source/filetarget.h
source/target.cpp
source/target.h

index adbb058dc3d192483bbfa7c03f9d042f1e8dcfdb..9908c0d4d2836c36c5e05e1eda9aa221bab067b2 100644 (file)
@@ -82,3 +82,11 @@ void FileTarget::check_rebuild()
        if(!needs_rebuild() && package && package->get_config().get_mtime()>mtime)
                mark_rebuild("Package options changed");
 }
        if(!needs_rebuild() && package && package->get_config().get_mtime()>mtime)
                mark_rebuild("Package options changed");
 }
+
+Task *FileTarget::build()
+{
+       if(tool && !builder.get_dry_run() && mtime)
+               FS::unlink(path);
+
+       return Target::build();
+}
index 2be0063c936f20bb5670a5ce16e02425e6e1d0d1..2319066b05acbb6994cc2082365ad8fd06449091 100644 (file)
@@ -37,6 +37,9 @@ public:
 
 protected:
        virtual void check_rebuild();
 
 protected:
        virtual void check_rebuild();
+
+public:
+       virtual Task *build();
 };
 
 #endif
 };
 
 #endif
index b0273e9ff535d9a5a80d0d6ecee5948245298b8c..cf4fae93d2aa3c851ea54627f4ec124fd3864ac4 100644 (file)
@@ -115,11 +115,6 @@ Task *Target::build()
                return 0;
        }
 
                return 0;
        }
 
-       // XXX Minor breach of OO here
-       if(FileTarget *ft = dynamic_cast<FileTarget *>(this))
-               if(!builder.get_dry_run() && FS::exists(ft->get_path()))
-                       FS::unlink(ft->get_path());
-
        Task *task = tool->run(*this);
        task->signal_finished.connect(sigc::mem_fun(this, &Target::build_finished));
        state = BUILDING;
        Task *task = tool->run(*this);
        task->signal_finished.connect(sigc::mem_fun(this, &Target::build_finished));
        state = BUILDING;
index ccc616bb464a50a950888040bf41e058d92a1790..a649e92e157057459e8dbcce918897eb417b053b 100644 (file)
@@ -117,7 +117,7 @@ public:
 
        /** Invokes the associated Tool to build the target and returns the
        resulting Task.  The task must be started by the caller. */
 
        /** Invokes the associated Tool to build the target and returns the
        resulting Task.  The task must be started by the caller. */
-       Task *build();
+       virtual Task *build();
 
 protected:
        /** Handler for Task::signal_finished. */
 
 protected:
        /** Handler for Task::signal_finished. */