From 2c0c23b75f563d0a1e68f6079a8eea73c40a877a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 5 Aug 2006 06:52:01 +0000 Subject: Tweaked the cache format, it's no longer compatable with the old version, but it is less than one tenth the size, without using anything as slow as a compresion system, I just store each string only once (it's sort of compression). I also updated the plain viewer to not be so annoying if it doesn't have anything to do. --- src/cache.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/filetarget.cpp | 5 +++- src/viewerplain.cpp | 27 ++++++++++++++++++-- src/viewerplain.h | 4 +++ 4 files changed, 104 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cache.cpp b/src/cache.cpp index 43e69dc..10971b1 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -1,5 +1,6 @@ #include "cache.h" #include "serializer.h" +#include "staticstring.h" Cache::Cache() { @@ -18,6 +19,32 @@ void Cache::serialize( class Serializer &ar ) { if( ar.isLoading() ) { + int sCache, sData, sIndex; + + ar >> sIndex; + StaticString *Index = new StaticString[sIndex]; + for( int i = 0; i < sIndex; i++ ) + { + ar >> Index[i]; + } + + ar >> sCache; + int nTmp; + for( int i = 0; i < sCache; i++ ) + { + Entry *e = new Entry; + ar >> e->tCreated; + ar >> sData; + std::list &lData = e->lData; + for( int j = 0; j < sData; j++ ) + { + ar >> nTmp; + lData.push_back( Index[nTmp].getString() ); + } + ar >> nTmp; + mCache[Index[nTmp].getString()] = e; + } + /* int sCache, sData; ar >> sCache; std::string sTmp; @@ -36,9 +63,52 @@ void Cache::serialize( class Serializer &ar ) ar >> sTmp; mCache[sTmp] = e; } + */ } else { + std::map mIndex; + for( std::map::iterator i = mCache.begin(); + i != mCache.end(); i++ ) + { + mIndex[(*i).first] = 0; + std::list &lData = (*i).second->lData; + for( std::list::iterator j = lData.begin(); + j != lData.end(); j++ ) + { + mIndex[(*j)] = 0; + } + } + + ar << mIndex.size(); + int cnt = 0; + for( std::map::iterator i = mIndex.begin(); + i != mIndex.end(); i++ ) + { + (*i).second = cnt; + cnt++; + std::string s = ((*i).first); + ar << s; + } + + ar << mCache.size(); + for( std::map::iterator i = mCache.begin(); + i != mCache.end(); i++ ) + { + ar << (*i).second->tCreated; + std::list &lData = (*i).second->lData; + ar << lData.size(); + for( std::list::iterator j = lData.begin(); + j != lData.end(); j++ ) + { + ar << mIndex[(*j)]; + } + + ar << mIndex[(*i).first]; + } + + + /* ar << mCache.size(); for( std::map::iterator i = mCache.begin(); i != mCache.end(); i++ ) @@ -55,6 +125,7 @@ void Cache::serialize( class Serializer &ar ) std::string str = (*i).first; ar << str; } + */ } } diff --git a/src/filetarget.cpp b/src/filetarget.cpp index 7a714a5..0d47e6f 100644 --- a/src/filetarget.cpp +++ b/src/filetarget.cpp @@ -95,10 +95,13 @@ void FileTarget::check( Builder &bld ) printf("No dependancies: %s\n", (*i)->getTarget() ); continue; } + time_t rebuild = target; for( std::list::iterator j = lReqs->begin(); j != lReqs->end(); j++ ) { time_t srcfile = getTime( bld, *j ); + if( srcfile < rebuild ) + rebuild = srcfile; if( srcfile > target ) { bld.view().beginExecute(); @@ -114,7 +117,7 @@ void FileTarget::check( Builder &bld ) if( k == lReqs->end() ) { bExtraReqs = true; - bld.genRequiresFor( (*i)->getTarget(), srcfile ); + bld.genRequiresFor( (*i)->getTarget(), rebuild ); } } } diff --git a/src/viewerplain.cpp b/src/viewerplain.cpp index edc5ba8..5d95d19 100644 --- a/src/viewerplain.cpp +++ b/src/viewerplain.cpp @@ -12,22 +12,45 @@ ViewerPlain::~ViewerPlain() void ViewerPlain::beginTarget( const char *sName, const char *sType, const char *sOperation, int nPerforms ) { - printf("--- %s ---\n", sName ); + sAction = sName; + bPrinted = false; +} + +void ViewerPlain::printHead() +{ + if( bPrinted == false ) + { + printf("--- %s ---\n", sAction.getString() ); + bPrinted = true; + } } void ViewerPlain::endTarget() { - printf("\n"); + if( bPrinted == true ) + { + printf("\n"); + } + else + { + printf("Nothing to be done for %s.\n", sAction.getString() ); + } } void ViewerPlain::beginPerform( Perform *pPerf ) { sTarget = pPerf->getTarget(); +} + +void ViewerPlain::beginExtraRequiresCheck( const char *sCommand ) +{ + printHead(); printf(" check: %s\n", sTarget.getString() ); } void ViewerPlain::beginExecute() { + printHead(); printf(" build: %s\n", sTarget.getString() ); } diff --git a/src/viewerplain.h b/src/viewerplain.h index 7b4b189..1ec2b64 100644 --- a/src/viewerplain.h +++ b/src/viewerplain.h @@ -16,9 +16,13 @@ public: virtual void endTarget(); virtual void beginPerform( Perform *pPerf ); + virtual void beginExtraRequiresCheck( const char *sCommand ); + void printHead(); virtual void beginExecute(); private: + class StaticString sAction; + bool bPrinted; class StaticString sTarget; }; -- cgit v1.2.3