diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-09-07 22:49:40 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-09-07 22:49:40 +0000 |
commit | 71cc260a3ca6d3d0594fd4cadb0711ae3f142932 (patch) | |
tree | 0b270638890c3b3d45e998cf50cf895f2cad6af5 /src/build.cpp | |
parent | fe5de4801bfe7926e116585e2f71399cb664dfb2 (diff) | |
download | build-71cc260a3ca6d3d0594fd4cadb0711ae3f142932.tar.gz build-71cc260a3ca6d3d0594fd4cadb0711ae3f142932.tar.bz2 build-71cc260a3ca6d3d0594fd4cadb0711ae3f142932.tar.xz build-71cc260a3ca6d3d0594fd4cadb0711ae3f142932.zip |
About to implement Rule, the heart of the porform generation system. Once
that's done, we can actually run the performs, and, most likely build things.
Diffstat (limited to 'src/build.cpp')
-rw-r--r-- | src/build.cpp | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/src/build.cpp b/src/build.cpp index bf867af..372e607 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | subExceptionDef( BuildException ); | 3 | subExceptionDef( BuildException ); |
4 | 4 | ||
5 | 5 | Build::Build() : | |
6 | Build::Build() | 6 | pStrProc( NULL ) |
7 | { | 7 | { |
8 | } | 8 | } |
9 | 9 | ||
@@ -11,10 +11,52 @@ Build::~Build() | |||
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
14 | void Build::setStringProc( StringProc *pStrProc ) | ||
15 | { | ||
16 | delete this->pStrProc; | ||
17 | this->pStrProc = pStrProc; | ||
18 | } | ||
19 | |||
20 | std::string Build::replVars( const std::string &sSrc, const std::string &sCont ) | ||
21 | { | ||
22 | if( pStrProc == NULL ) | ||
23 | throw BuildException( | ||
24 | "No valid string processor was registered with the Build object." | ||
25 | ); | ||
26 | |||
27 | return pStrProc->replVars( sSrc, sCont ); | ||
28 | } | ||
29 | |||
14 | void Build::execAction( const std::string &sWhat ) | 30 | void Build::execAction( const std::string &sWhat ) |
15 | { | 31 | { |
16 | if( mAction.find( sWhat ) == mAction.end() ) | 32 | if( mAction.find( sWhat ) == mAction.end() ) |
17 | throw BuildException("No action matches %s.", sWhat.c_str() ); | 33 | throw BuildException( |
34 | "No action matches %s, check your build.conf.", | ||
35 | sWhat.c_str() | ||
36 | ); | ||
37 | |||
38 | Action *pAct = mAction[sWhat]; | ||
39 | |||
40 | for( pAct->begin(); !pAct->isEnded(); pAct->next() ) | ||
41 | { | ||
42 | if( mTarget.find( pAct->getWhat() ) == mTarget.end() ) | ||
43 | throw BuildException( | ||
44 | "No target matches %s in action %s.", | ||
45 | pAct->getWhat().c_str(), | ||
46 | sWhat.c_str() | ||
47 | ); | ||
48 | Target *pTarget = mTarget[pAct->getWhat()]; | ||
49 | switch( pAct->getAct() ) | ||
50 | { | ||
51 | case Action::actCheck: | ||
52 | pTarget->check( *this ); | ||
53 | break; | ||
54 | |||
55 | case Action::actClean: | ||
56 | pTarget->clean( *this ); | ||
57 | break; | ||
58 | } | ||
59 | } | ||
18 | 60 | ||
19 | return; | 61 | return; |
20 | } | 62 | } |
@@ -42,6 +84,14 @@ void Build::addRule( Rule *pRule ) | |||
42 | mRule[pRule->getName()] = pRule; | 84 | mRule[pRule->getName()] = pRule; |
43 | } | 85 | } |
44 | 86 | ||
87 | Rule *Build::getRule( const std::string &name ) | ||
88 | { | ||
89 | if( mRule.find( name ) == mRule.end() ) | ||
90 | throw BuildException("No rule named %s found.", name.c_str() ); | ||
91 | |||
92 | return mRule[name]; | ||
93 | } | ||
94 | |||
45 | void Build::addAction( Action *pAction ) | 95 | void Build::addAction( Action *pAction ) |
46 | { | 96 | { |
47 | mAction[pAction->getName()] = pAction; | 97 | mAction[pAction->getName()] = pAction; |