From d19ada0aa88aba1c7b439035c0028440ac860ec3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 12 Sep 2006 00:22:33 +0000 Subject: Build now builds, it has viewers, and dependancy checking, and everything works. Now we have to add cleaning, caching, and more viewer hooks / viewers. --- src/targetfile.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 14 deletions(-) (limited to 'src/targetfile.cpp') 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 @@ #include "plugger.h" #include "rule.h" #include "build.h" +#include "perform.h" +#include "function.h" +#include "viewer.h" PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); @@ -15,26 +18,43 @@ TargetFile::~TargetFile() void TargetFile::check( Build &bld ) { - printf("Target file checking: %s\n", getName().c_str() ); - Rule *pRule = bld.getRule( getRule() ); PerformList lPerf; + pRule->setTarget( getName() ); StringList lFinal = pRule->execute( bld, getInput(), lPerf ); - printf("Input: "); - for( StringList::iterator i = getInput().begin(); - i != getInput().end(); i++ ) - { - if( i != getInput().begin() ) printf(", "); - printf("%s", (*i).c_str() ); - } - printf("\nFinal: "); - for( StringList::iterator i = lFinal.begin(); i != lFinal.end(); i++ ) + for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ ) { - if( i != lFinal.begin() ) printf(", "); - printf("%s", (*i).c_str() ); + time_t tTarget = getTime( bld, (*i)->getTarget() ); + StringList &reqs = bld.getRequires( (*i)->getTarget() ); + FunctionList::iterator f = (*i)->getReqFuncs().begin(); + bool bBuilt = false; +aastrt: for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ ) + { + if( getTime( bld, *j ) > tTarget ) + { + bld.getView()->beginPerform( *i ); + (*i)->execute( bld ); + bld.getView()->endPerform(); + updateTime( (*i)->getTarget() ); + bBuilt = true; + break; + } + } + if( bBuilt == true ) + continue; + + if( f != (*i)->getReqFuncs().end() ) + { + StringList lTmpIn; + lTmpIn.push_back( (*i)->getTarget() ); + bld.getView()->beginRequiresCheck( false, (*i)->getTarget() ); + (*f)->execute( &bld, lTmpIn, reqs ); + bld.getView()->endRequiresCheck(); + f++; + goto aastrt; + } } - printf("\n"); } void TargetFile::clean( Build &bld ) @@ -42,3 +62,35 @@ void TargetFile::clean( Build &bld ) printf("Target file cleaning: %s\n", getName().c_str() ); } +time_t TargetFile::getTime( Build &bld, std::string str ) +{ + std::map::iterator i = mTimes.find( str ); + if( i != mTimes.end() ) + { + //nCache++; + //bld.view().beginRequiresCheck( true, str.c_str() ); + //bld.view().endRequiresCheck(); + return (*i).second; + } + + //bld.view().beginRequiresCheck( false, str.c_str() ); + struct stat st; + stat( str.c_str(), &st ); + + mTimes[str] = st.st_mtime; + + //nNew++; + + //bld.view().endRequiresCheck(); + + return st.st_mtime; +} + +void TargetFile::updateTime( std::string str ) +{ + struct stat st; + stat( str.c_str(), &st ); + + mTimes[str] = st.st_mtime; +} + -- cgit v1.2.3