From: Mikko Rasa Date: Sun, 15 Jul 2012 12:10:37 +0000 (+0300) Subject: Make Target::build virtual and move the unlink call to FileTarget X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8818c970f123a7fa44bf41bc60369217d083b4da;p=builder.git Make Target::build virtual and move the unlink call to FileTarget --- diff --git a/source/filetarget.cpp b/source/filetarget.cpp index adbb058..9908c0d 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -82,3 +82,11 @@ void FileTarget::check_rebuild() 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(); +} diff --git a/source/filetarget.h b/source/filetarget.h index 2be0063..2319066 100644 --- a/source/filetarget.h +++ b/source/filetarget.h @@ -37,6 +37,9 @@ public: protected: virtual void check_rebuild(); + +public: + virtual Task *build(); }; #endif diff --git a/source/target.cpp b/source/target.cpp index b0273e9..cf4fae9 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -115,11 +115,6 @@ Task *Target::build() return 0; } - // XXX Minor breach of OO here - if(FileTarget *ft = dynamic_cast(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; diff --git a/source/target.h b/source/target.h index ccc616b..a649e92 100644 --- a/source/target.h +++ b/source/target.h @@ -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. */ - Task *build(); + virtual Task *build(); protected: /** Handler for Task::signal_finished. */