1 #include <msp/fs/stat.h>
2 #include <msp/fs/utils.h>
5 #include "filetarget.h"
12 Target::Target(Builder &b, const Package *p, const string &n):
24 Target *Target::get_buildable_target()
29 bool self_ok = !building;
30 for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
32 Target *tgt = (*i)->get_buildable_target();
35 else if((*i)->get_rebuild())
45 void Target::add_depend(Target *dep)
48 throw invalid_argument("Target::add_depend");
49 depends.push_back(dep);
52 void Target::prepare()
58 builder.problem((package ? package->get_name() : string()), "Dependency cycle detected at "+name);
63 for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
71 Action *Target::build()
79 // XXX Minor breach of OO here
80 if(FileTarget *ft = dynamic_cast<FileTarget *>(this))
81 if(!builder.get_dry_run() && FS::exists(ft->get_path()))
82 FS::unlink(ft->get_path());
84 Action *action = create_action();
87 action->signal_done.connect(sigc::mem_fun(this, &Target::build_done));
95 void Target::mark_rebuild(const std::string &reason)
98 rebuild_reason = reason;
101 void Target::build_done()