1 #include <msp/fs/stat.h>
2 #include <msp/fs/utils.h>
4 #include "filetarget.h"
13 Target::Target(Builder &b, const Package *p, const string &n):
21 builder.add_target(this);
24 Target *Target::get_buildable_target()
29 bool self_ok = state!=BUILDING;
30 for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
32 Target *tgt = (*i)->get_buildable_target();
35 else if((*i)->needs_rebuild())
45 void Target::set_tool(const Tool &t)
50 void Target::add_depend(Target *dep)
53 throw invalid_argument("Target::add_depend");
54 depends.push_back(dep);
57 void Target::prepare()
63 builder.problem((package ? package->get_name() : string()), "Dependency cycle detected at "+name);
68 for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
84 // XXX Minor breach of OO here
85 if(FileTarget *ft = dynamic_cast<FileTarget *>(this))
86 if(!builder.get_dry_run() && FS::exists(ft->get_path()))
87 FS::unlink(ft->get_path());
89 Task *task = tool->run(*this);
90 task->signal_finished.connect(sigc::mem_fun(this, &Target::build_finished));
96 void Target::mark_rebuild(const std::string &reason)
99 rebuild_reason = reason;
102 void Target::build_finished(bool /*success*/)