1 #include <msp/fs/stat.h>
2 #include <msp/fs/utils.h>
4 #include "filetarget.h"
13 Target::Target(Builder &b, const string &n):
22 builder.add_target(this);
25 Target *Target::get_buildable_target()
30 bool self_ok = state!=BUILDING;
31 for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
33 Target *tgt = (*i)->get_buildable_target();
36 else if((*i)->needs_rebuild())
46 void Target::set_tool(const Tool &t)
51 void Target::add_depend(Target *dep)
54 throw invalid_argument("Target::add_depend");
55 depends.push_back(dep);
58 void Target::prepare()
64 builder.problem((package ? package->get_name() : string()), "Dependency cycle detected at "+name);
69 for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
85 // XXX Minor breach of OO here
86 if(FileTarget *ft = dynamic_cast<FileTarget *>(this))
87 if(!builder.get_dry_run() && FS::exists(ft->get_path()))
88 FS::unlink(ft->get_path());
90 Task *task = tool->run(*this);
91 task->signal_finished.connect(sigc::mem_fun(this, &Target::build_finished));
97 void Target::mark_rebuild(const std::string &reason)
100 rebuild_reason = reason;
103 void Target::build_finished(bool /*success*/)