+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
#include <msp/path/utils.h>
#include <msp/time/utils.h>
#include "action.h"
*/
Target *Target::get_buildable_target()
{
- bool self_ok=true;
+ if(!rebuild)
+ return 0;
+
+ bool self_ok=!building;
for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
{
Target *tgt=(*i)->get_buildable_target();
self_ok=false;
}
- if(self_ok && rebuild && !building)
+ if(self_ok)
return this;
return 0;
void Target::add_depend(Target *dep)
{
+ if(dep==this)
+ throw InvalidParameterValue("A target can't depend on itself");
depends.push_back(dep);
dep->rdepends.push_back(this);
}
prepared(false),
counted(false)
{
+ builder.add_target(this);
+
struct stat st;
if(!Path::stat(name, st))
mtime=Time::TimeStamp::from_unixtime(st.st_mtime);