diff options
Diffstat (limited to 'src/targetfile.cpp')
| -rw-r--r-- | src/targetfile.cpp | 80 | 
1 files changed, 66 insertions, 14 deletions
diff --git a/src/targetfile.cpp b/src/targetfile.cpp index dc9e597..0299f9d 100644 --- a/src/targetfile.cpp +++ b/src/targetfile.cpp  | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | #include "plugger.h" | 2 | #include "plugger.h" | 
| 3 | #include "rule.h" | 3 | #include "rule.h" | 
| 4 | #include "build.h" | 4 | #include "build.h" | 
| 5 | #include "perform.h" | ||
| 6 | #include "function.h" | ||
| 7 | #include "viewer.h" | ||
| 5 | 8 | ||
| 6 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); | 9 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); | 
| 7 | 10 | ||
| @@ -15,26 +18,43 @@ TargetFile::~TargetFile() | |||
| 15 | 18 | ||
| 16 | void TargetFile::check( Build &bld ) | 19 | void TargetFile::check( Build &bld ) | 
| 17 | { | 20 | { | 
| 18 | printf("Target file checking: %s\n", getName().c_str() ); | ||
| 19 | |||
| 20 | Rule *pRule = bld.getRule( getRule() ); | 21 | Rule *pRule = bld.getRule( getRule() ); | 
| 21 | PerformList lPerf; | 22 | PerformList lPerf; | 
| 23 | pRule->setTarget( getName() ); | ||
| 22 | StringList lFinal = pRule->execute( bld, getInput(), lPerf ); | 24 | StringList lFinal = pRule->execute( bld, getInput(), lPerf ); | 
| 23 | 25 | ||
| 24 | printf("Input: "); | 26 | for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ ) | 
| 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 | { | 27 | { | 
| 34 | if( i != lFinal.begin() ) printf(", "); | 28 | time_t tTarget = getTime( bld, (*i)->getTarget() ); | 
| 35 | printf("%s", (*i).c_str() ); | 29 | StringList &reqs = bld.getRequires( (*i)->getTarget() ); | 
| 30 | FunctionList::iterator f = (*i)->getReqFuncs().begin(); | ||
| 31 | bool bBuilt = false; | ||
| 32 | aastrt: for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ ) | ||
| 33 | { | ||
| 34 | if( getTime( bld, *j ) > tTarget ) | ||
| 35 | { | ||
| 36 | bld.getView()->beginPerform( *i ); | ||
| 37 | (*i)->execute( bld ); | ||
| 38 | bld.getView()->endPerform(); | ||
| 39 | updateTime( (*i)->getTarget() ); | ||
| 40 | bBuilt = true; | ||
| 41 | break; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | if( bBuilt == true ) | ||
| 45 | continue; | ||
| 46 | |||
| 47 | if( f != (*i)->getReqFuncs().end() ) | ||
| 48 | { | ||
| 49 | StringList lTmpIn; | ||
| 50 | lTmpIn.push_back( (*i)->getTarget() ); | ||
| 51 | bld.getView()->beginRequiresCheck( false, (*i)->getTarget() ); | ||
| 52 | (*f)->execute( &bld, lTmpIn, reqs ); | ||
| 53 | bld.getView()->endRequiresCheck(); | ||
| 54 | f++; | ||
| 55 | goto aastrt; | ||
| 56 | } | ||
| 36 | } | 57 | } | 
| 37 | printf("\n"); | ||
| 38 | } | 58 | } | 
| 39 | 59 | ||
| 40 | void TargetFile::clean( Build &bld ) | 60 | void TargetFile::clean( Build &bld ) | 
| @@ -42,3 +62,35 @@ void TargetFile::clean( Build &bld ) | |||
| 42 | printf("Target file cleaning: %s\n", getName().c_str() ); | 62 | printf("Target file cleaning: %s\n", getName().c_str() ); | 
| 43 | } | 63 | } | 
| 44 | 64 | ||
| 65 | time_t TargetFile::getTime( Build &bld, std::string str ) | ||
| 66 | { | ||
| 67 | std::map<std::string, time_t>::iterator i = mTimes.find( str ); | ||
| 68 | if( i != mTimes.end() ) | ||
| 69 | { | ||
| 70 | //nCache++; | ||
| 71 | //bld.view().beginRequiresCheck( true, str.c_str() ); | ||
| 72 | //bld.view().endRequiresCheck(); | ||
| 73 | return (*i).second; | ||
| 74 | } | ||
| 75 | |||
| 76 | //bld.view().beginRequiresCheck( false, str.c_str() ); | ||
| 77 | struct stat st; | ||
| 78 | stat( str.c_str(), &st ); | ||
| 79 | |||
| 80 | mTimes[str] = st.st_mtime; | ||
| 81 | |||
| 82 | //nNew++; | ||
| 83 | |||
| 84 | //bld.view().endRequiresCheck(); | ||
| 85 | |||
| 86 | return st.st_mtime; | ||
| 87 | } | ||
| 88 | |||
| 89 | void TargetFile::updateTime( std::string str ) | ||
| 90 | { | ||
| 91 | struct stat st; | ||
| 92 | stat( str.c_str(), &st ); | ||
| 93 | |||
| 94 | mTimes[str] = st.st_mtime; | ||
| 95 | } | ||
| 96 | |||
