#include <msp/time/utils.h>
#include "action.h"
#include "builder.h"
+#include "filetarget.h"
#include "package.h"
#include "sourcepackage.h"
#include "target.h"
building(false),
rebuild(false),
deps_ready(false),
- prepared(false),
- counted(false)
+ preparing(false),
+ prepared(false)
{
builder.add_target(this);
-
- struct stat st;
- if(!FS::stat(name, st))
- mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
}
Target *Target::get_buildable_target()
{
if(prepared)
return;
+ if(preparing)
+ {
+ builder.problem((package ? package->get_name() : string()), "Dependency cycle detected at "+name);
+ return;
+ }
- prepared=true;
+ preparing=true;
for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
(*i)->prepare();
check_rebuild();
-
+ preparing=false;
+ prepared=true;
}
Action *Target::build()
return 0;
}
- if(!builder.get_dry_run() && FS::exists(name))
- FS::unlink(name);
+ if(FileTarget *ft=dynamic_cast<FileTarget *>(this))
+ if(!builder.get_dry_run() && FS::exists(ft->get_path()))
+ FS::unlink(ft->get_path());
Action *action=create_action();
if(action)
return action;
}
-unsigned Target::count_rebuild()
-{
- if(counted)
- return 0;
-
- counted=true;
- unsigned count=rebuild;
- for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
- count+=(*i)->count_rebuild();
- return count;
-}
-
void Target::touch()
{
mtime=Time::now();