diff options
Diffstat (limited to '')
| -rw-r--r-- | src/builder.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/builder.cpp b/src/builder.cpp index d448243..c4f2d12 100644 --- a/src/builder.cpp +++ b/src/builder.cpp | |||
| @@ -217,6 +217,7 @@ void Builder::varAddSet( const char *sName, const char *sValue ) | |||
| 217 | 217 | ||
| 218 | void Builder::processRequires( std::list<std::string> &lInput ) | 218 | void Builder::processRequires( std::list<std::string> &lInput ) |
| 219 | { | 219 | { |
| 220 | // These are cheap and handy to have all the time | ||
| 220 | for( regreqlist::iterator i = lRequiresRegexp.begin(); | 221 | for( regreqlist::iterator i = lRequiresRegexp.begin(); |
| 221 | i != lRequiresRegexp.end(); i++ ) | 222 | i != lRequiresRegexp.end(); i++ ) |
| 222 | { | 223 | { |
| @@ -240,6 +241,8 @@ void Builder::processRequires( std::list<std::string> &lInput ) | |||
| 240 | } | 241 | } |
| 241 | } | 242 | } |
| 242 | 243 | ||
| 244 | // These are only done on request now, they were too expensive | ||
| 245 | /* | ||
| 243 | for( regreqlist::iterator i = lRequiresRegexpCommand.begin(); | 246 | for( regreqlist::iterator i = lRequiresRegexpCommand.begin(); |
| 244 | i != lRequiresRegexpCommand.end(); i++ ) | 247 | i != lRequiresRegexpCommand.end(); i++ ) |
| 245 | { | 248 | { |
| @@ -302,6 +305,69 @@ void Builder::processRequires( std::list<std::string> &lInput ) | |||
| 302 | } | 305 | } |
| 303 | } | 306 | } |
| 304 | } | 307 | } |
| 308 | */ | ||
| 309 | } | ||
| 310 | |||
| 311 | void Builder::genRequiresFor( const char *sName ) | ||
| 312 | { | ||
| 313 | for( regreqlist::iterator i = lRequiresRegexpCommand.begin(); | ||
| 314 | i != lRequiresRegexpCommand.end(); i++ ) | ||
| 315 | { | ||
| 316 | RegExp *re = (*i).first; | ||
| 317 | if( re->execute( sName ) ) | ||
| 318 | { | ||
| 319 | varmap *revars = regexVars( re ); | ||
| 320 | std::string s = varRepl( (*i).second.c_str(), "", revars ); | ||
| 321 | FILE *fcmd = popen( s.c_str(), "r" ); | ||
| 322 | std::string rhs; | ||
| 323 | bool bHeader = true; | ||
| 324 | for(;;) | ||
| 325 | { | ||
| 326 | if( feof( fcmd ) ) | ||
| 327 | break; | ||
| 328 | int cc = fgetc( fcmd ); | ||
| 329 | if( cc == EOF ) | ||
| 330 | break; | ||
| 331 | unsigned char c = cc; | ||
| 332 | if( bHeader ) | ||
| 333 | { | ||
| 334 | if( c == ':' ) | ||
| 335 | bHeader = false; | ||
| 336 | } | ||
| 337 | else | ||
| 338 | { | ||
| 339 | if( c == ' ' || c == '\t' ) | ||
| 340 | { | ||
| 341 | if( rhs != "" ) | ||
| 342 | { | ||
| 343 | requiresNormal( | ||
| 344 | sName, | ||
| 345 | rhs.c_str() | ||
| 346 | ); | ||
| 347 | rhs = ""; | ||
| 348 | } | ||
| 349 | } | ||
| 350 | else | ||
| 351 | { | ||
| 352 | if( c == '\\' ) | ||
| 353 | c = fgetc( fcmd ); | ||
| 354 | if( c != '\n' ) | ||
| 355 | rhs += c; | ||
| 356 | } | ||
| 357 | } | ||
| 358 | } | ||
| 359 | if( rhs != "" ) | ||
| 360 | { | ||
| 361 | requiresNormal( | ||
| 362 | sName, | ||
| 363 | rhs.c_str() | ||
| 364 | ); | ||
| 365 | rhs = ""; | ||
| 366 | } | ||
| 367 | pclose( fcmd ); | ||
| 368 | delete revars; | ||
| 369 | } | ||
| 370 | } | ||
| 305 | } | 371 | } |
| 306 | 372 | ||
| 307 | std::map<std::string, std::string> *Builder::regexVars( RegExp *re ) | 373 | std::map<std::string, std::string> *Builder::regexVars( RegExp *re ) |
