1 #include <msp/path/utils.h>
2 #include <msp/time/utils.h>
11 Target *Target::get_buildable_target()
14 for(list<Target *>::iterator i=depends.begin(); i!=depends.end(); ++i)
16 Target *tgt=(*i)->get_buildable_target();
19 else if((*i)->get_rebuild())
23 if(self_ok && rebuild && !building)
29 void Target::add_depend(Target *dep)
31 depends.push_back(dep);
32 dep->rdepends.push_back(this);
35 void Target::prepare()
40 for(list<Target *>::iterator i=depends.begin(); i!=depends.end(); ++i)
46 unsigned Target::count_rebuild()
52 unsigned count=rebuild;
53 for(list<Target *>::iterator i=depends.begin(); i!=depends.end(); ++i)
54 count+=(*i)->count_rebuild();
63 Target::Target(Builder &b, const Package *p, const string &n):
75 if(!Path::stat(name, st))
76 mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
79 void Target::mark_rebuild(const std::string &reason)
82 rebuild_reason=reason;
85 void Target::check_rebuild()
90 if(builder.get_build_all())
91 mark_rebuild("Rebuilding everything");
93 mark_rebuild("Does not exist");
96 for(list<Target *>::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
98 if((*i)->get_mtime()>mtime)
99 mark_rebuild(Path::basename((*i)->get_name())+" has changed");
100 else if((*i)->get_rebuild())
101 mark_rebuild(Path::basename((*i)->get_name())+" needs rebuilding");
104 if(!rebuild && package && package->get_config().get_mtime()>mtime)
105 mark_rebuild("Package options changed");
108 Action *Target::build(Action *action)
111 action->signal_done.connect(sigc::mem_fun(this, &Target::build_done));
115 void Target::build_done()