diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-09-20 18:56:49 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-09-20 18:56:49 +0000 |
commit | 85539c8c262c0c9e227c87fd1de02c53c163b7d8 (patch) | |
tree | b6f96899ca745c157a6de93ad27013416976fc06 /src/build.cpp | |
parent | 5a32418a040e967887aa6e01e41abc22932471db (diff) | |
download | build-85539c8c262c0c9e227c87fd1de02c53c163b7d8.tar.gz build-85539c8c262c0c9e227c87fd1de02c53c163b7d8.tar.bz2 build-85539c8c262c0c9e227c87fd1de02c53c163b7d8.tar.xz build-85539c8c262c0c9e227c87fd1de02c53c163b7d8.zip |
Changed the api for variable replacement contexts. There can now be multiple
levels of contextual inheritance, so now sub-targets automatically get their
parent target's context variables, if they need them.
Diffstat (limited to '')
-rw-r--r-- | src/build.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/build.cpp b/src/build.cpp index 89366f9..b48e9f1 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -54,14 +54,14 @@ void Build::setStringProc( StringProc *pStrProc ) | |||
54 | this->pStrProc = pStrProc; | 54 | this->pStrProc = pStrProc; |
55 | } | 55 | } |
56 | 56 | ||
57 | std::string Build::replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra ) | 57 | std::string Build::replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra ) |
58 | { | 58 | { |
59 | if( pStrProc == NULL ) | 59 | if( pStrProc == NULL ) |
60 | throw BuildException( | 60 | throw BuildException( |
61 | "No valid string processor was registered with the Build object." | 61 | "No valid string processor was registered with the Build object." |
62 | ); | 62 | ); |
63 | 63 | ||
64 | return pStrProc->replVars( sSrc, sCont, mExtra ); | 64 | return pStrProc->replVars( sSrc, pCont, mExtra ); |
65 | } | 65 | } |
66 | 66 | ||
67 | void Build::execAction( const std::string &sWhat ) | 67 | void Build::execAction( const std::string &sWhat ) |
@@ -144,11 +144,13 @@ void Build::set( const std::string &cont, const std::string &var, const std::str | |||
144 | { | 144 | { |
145 | if( cont == "" ) | 145 | if( cont == "" ) |
146 | { | 146 | { |
147 | mVars[var] = replVars( val, cont, NULL ); | 147 | mVars[var] = replVars( val, NULL, NULL ); |
148 | } | 148 | } |
149 | else | 149 | else |
150 | { | 150 | { |
151 | mContVars[cont][var] = replVars( val, cont, NULL ); | 151 | StringList cl; |
152 | cl.push_front( cont ); | ||
153 | mContVars[cont][var] = replVars( val, &cl, NULL ); | ||
152 | } | 154 | } |
153 | } | 155 | } |
154 | 156 | ||
@@ -156,15 +158,17 @@ void Build::setAdd( const std::string &cont, const std::string &var, const std:: | |||
156 | { | 158 | { |
157 | if( cont == "" ) | 159 | if( cont == "" ) |
158 | { | 160 | { |
159 | mVars[var] = getVar( cont, var, NULL ) + " " + replVars( val, cont, NULL ); | 161 | mVars[var] = getVar( NULL, var, NULL ) + " " + replVars( val, NULL, NULL ); |
160 | } | 162 | } |
161 | else | 163 | else |
162 | { | 164 | { |
163 | mContVars[cont][var] = getVar( cont, var, NULL ) + " " + replVars( val, cont, NULL ); | 165 | StringList cl; |
166 | cl.push_front( cont ); | ||
167 | mContVars[cont][var] = getVar( &cl, var, NULL ) + " " + replVars( val, &cl, NULL ); | ||
164 | } | 168 | } |
165 | } | 169 | } |
166 | 170 | ||
167 | std::string Build::getVar( const std::string &cont, const std::string &var, VarMap *mExtra ) | 171 | std::string Build::getVar( const StringList *cont, const std::string &var, VarMap *mExtra ) |
168 | { | 172 | { |
169 | if( mExtra != NULL ) | 173 | if( mExtra != NULL ) |
170 | { | 174 | { |
@@ -175,7 +179,7 @@ std::string Build::getVar( const std::string &cont, const std::string &var, VarM | |||
175 | return (*mExtra)[var]; | 179 | return (*mExtra)[var]; |
176 | } | 180 | } |
177 | 181 | ||
178 | if( cont == "" ) | 182 | if( cont == NULL ) |
179 | { | 183 | { |
180 | if( mVars.find(var) == mVars.end() ) | 184 | if( mVars.find(var) == mVars.end() ) |
181 | { | 185 | { |
@@ -192,11 +196,18 @@ std::string Build::getVar( const std::string &cont, const std::string &var, VarM | |||
192 | } | 196 | } |
193 | else | 197 | else |
194 | { | 198 | { |
195 | if( mContVars[cont].find(var) == mContVars[cont].end() ) | 199 | if( cont->empty() ) |
200 | { | ||
201 | return getVar( NULL, var, NULL ); | ||
202 | } | ||
203 | std::string sTop = cont->front(); | ||
204 | if( mContVars[sTop].find(var) == mContVars[sTop].end() ) | ||
196 | { | 205 | { |
197 | mContVars[cont][var] = getVar( "", var, NULL ); | 206 | ((StringList *)cont)->pop_front(); |
207 | mContVars[sTop][var] = getVar( cont, var, NULL ); | ||
208 | ((StringList *)cont)->push_front( sTop ); | ||
198 | } | 209 | } |
199 | return mContVars[cont][var]; | 210 | return mContVars[sTop][var]; |
200 | } | 211 | } |
201 | } | 212 | } |
202 | 213 | ||