From 062fcfb96c56ecfb69b8c3162ced65b63e863752 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 2 Aug 2006 06:54:48 +0000 Subject: Build will now only perform your extra code for using programs to generate more dependancies per target, and only if none of the other target's dependancies required a rebuild. --- src/builder.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/builder.h | 1 + src/filetarget.cpp | 12 +++++++++- 3 files changed, 78 insertions(+), 1 deletion(-) (limited to 'src') 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 ) void Builder::processRequires( std::list &lInput ) { + // These are cheap and handy to have all the time for( regreqlist::iterator i = lRequiresRegexp.begin(); i != lRequiresRegexp.end(); i++ ) { @@ -240,6 +241,8 @@ void Builder::processRequires( std::list &lInput ) } } + // These are only done on request now, they were too expensive + /* for( regreqlist::iterator i = lRequiresRegexpCommand.begin(); i != lRequiresRegexpCommand.end(); i++ ) { @@ -302,6 +305,69 @@ void Builder::processRequires( std::list &lInput ) } } } + */ +} + +void Builder::genRequiresFor( const char *sName ) +{ + for( regreqlist::iterator i = lRequiresRegexpCommand.begin(); + i != lRequiresRegexpCommand.end(); i++ ) + { + RegExp *re = (*i).first; + if( re->execute( sName ) ) + { + varmap *revars = regexVars( re ); + std::string s = varRepl( (*i).second.c_str(), "", revars ); + FILE *fcmd = popen( s.c_str(), "r" ); + std::string rhs; + bool bHeader = true; + for(;;) + { + if( feof( fcmd ) ) + break; + int cc = fgetc( fcmd ); + if( cc == EOF ) + break; + unsigned char c = cc; + if( bHeader ) + { + if( c == ':' ) + bHeader = false; + } + else + { + if( c == ' ' || c == '\t' ) + { + if( rhs != "" ) + { + requiresNormal( + sName, + rhs.c_str() + ); + rhs = ""; + } + } + else + { + if( c == '\\' ) + c = fgetc( fcmd ); + if( c != '\n' ) + rhs += c; + } + } + } + if( rhs != "" ) + { + requiresNormal( + sName, + rhs.c_str() + ); + rhs = ""; + } + pclose( fcmd ); + delete revars; + } + } } std::map *Builder::regexVars( RegExp *re ) diff --git a/src/builder.h b/src/builder.h index f27a042..296b9d7 100644 --- a/src/builder.h +++ b/src/builder.h @@ -54,6 +54,7 @@ public: void processRequires( std::list &lInput ); void requires( const char *sBase, const char *sReq ); void requiresFromCommand( const char *sBase, const char *sReq ); + void genRequiresFor( const char *sName ); void requiresRegexp( bool on ) { bReqRegexp = on; diff --git a/src/filetarget.cpp b/src/filetarget.cpp index cd95188..ca9a39f 100644 --- a/src/filetarget.cpp +++ b/src/filetarget.cpp @@ -81,10 +81,10 @@ void FileTarget::check( Builder &bld ) bld.processRequires( lOutput ); - for( std::list::iterator i = perf.begin(); i != perf.end(); i++ ) { + bool bExtraReqs = false; time_t target = getTime( std::string((*i)->getTarget()) ); std::list *lReqs = bld.getRequires( (*i)->getTarget() ); if( lReqs == NULL ) @@ -101,6 +101,16 @@ void FileTarget::check( Builder &bld ) updateTime( (*i)->getTarget() ); break; } + if( bExtraReqs == false ) + { + std::list::iterator k = j; + k++; + if( k == lReqs->end() ) + { + bExtraReqs = true; + bld.genRequiresFor( (*i)->getTarget() ); + } + } } } -- cgit v1.2.3