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):
23 builder.add_target(this);
26 Target *Target::get_buildable_target()
31 bool self_ok = !building;
32 for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
34 Target *tgt = (*i)->get_buildable_target();
37 else if((*i)->get_rebuild())
47 void Target::add_depend(Target *dep)
50 throw invalid_argument("Target::add_depend");
51 depends.push_back(dep);
54 void Target::prepare()
60 builder.problem((package ? package->get_name() : string()), "Dependency cycle detected at "+name);
65 for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
73 Action *Target::build()
81 // XXX Minor breach of OO here
82 if(FileTarget *ft = dynamic_cast<FileTarget *>(this))
83 if(!builder.get_dry_run() && FS::exists(ft->get_path()))
84 FS::unlink(ft->get_path());
86 Action *action = create_action();
89 action->signal_done.connect(sigc::mem_fun(this, &Target::build_done));
97 void Target::mark_rebuild(const std::string &reason)
100 rebuild_reason = reason;
103 void Target::build_done()