3 This file is part of builder
4 Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/fs/stat.h>
9 #include <msp/fs/utils.h>
12 #include "filetarget.h"
19 Target::Target(Builder &b, const Package *p, const string &n):
31 Target *Target::get_buildable_target()
36 bool self_ok = !building;
37 for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
39 Target *tgt = (*i)->get_buildable_target();
42 else if((*i)->get_rebuild())
52 void Target::add_depend(Target *dep)
55 throw InvalidParameterValue("A target can't depend on itself");
56 depends.push_back(dep);
59 void Target::prepare()
65 builder.problem((package ? package->get_name() : string()), "Dependency cycle detected at "+name);
70 for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
78 Action *Target::build()
86 // XXX Minor breach of OO here
87 if(FileTarget *ft = dynamic_cast<FileTarget *>(this))
88 if(!builder.get_dry_run() && FS::exists(ft->get_path()))
89 FS::unlink(ft->get_path());
91 Action *action = create_action();
94 action->signal_done.connect(sigc::mem_fun(this, &Target::build_done));
102 void Target::mark_rebuild(const std::string &reason)
105 rebuild_reason = reason;
108 void Target::build_done()