From 863a1f4ce1d7b70f9a73edb16b0de1c753087152 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 3 Nov 2006 21:12:51 +0000 Subject: david - percent viewer. --- src/main.cpp | 9 ++++- src/viewerfactory.cpp | 2 + src/viewerplainpct.cpp | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ src/viewerplainpct.h | 45 +++++++++++++++++++++ 4 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/viewerplainpct.cpp create mode 100644 src/viewerplainpct.h (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 06a1ff6..b7cf6e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,7 @@ public: sCache(".build.cache"), bDebug( false ), bPostDebug( false ), - sView("plain"), + sView("plainpct"), bInfo( false ), bCleanMode( false ), sDir("") @@ -31,6 +31,8 @@ public: "Clean instead of checking the given action.", NULL, "true" ); addParam('p', mkproc(Param::procViewPercent), "Switch to percent view."); + addParam('P', mkproc(Param::procViewPlain), + "Switch to plain view."); addParam('m', mkproc(Param::procViewMake), "Switch to 'make' style view."); addParam("cache", &sCache, @@ -64,6 +66,11 @@ public: { sView = "percent"; } + + int procViewPlain( int argc, char *argv[] ) + { + sView = "plain"; + } int procViewMake( int argc, char *argv[] ) { diff --git a/src/viewerfactory.cpp b/src/viewerfactory.cpp index 8024a7e..52ec5d4 100644 --- a/src/viewerfactory.cpp +++ b/src/viewerfactory.cpp @@ -3,12 +3,14 @@ extern struct PluginInfo plain; extern struct PluginInfo percent; extern struct PluginInfo make; +extern struct PluginInfo plainpct; ViewerFactory::ViewerFactory() { registerBuiltinPlugin( &plain ); registerBuiltinPlugin( &percent ); registerBuiltinPlugin( &make ); + registerBuiltinPlugin( &plainpct ); } ViewerFactory::~ViewerFactory() diff --git a/src/viewerplainpct.cpp b/src/viewerplainpct.cpp new file mode 100644 index 0000000..a7baff1 --- /dev/null +++ b/src/viewerplainpct.cpp @@ -0,0 +1,107 @@ +#include "viewerplainpct.h" +#include "perform.h" +#include "plugger.h" +#include "math.h" + +PluginInterface2( plainpct, ViewerPlainPct, Viewer, "Mike Buland", 0, 1 ); + +ViewerPlainPct::ViewerPlainPct() : + bRunClean( true ) +{ +} + +ViewerPlainPct::~ViewerPlainPct() +{ +} + +void ViewerPlainPct::beginCommand( Action::eAction nAct, const std::string &sTarget ) +{ + Cmd cmd; + if( sCmd.empty() ) + cmd.nLevel = 0; + else + cmd.nLevel = sCmd.front().nLevel+1; + + cmd.bCmdClean = true; + cmd.sTarget = sTarget; + + sCmd.push_front( cmd ); +} + +void ViewerPlainPct::endCommand() +{ + if( sCmd.front().bCmdClean == false ) + printf("\n"); + sCmd.pop_front(); + iCC++; +} + +void ViewerPlainPct::indent() +{ + if( sCmd.empty() ) return; + int jmax = sCmd.front().nLevel; + for( int j = 0; j < jmax; j++ ) + { + printf(" "); + } +} + +void ViewerPlainPct::printHead() +{ + if( sCmd.front().bCmdClean == true ) + { + bRunClean = false; + sCmd.front().bCmdClean = false; + indent(); + printf("--- [%d/%d] %s ---\n", iCC, iTC, sCmd.front().sTarget.c_str() ); + } +} + +void ViewerPlainPct::beginRequiresCheck( bool bCached, const std::string &sName ) +{ + printHead(); + indent(); + printf("[%3d%%] deps: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), sName.c_str() ); +} + +void ViewerPlainPct::endRequiresCheck() +{ + iCP++; + bDidReq = true; +} + +void ViewerPlainPct::beginPerform( Perform *pPerform ) +{ + printHead(); + indent(); + printf("[%3d%%] %8s: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), pPerform->getRule().c_str(), pPerform->getTarget().c_str() ); +} + +void ViewerPlainPct::endPerform() +{ + if(!bDidReq) + iCP++; + bDidReq = false; +} + +void ViewerPlainPct::beginPerforms( int nCount ) +{ + iTP = nCount; + iCP = 1; + bDidReq = false; +} + +void ViewerPlainPct::beginAction( const std::string &sName, int nCommands ) +{ + iTC = nCommands; + iCC = 1; +} + +void ViewerPlainPct::endAction() +{ + if( bRunClean == true ) + { + printf("Nothing to be done.\n\n"); + } +} + diff --git a/src/viewerplainpct.h b/src/viewerplainpct.h new file mode 100644 index 0000000..5a57ef0 --- /dev/null +++ b/src/viewerplainpct.h @@ -0,0 +1,45 @@ +#ifndef VIEWER_PLAIN_H +#define VIEWER_PLAIN_H + +#include +#include +#include "viewer.h" + +class ViewerPlainPct : public Viewer +{ +public: + ViewerPlainPct(); + virtual ~ViewerPlainPct(); + + virtual void beginCommand( Action::eAction nAct, const std::string &sTarget ); + virtual void endCommand(); + + virtual void beginRequiresCheck( bool bCached, const std::string &sName ); + virtual void endRequiresCheck(); + virtual void beginPerform( Perform *pPerform ); + virtual void endPerform(); + virtual void beginPerforms( int nCount ); + + virtual void beginAction( const std::string &sName, int nCommands ); + + virtual void endAction(); + + void printHead(); + void indent(); + +private: + bool bDidReq; + int iTP, iCP, iTC, iCC; + + bool bRunClean; + typedef struct + { + int nLevel; + bool bCmdClean; + std::string sTarget; + } Cmd; + typedef std::list CmdStack; + CmdStack sCmd; +}; + +#endif -- cgit v1.2.3