diff options
-rw-r--r-- | src/build.cpp | 56 | ||||
-rw-r--r-- | src/build.h | 7 | ||||
-rw-r--r-- | src/buildparser.cpp | 2 | ||||
-rw-r--r-- | src/rule.cpp | 4 | ||||
-rw-r--r-- | src/rule.h | 2 | ||||
-rw-r--r-- | src/stringprocbuild.cpp | 2 | ||||
-rw-r--r-- | src/target.h | 5 | ||||
-rw-r--r-- | src/targetfile.cpp | 16 | ||||
-rw-r--r-- | src/targetfile.h | 3 |
9 files changed, 94 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; |
diff --git a/src/build.h b/src/build.h index 77e40fa..d5e6604 100644 --- a/src/build.h +++ b/src/build.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "rule.h" | 10 | #include "rule.h" |
11 | #include "target.h" | 11 | #include "target.h" |
12 | #include "action.h" | 12 | #include "action.h" |
13 | #include "stringproc.h" | ||
13 | 14 | ||
14 | subExceptionDecl( BuildException ); | 15 | subExceptionDecl( BuildException ); |
15 | 16 | ||
@@ -36,8 +37,13 @@ public: | |||
36 | void setAdd( const std::string &cont, const std::string &var, const std::string &val ); | 37 | void setAdd( const std::string &cont, const std::string &var, const std::string &val ); |
37 | std::string getVar( const std::string &cont, const std::string &var ); | 38 | std::string getVar( const std::string &cont, const std::string &var ); |
38 | 39 | ||
40 | Rule *getRule( const std::string &name ); | ||
41 | |||
39 | void debugDump(); | 42 | void debugDump(); |
40 | 43 | ||
44 | void setStringProc( StringProc *pStrProc ); | ||
45 | std::string replVars( const std::string &sSrc, const std::string &sCont ); | ||
46 | |||
41 | private: | 47 | private: |
42 | typedef std::map<std::string, Target *> TargetMap; | 48 | typedef std::map<std::string, Target *> TargetMap; |
43 | typedef std::list<std::string> StringList; | 49 | typedef std::list<std::string> StringList; |
@@ -53,6 +59,7 @@ private: | |||
53 | ContextMap mContVars; | 59 | ContextMap mContVars; |
54 | RuleMap mRule; | 60 | RuleMap mRule; |
55 | ActionMap mAction; | 61 | ActionMap mAction; |
62 | StringProc *pStrProc; | ||
56 | 63 | ||
57 | //std::map<std::string, Rule *> mRule; | 64 | //std::map<std::string, Rule *> mRule; |
58 | //Action *pActDefault; | 65 | //Action *pActDefault; |
diff --git a/src/buildparser.cpp b/src/buildparser.cpp index 90e21e2..f855990 100644 --- a/src/buildparser.cpp +++ b/src/buildparser.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "action.h" | 5 | #include "action.h" |
6 | #include "build.h" | 6 | #include "build.h" |
7 | #include "rule.h" | 7 | #include "rule.h" |
8 | #include "stringprocbuild.h" | ||
8 | 9 | ||
9 | BuildParser::BuildParser() : | 10 | BuildParser::BuildParser() : |
10 | fFunction( FunctionFactory::getInstance() ), | 11 | fFunction( FunctionFactory::getInstance() ), |
@@ -343,6 +344,7 @@ void BuildParser::printBuildList( const BuildList &lst ) | |||
343 | Build *BuildParser::genBuild() | 344 | Build *BuildParser::genBuild() |
344 | { | 345 | { |
345 | Build *bld = new Build; | 346 | Build *bld = new Build; |
347 | bld->setStringProc( new StringProcBuild( bld ) ); | ||
346 | 348 | ||
347 | for( SetVarList::iterator i = lGlobalVars.begin(); | 349 | for( SetVarList::iterator i = lGlobalVars.begin(); |
348 | i != lGlobalVars.end(); i++ ) | 350 | i != lGlobalVars.end(); i++ ) |
diff --git a/src/rule.cpp b/src/rule.cpp index 2212936..4426575 100644 --- a/src/rule.cpp +++ b/src/rule.cpp | |||
@@ -8,3 +8,7 @@ Rule::~Rule() | |||
8 | { | 8 | { |
9 | } | 9 | } |
10 | 10 | ||
11 | void Rule::execute() | ||
12 | { | ||
13 | } | ||
14 | |||
@@ -17,6 +17,8 @@ public: | |||
17 | Rule(); | 17 | Rule(); |
18 | virtual ~Rule(); | 18 | virtual ~Rule(); |
19 | 19 | ||
20 | void execute(); | ||
21 | |||
20 | std::string getName() | 22 | std::string getName() |
21 | { | 23 | { |
22 | return sName; | 24 | return sName; |
diff --git a/src/stringprocbuild.cpp b/src/stringprocbuild.cpp index 56eae12..d0a5951 100644 --- a/src/stringprocbuild.cpp +++ b/src/stringprocbuild.cpp | |||
@@ -48,5 +48,7 @@ std::string StringProcBuild::replVars( const std::string &sSrc, const std::strin | |||
48 | sSrc.c_str() | 48 | sSrc.c_str() |
49 | ); | 49 | ); |
50 | } | 50 | } |
51 | |||
52 | return sDes; | ||
51 | } | 53 | } |
52 | 54 | ||
diff --git a/src/target.h b/src/target.h index 75fcb50..5325965 100644 --- a/src/target.h +++ b/src/target.h | |||
@@ -8,12 +8,17 @@ | |||
8 | 8 | ||
9 | typedef std::list<std::string> StringList; | 9 | typedef std::list<std::string> StringList; |
10 | 10 | ||
11 | class Build; | ||
12 | |||
11 | class Target | 13 | class Target |
12 | { | 14 | { |
13 | public: | 15 | public: |
14 | Target(); | 16 | Target(); |
15 | virtual ~Target(); | 17 | virtual ~Target(); |
16 | 18 | ||
19 | virtual void check( Build &bld ) = 0; | ||
20 | virtual void clean( Build &bld ) = 0; | ||
21 | |||
17 | void setName( const std::string &sName ) | 22 | void setName( const std::string &sName ) |
18 | { | 23 | { |
19 | this->sName = sName; | 24 | this->sName = sName; |
diff --git a/src/targetfile.cpp b/src/targetfile.cpp index fee41c9..8f6651e 100644 --- a/src/targetfile.cpp +++ b/src/targetfile.cpp | |||
@@ -1,5 +1,7 @@ | |||
1 | #include "targetfile.h" | 1 | #include "targetfile.h" |
2 | #include "plugger.h" | 2 | #include "plugger.h" |
3 | #include "rule.h" | ||
4 | #include "build.h" | ||
3 | 5 | ||
4 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); | 6 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); |
5 | 7 | ||
@@ -10,3 +12,17 @@ TargetFile::TargetFile() | |||
10 | TargetFile::~TargetFile() | 12 | TargetFile::~TargetFile() |
11 | { | 13 | { |
12 | } | 14 | } |
15 | |||
16 | void TargetFile::check( Build &bld ) | ||
17 | { | ||
18 | printf("Target file checking: %s\n", getName().c_str() ); | ||
19 | |||
20 | Rule *pRule = bld.getRule( getRule() ); | ||
21 | pRule->execute(); | ||
22 | } | ||
23 | |||
24 | void TargetFile::clean( Build &bld ) | ||
25 | { | ||
26 | printf("Target file cleaning: %s\n", getName().c_str() ); | ||
27 | } | ||
28 | |||
diff --git a/src/targetfile.h b/src/targetfile.h index 28fc2b1..37e6770 100644 --- a/src/targetfile.h +++ b/src/targetfile.h | |||
@@ -11,6 +11,9 @@ public: | |||
11 | TargetFile(); | 11 | TargetFile(); |
12 | virtual ~TargetFile(); | 12 | virtual ~TargetFile(); |
13 | 13 | ||
14 | virtual void check( Build &bld ); | ||
15 | virtual void clean( Build &bld ); | ||
16 | |||
14 | private: | 17 | private: |
15 | 18 | ||
16 | }; | 19 | }; |