aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-09-21 15:21:53 +0000
committerMike Buland <eichlan@xagasoft.com>2006-09-21 15:21:53 +0000
commitd5b78aeaa9af689b52046eb5577624fb6d031835 (patch)
tree43271fd845413fc1913e17e4799b9ccc4aa6002b /src
parent2b24eab3703bedb2aa4f1329fc3c919c869b6e85 (diff)
downloadbuild-d5b78aeaa9af689b52046eb5577624fb6d031835.tar.gz
build-d5b78aeaa9af689b52046eb5577624fb6d031835.tar.bz2
build-d5b78aeaa9af689b52046eb5577624fb6d031835.tar.xz
build-d5b78aeaa9af689b52046eb5577624fb6d031835.zip
Auto target chaining based on requirements is now in place. This means that if
a requirement is set for a target that needs to be built, and that requirement is another target, that target will be processed when it is needed.
Diffstat (limited to '')
-rw-r--r--src/build.cpp21
-rw-r--r--src/build.h2
-rw-r--r--src/target.cpp19
-rw-r--r--src/target.h10
-rw-r--r--src/targetfile.cpp1
5 files changed, 42 insertions, 11 deletions
diff --git a/src/build.cpp b/src/build.cpp
index c81c885..5121d1f 100644
--- a/src/build.cpp
+++ b/src/build.cpp
@@ -86,16 +86,8 @@ void Build::execAction( const std::string &sWhat )
86 ); 86 );
87 Target *pTarget = mTarget[pAct->getWhat()]; 87 Target *pTarget = mTarget[pAct->getWhat()];
88 pView->beginCommand( pAct->getAct(), pAct->getWhat() ); 88 pView->beginCommand( pAct->getAct(), pAct->getWhat() );
89 switch( pAct->getAct() ) 89 if( !pTarget->wasRun() )
90 { 90 pTarget->run( pAct->getAct(), *this );
91 case Action::actCheck:
92 pTarget->check( *this );
93 break;
94
95 case Action::actClean:
96 pTarget->clean( *this );
97 break;
98 }
99 pView->endCommand(); 91 pView->endCommand();
100 } 92 }
101 93
@@ -363,3 +355,12 @@ void Build::updateCache( const std::string &sID, FunctionList &lFunc, StringList
363 bCacheUpdated = true; 355 bCacheUpdated = true;
364} 356}
365 357
358void Build::chainTarget( const std::string &sName )
359{
360 TargetMap::iterator i = mTarget.find(sName);
361 if( i == mTarget.end() ) return;
362
363 if( !(*i).second->wasRun() )
364 (*i).second->run( Action::actCheck, *this );
365}
366
diff --git a/src/build.h b/src/build.h
index 9229617..6e98405 100644
--- a/src/build.h
+++ b/src/build.h
@@ -74,6 +74,8 @@ public:
74 bool getCached( const std::string &sID, int nTime, StringList &lOut ); 74 bool getCached( const std::string &sID, int nTime, StringList &lOut );
75 void updateCache( const std::string &sID, FunctionList &lFunc, StringList &lOut ); 75 void updateCache( const std::string &sID, FunctionList &lFunc, StringList &lOut );
76 76
77 void chainTarget( const std::string &sName );
78
77private: 79private:
78 TargetMap mTarget; 80 TargetMap mTarget;
79 ReqMap mRequires; 81 ReqMap mRequires;
diff --git a/src/target.cpp b/src/target.cpp
index 834dbaa..a26f76f 100644
--- a/src/target.cpp
+++ b/src/target.cpp
@@ -1,6 +1,7 @@
1#include "target.h" 1#include "target.h"
2 2
3Target::Target() 3Target::Target() :
4 bRun( false )
4{ 5{
5} 6}
6 7
@@ -8,3 +9,19 @@ Target::~Target()
8{ 9{
9} 10}
10 11
12void Target::run( Action::eAction nAct, Build &bld )
13{
14 bRun = true;
15
16 switch( nAct )
17 {
18 case Action::actCheck:
19 check( bld );
20 break;
21
22 case Action::actClean:
23 clean( bld );
24 break;
25 }
26}
27
diff --git a/src/target.h b/src/target.h
index 5325965..f51e0e0 100644
--- a/src/target.h
+++ b/src/target.h
@@ -6,6 +6,8 @@
6#include <string> 6#include <string>
7#include <list> 7#include <list>
8 8
9#include "action.h"
10
9typedef std::list<std::string> StringList; 11typedef std::list<std::string> StringList;
10 12
11class Build; 13class Build;
@@ -16,6 +18,7 @@ public:
16 Target(); 18 Target();
17 virtual ~Target(); 19 virtual ~Target();
18 20
21 void run( Action::eAction nAct, Build &bld );
19 virtual void check( Build &bld ) = 0; 22 virtual void check( Build &bld ) = 0;
20 virtual void clean( Build &bld ) = 0; 23 virtual void clean( Build &bld ) = 0;
21 24
@@ -44,10 +47,17 @@ public:
44 return lInput; 47 return lInput;
45 } 48 }
46 49
50 bool wasRun()
51 {
52 return bRun;
53 }
54
55
47private: 56private:
48 std::string sName; 57 std::string sName;
49 std::string sRule; 58 std::string sRule;
50 StringList lInput; 59 StringList lInput;
60 bool bRun;
51}; 61};
52 62
53#endif 63#endif
diff --git a/src/targetfile.cpp b/src/targetfile.cpp
index 6ea83d5..950fc7b 100644
--- a/src/targetfile.cpp
+++ b/src/targetfile.cpp
@@ -32,6 +32,7 @@ void TargetFile::check( Build &bld )
32 bool bExtras = false; 32 bool bExtras = false;
33 for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ ) 33 for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ )
34 { 34 {
35 bld.chainTarget( *j );
35 if( getTime( bld, *j ) > tTarget ) 36 if( getTime( bld, *j ) > tTarget )
36 { 37 {
37 bld.getView()->beginPerform( *i ); 38 bld.getView()->beginPerform( *i );