diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cpp | 21 | ||||
-rw-r--r-- | src/build.h | 6 | ||||
-rw-r--r-- | src/perform.cpp | 4 | ||||
-rw-r--r-- | src/perform.h | 5 | ||||
-rw-r--r-- | src/performcommand.cpp | 2 | ||||
-rw-r--r-- | src/rule.cpp | 5 | ||||
-rw-r--r-- | src/rule.h | 4 | ||||
-rw-r--r-- | src/stringproc.h | 5 | ||||
-rw-r--r-- | src/stringprocbuild.cpp | 4 | ||||
-rw-r--r-- | src/stringprocbuild.h | 2 | ||||
-rw-r--r-- | src/targetfile.cpp | 18 |
11 files changed, 56 insertions, 20 deletions
diff --git a/src/build.cpp b/src/build.cpp index 372e607..255cbd3 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -17,14 +17,14 @@ void Build::setStringProc( StringProc *pStrProc ) | |||
17 | this->pStrProc = pStrProc; | 17 | this->pStrProc = pStrProc; |
18 | } | 18 | } |
19 | 19 | ||
20 | std::string Build::replVars( const std::string &sSrc, const std::string &sCont ) | 20 | std::string Build::replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra ) |
21 | { | 21 | { |
22 | if( pStrProc == NULL ) | 22 | if( pStrProc == NULL ) |
23 | throw BuildException( | 23 | throw BuildException( |
24 | "No valid string processor was registered with the Build object." | 24 | "No valid string processor was registered with the Build object." |
25 | ); | 25 | ); |
26 | 26 | ||
27 | return pStrProc->replVars( sSrc, sCont ); | 27 | return pStrProc->replVars( sSrc, sCont, mExtra ); |
28 | } | 28 | } |
29 | 29 | ||
30 | void Build::execAction( const std::string &sWhat ) | 30 | void Build::execAction( const std::string &sWhat ) |
@@ -113,16 +113,25 @@ void Build::setAdd( const std::string &cont, const std::string &var, const std:: | |||
113 | { | 113 | { |
114 | if( cont == "" ) | 114 | if( cont == "" ) |
115 | { | 115 | { |
116 | mVars[var] = getVar( cont, var ) + " " + val; | 116 | mVars[var] = getVar( cont, var, NULL ) + " " + val; |
117 | } | 117 | } |
118 | else | 118 | else |
119 | { | 119 | { |
120 | mContVars[cont][var] = getVar( cont, var ) + " " + val; | 120 | mContVars[cont][var] = getVar( cont, var, NULL ) + " " + val; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | std::string Build::getVar( const std::string &cont, const std::string &var ) | 124 | std::string Build::getVar( const std::string &cont, const std::string &var, VarMap *mExtra ) |
125 | { | 125 | { |
126 | if( mExtra != NULL ) | ||
127 | { | ||
128 | if( mExtra->find(var) == mExtra->end() ) | ||
129 | { | ||
130 | return getVar( cont, var, NULL ); | ||
131 | } | ||
132 | return (*mExtra)[var]; | ||
133 | } | ||
134 | |||
126 | if( cont == "" ) | 135 | if( cont == "" ) |
127 | { | 136 | { |
128 | if( mVars.find(var) == mVars.end() ) | 137 | if( mVars.find(var) == mVars.end() ) |
@@ -142,7 +151,7 @@ std::string Build::getVar( const std::string &cont, const std::string &var ) | |||
142 | { | 151 | { |
143 | if( mContVars[cont].find(var) == mContVars[cont].end() ) | 152 | if( mContVars[cont].find(var) == mContVars[cont].end() ) |
144 | { | 153 | { |
145 | mContVars[cont][var] = getVar( "", var ); | 154 | mContVars[cont][var] = getVar( "", var, NULL ); |
146 | } | 155 | } |
147 | return mContVars[cont][var]; | 156 | return mContVars[cont][var]; |
148 | } | 157 | } |
diff --git a/src/build.h b/src/build.h index d5e6604..080304b 100644 --- a/src/build.h +++ b/src/build.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "stringproc.h" | 13 | #include "stringproc.h" |
14 | 14 | ||
15 | subExceptionDecl( BuildException ); | 15 | subExceptionDecl( BuildException ); |
16 | typedef std::map<std::string, std::string> VarMap; | ||
16 | 17 | ||
17 | class Build | 18 | class Build |
18 | { | 19 | { |
@@ -35,20 +36,19 @@ public: | |||
35 | 36 | ||
36 | void set( const std::string &cont, const std::string &var, const std::string &val ); | 37 | void set( 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 ); | 38 | void setAdd( const std::string &cont, const std::string &var, const std::string &val ); |
38 | std::string getVar( const std::string &cont, const std::string &var ); | 39 | std::string getVar( const std::string &cont, const std::string &var, VarMap *mExtra ); |
39 | 40 | ||
40 | Rule *getRule( const std::string &name ); | 41 | Rule *getRule( const std::string &name ); |
41 | 42 | ||
42 | void debugDump(); | 43 | void debugDump(); |
43 | 44 | ||
44 | void setStringProc( StringProc *pStrProc ); | 45 | void setStringProc( StringProc *pStrProc ); |
45 | std::string replVars( const std::string &sSrc, const std::string &sCont ); | 46 | std::string replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra ); |
46 | 47 | ||
47 | private: | 48 | private: |
48 | typedef std::map<std::string, Target *> TargetMap; | 49 | typedef std::map<std::string, Target *> TargetMap; |
49 | typedef std::list<std::string> StringList; | 50 | typedef std::list<std::string> StringList; |
50 | typedef std::map<std::string, StringList> ReqMap; | 51 | typedef std::map<std::string, StringList> ReqMap; |
51 | typedef std::map<std::string, std::string> VarMap; | ||
52 | typedef std::map<std::string, VarMap> ContextMap; | 52 | typedef std::map<std::string, VarMap> ContextMap; |
53 | typedef std::map<std::string, Rule *> RuleMap; | 53 | typedef std::map<std::string, Rule *> RuleMap; |
54 | typedef std::map<std::string, Action *> ActionMap; | 54 | typedef std::map<std::string, Action *> ActionMap; |
diff --git a/src/perform.cpp b/src/perform.cpp index 20ad51a..64e6bab 100644 --- a/src/perform.cpp +++ b/src/perform.cpp | |||
@@ -14,13 +14,13 @@ void Perform::addParam( const char *sParam ) | |||
14 | lParam.push_back( sParam ); | 14 | lParam.push_back( sParam ); |
15 | } | 15 | } |
16 | 16 | ||
17 | void Perform::copyData( Perform *pSrc, Build &bld, const std::string &cont ) | 17 | void Perform::copyData( Perform *pSrc, Build &bld, const std::string &cont, VarMap *mExtra ) |
18 | { | 18 | { |
19 | lParam.clear(); | 19 | lParam.clear(); |
20 | for( std::list<std::string>::iterator i = pSrc->lParam.begin(); | 20 | for( std::list<std::string>::iterator i = pSrc->lParam.begin(); |
21 | i != pSrc->lParam.end(); i++ ) | 21 | i != pSrc->lParam.end(); i++ ) |
22 | { | 22 | { |
23 | lParam.push_back( bld.replVars( *i, cont ) ); | 23 | lParam.push_back( bld.replVars( *i, cont, mExtra ) ); |
24 | } | 24 | } |
25 | } | 25 | } |
26 | 26 | ||
diff --git a/src/perform.h b/src/perform.h index add5a09..93c8b9a 100644 --- a/src/perform.h +++ b/src/perform.h | |||
@@ -4,6 +4,9 @@ | |||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <list> | 5 | #include <list> |
6 | #include <string> | 6 | #include <string> |
7 | #include <map> | ||
8 | |||
9 | typedef std::map<std::string,std::string> VarMap; | ||
7 | 10 | ||
8 | class Build; | 11 | class Build; |
9 | 12 | ||
@@ -15,7 +18,7 @@ public: | |||
15 | 18 | ||
16 | void addParam( const char *sParam ); | 19 | void addParam( const char *sParam ); |
17 | virtual Perform *duplicate( Build &bld, const std::string &cont ) = 0; | 20 | virtual Perform *duplicate( Build &bld, const std::string &cont ) = 0; |
18 | void copyData( Perform *pSrc, Build &bld, const std::string &cont ); | 21 | void copyData( Perform *pSrc, Build &bld, const std::string &cont, VarMap *mExtra ); |
19 | std::string getTarget() | 22 | std::string getTarget() |
20 | { | 23 | { |
21 | return sTarget; | 24 | return sTarget; |
diff --git a/src/performcommand.cpp b/src/performcommand.cpp index 7505061..6963022 100644 --- a/src/performcommand.cpp +++ b/src/performcommand.cpp | |||
@@ -14,7 +14,7 @@ PerformCommand::~PerformCommand() | |||
14 | Perform *PerformCommand::duplicate( Build &bld, const std::string &cont ) | 14 | Perform *PerformCommand::duplicate( Build &bld, const std::string &cont ) |
15 | { | 15 | { |
16 | Perform *pRet = new PerformCommand(); | 16 | Perform *pRet = new PerformCommand(); |
17 | pRet->copyData( this, bld, cont ); | 17 | pRet->copyData( this, bld, cont, NULL ); |
18 | return pRet; | 18 | return pRet; |
19 | } | 19 | } |
20 | 20 | ||
diff --git a/src/rule.cpp b/src/rule.cpp index 4426575..4919eef 100644 --- a/src/rule.cpp +++ b/src/rule.cpp | |||
@@ -8,7 +8,10 @@ Rule::~Rule() | |||
8 | { | 8 | { |
9 | } | 9 | } |
10 | 10 | ||
11 | void Rule::execute() | 11 | StringList Rule::execute( Build &bld, StringList &lInput, PerformList &lPerf ) |
12 | { | 12 | { |
13 | StringList lOutput; | ||
14 | |||
15 | return lOutput; | ||
13 | } | 16 | } |
14 | 17 | ||
@@ -7,9 +7,11 @@ | |||
7 | 7 | ||
8 | class Function; | 8 | class Function; |
9 | class Perform; | 9 | class Perform; |
10 | class Build; | ||
10 | 11 | ||
11 | typedef std::list<Function *> FunctionList; | 12 | typedef std::list<Function *> FunctionList; |
12 | typedef std::list<Perform *> PerformList; | 13 | typedef std::list<Perform *> PerformList; |
14 | typedef std::list<std::string> StringList; | ||
13 | 15 | ||
14 | class Rule | 16 | class Rule |
15 | { | 17 | { |
@@ -17,7 +19,7 @@ public: | |||
17 | Rule(); | 19 | Rule(); |
18 | virtual ~Rule(); | 20 | virtual ~Rule(); |
19 | 21 | ||
20 | void execute(); | 22 | StringList execute( Build &bld, StringList &lInput, PerformList &lPerf ); |
21 | 23 | ||
22 | std::string getName() | 24 | std::string getName() |
23 | { | 25 | { |
diff --git a/src/stringproc.h b/src/stringproc.h index 237ad6f..860579f 100644 --- a/src/stringproc.h +++ b/src/stringproc.h | |||
@@ -3,16 +3,19 @@ | |||
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <string> | 5 | #include <string> |
6 | #include <map> | ||
6 | 7 | ||
7 | class Build; | 8 | class Build; |
8 | 9 | ||
10 | typedef std::map<std::string,std::string> VarMap; | ||
11 | |||
9 | class StringProc | 12 | class StringProc |
10 | { | 13 | { |
11 | public: | 14 | public: |
12 | StringProc( Build *pBld ); | 15 | StringProc( Build *pBld ); |
13 | virtual ~StringProc(); | 16 | virtual ~StringProc(); |
14 | 17 | ||
15 | virtual std::string replVars( const std::string &sSrc, const std::string &sCont )=0; | 18 | virtual std::string replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra )=0; |
16 | 19 | ||
17 | protected: | 20 | protected: |
18 | Build *getBuild() | 21 | Build *getBuild() |
diff --git a/src/stringprocbuild.cpp b/src/stringprocbuild.cpp index d0a5951..071e941 100644 --- a/src/stringprocbuild.cpp +++ b/src/stringprocbuild.cpp | |||
@@ -10,7 +10,7 @@ StringProcBuild::~StringProcBuild() | |||
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
13 | std::string StringProcBuild::replVars( const std::string &sSrc, const std::string &sCont ) | 13 | std::string StringProcBuild::replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra ) |
14 | { | 14 | { |
15 | std::string sDes, sBuf; | 15 | std::string sDes, sBuf; |
16 | int nMode = 0; | 16 | int nMode = 0; |
@@ -31,7 +31,7 @@ std::string StringProcBuild::replVars( const std::string &sSrc, const std::strin | |||
31 | { | 31 | { |
32 | if( sSrc[j] == '}' ) | 32 | if( sSrc[j] == '}' ) |
33 | { | 33 | { |
34 | sDes += getBuild()->getVar( sCont, sBuf ); | 34 | sDes += getBuild()->getVar( sCont, sBuf, mExtra ); |
35 | nMode = 0; | 35 | nMode = 0; |
36 | } | 36 | } |
37 | else | 37 | else |
diff --git a/src/stringprocbuild.h b/src/stringprocbuild.h index 13dd4f6..d940507 100644 --- a/src/stringprocbuild.h +++ b/src/stringprocbuild.h | |||
@@ -11,7 +11,7 @@ public: | |||
11 | StringProcBuild( Build *pBld ); | 11 | StringProcBuild( Build *pBld ); |
12 | virtual ~StringProcBuild(); | 12 | virtual ~StringProcBuild(); |
13 | 13 | ||
14 | virtual std::string replVars( const std::string &sSrc, const std::string &sCont ); | 14 | virtual std::string replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra ); |
15 | 15 | ||
16 | private: | 16 | private: |
17 | 17 | ||
diff --git a/src/targetfile.cpp b/src/targetfile.cpp index 8f6651e..dc9e597 100644 --- a/src/targetfile.cpp +++ b/src/targetfile.cpp | |||
@@ -18,7 +18,23 @@ void TargetFile::check( Build &bld ) | |||
18 | printf("Target file checking: %s\n", getName().c_str() ); | 18 | printf("Target file checking: %s\n", getName().c_str() ); |
19 | 19 | ||
20 | Rule *pRule = bld.getRule( getRule() ); | 20 | Rule *pRule = bld.getRule( getRule() ); |
21 | pRule->execute(); | 21 | PerformList lPerf; |
22 | StringList lFinal = pRule->execute( bld, getInput(), lPerf ); | ||
23 | |||
24 | printf("Input: "); | ||
25 | for( StringList::iterator i = getInput().begin(); | ||
26 | i != getInput().end(); i++ ) | ||
27 | { | ||
28 | if( i != getInput().begin() ) printf(", "); | ||
29 | printf("%s", (*i).c_str() ); | ||
30 | } | ||
31 | printf("\nFinal: "); | ||
32 | for( StringList::iterator i = lFinal.begin(); i != lFinal.end(); i++ ) | ||
33 | { | ||
34 | if( i != lFinal.begin() ) printf(", "); | ||
35 | printf("%s", (*i).c_str() ); | ||
36 | } | ||
37 | printf("\n"); | ||
22 | } | 38 | } |
23 | 39 | ||
24 | void TargetFile::clean( Build &bld ) | 40 | void TargetFile::clean( Build &bld ) |