diff options
Diffstat (limited to '')
| -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; | 
