X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftarget.cpp;h=adde0cd180727b8ceb0a18d46455c60e3cf1f244;hb=7e5ac6af8987bf12f3e338d00e96e8cb74f3534b;hp=f2a1a1372e482489a24a1ce5bbf9de38dae011b6;hpb=c52efe77690dcf620d3b19f750a91422f771942d;p=builder.git diff --git a/source/target.cpp b/source/target.cpp index f2a1a13..adde0cd 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -1,10 +1,11 @@ #include #include -#include "action.h" #include "builder.h" #include "filetarget.h" #include "package.h" #include "target.h" +#include "task.h" +#include "tool.h" using namespace std; using namespace Msp; @@ -13,7 +14,7 @@ Target::Target(Builder &b, const Package *p, const string &n): builder(b), package(p), name(n), - buildable(false), + tool(0), building(false), rebuild(false), deps_ready(false), @@ -29,7 +30,7 @@ Target *Target::get_buildable_target() return 0; bool self_ok = !building; - for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) + for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i) { Target *tgt = (*i)->get_buildable_target(); if(tgt) @@ -44,6 +45,11 @@ Target *Target::get_buildable_target() return 0; } +void Target::set_tool(const Tool &t) +{ + tool = &t; +} + void Target::add_depend(Target *dep) { if(dep==this) @@ -62,7 +68,7 @@ void Target::prepare() } preparing = true; - for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) + for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i) (*i)->prepare(); check_rebuild(); @@ -70,9 +76,9 @@ void Target::prepare() prepared = true; } -Action *Target::build() +Task *Target::build() { - if(!buildable) + if(!tool) { rebuild = false; return 0; @@ -83,15 +89,11 @@ Action *Target::build() if(!builder.get_dry_run() && FS::exists(ft->get_path())) FS::unlink(ft->get_path()); - Action *action = create_action(); - if(action) - { - action->signal_done.connect(sigc::mem_fun(this, &Target::build_done)); - - building = true; - } + Task *task = tool->run(*this); + task->signal_finished.connect(sigc::mem_fun(this, &Target::build_finished)); + building = true; - return action; + return task; } void Target::mark_rebuild(const std::string &reason) @@ -100,7 +102,7 @@ void Target::mark_rebuild(const std::string &reason) rebuild_reason = reason; } -void Target::build_done() +void Target::build_finished(bool /*success*/) { building = false; rebuild = false;