X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftarget.cpp;h=b24013aaf55eabb094c72ef912480a956c6a9ae8;hb=242c55b17e6608b29a77ca17a5b677e202a3ca90;hp=07620502f4be2cbe21eafde8b5dab5de870d9668;hpb=77461a8c0e2b5686b04cf15f3a9333b215813992;p=builder.git diff --git a/source/target.cpp b/source/target.cpp index 0762050..b24013a 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -17,11 +17,24 @@ Distributed under the LGPL using namespace std; using namespace Msp; -/** -Tries to locate a target that will help getting this target built. If all -dependencies are up-to-date, returns this target. If there are no targets -ready to be built (maybe because they are being built right now), returns 0. -*/ +Target::Target(Builder &b, const Package *p, const string &n): + builder(b), + package(p), + name(n), + buildable(false), + building(false), + rebuild(false), + deps_ready(false), + prepared(false), + counted(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(!rebuild) @@ -51,11 +64,6 @@ void Target::add_depend(Target *dep) dep->rdepends.push_back(this); } -/** -Prepares the target by recursively preparing dependencies, then checking -whether rebuilding is needed. A flag is used to prevent unnecessary -executions. -*/ void Target::prepare() { if(prepared) @@ -91,10 +99,6 @@ Action *Target::build() return action; } -/** -Returns the number of targets that need to be rebuilt in order to get this -target up-to-date. -*/ unsigned Target::count_rebuild() { if(counted) @@ -107,41 +111,17 @@ unsigned Target::count_rebuild() return count; } -/** -Changes the mtime of the target to the current time. -*/ void Target::touch() { mtime=Time::now(); } -Target::Target(Builder &b, const Package *p, const string &n): - builder(b), - package(p), - name(n), - buildable(false), - building(false), - rebuild(false), - deps_ready(false), - prepared(false), - counted(false) -{ - builder.add_target(this); - - struct stat st; - if(!FS::stat(name, st)) - mtime=Time::TimeStamp::from_unixtime(st.st_mtime); -} - void Target::mark_rebuild(const std::string &reason) { rebuild=true; rebuild_reason=reason; } -/** -Checks if this target needs to be rebuilt and why. -*/ void Target::check_rebuild() { if(!buildable) @@ -167,9 +147,6 @@ void Target::check_rebuild() mark_rebuild("Package options changed"); } -/** -Handles for the build_done signal of Action. -*/ void Target::build_done() { building=false;