diff options
| author | David <david@xagasoft.com> | 2006-11-03 21:12:51 +0000 |
|---|---|---|
| committer | David <david@xagasoft.com> | 2006-11-03 21:12:51 +0000 |
| commit | 863a1f4ce1d7b70f9a73edb16b0de1c753087152 (patch) | |
| tree | 7b344101a1d8bb5d49ffd2a16b2782612a9b9471 /src | |
| parent | e270362ceacad49a72cf46394fcb5f010acc41f9 (diff) | |
| download | build-863a1f4ce1d7b70f9a73edb16b0de1c753087152.tar.gz build-863a1f4ce1d7b70f9a73edb16b0de1c753087152.tar.bz2 build-863a1f4ce1d7b70f9a73edb16b0de1c753087152.tar.xz build-863a1f4ce1d7b70f9a73edb16b0de1c753087152.zip | |
david - percent viewer.
Diffstat (limited to '')
| -rw-r--r-- | src/main.cpp | 9 | ||||
| -rw-r--r-- | src/viewerfactory.cpp | 2 | ||||
| -rw-r--r-- | src/viewerplainpct.cpp | 107 | ||||
| -rw-r--r-- | src/viewerplainpct.h | 45 |
4 files changed, 162 insertions, 1 deletions
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: | |||
| 15 | sCache(".build.cache"), | 15 | sCache(".build.cache"), |
| 16 | bDebug( false ), | 16 | bDebug( false ), |
| 17 | bPostDebug( false ), | 17 | bPostDebug( false ), |
| 18 | sView("plain"), | 18 | sView("plainpct"), |
| 19 | bInfo( false ), | 19 | bInfo( false ), |
| 20 | bCleanMode( false ), | 20 | bCleanMode( false ), |
| 21 | sDir("") | 21 | sDir("") |
| @@ -31,6 +31,8 @@ public: | |||
| 31 | "Clean instead of checking the given action.", NULL, "true" ); | 31 | "Clean instead of checking the given action.", NULL, "true" ); |
| 32 | addParam('p', mkproc(Param::procViewPercent), | 32 | addParam('p', mkproc(Param::procViewPercent), |
| 33 | "Switch to percent view."); | 33 | "Switch to percent view."); |
| 34 | addParam('P', mkproc(Param::procViewPlain), | ||
| 35 | "Switch to plain view."); | ||
| 34 | addParam('m', mkproc(Param::procViewMake), | 36 | addParam('m', mkproc(Param::procViewMake), |
| 35 | "Switch to 'make' style view."); | 37 | "Switch to 'make' style view."); |
| 36 | addParam("cache", &sCache, | 38 | addParam("cache", &sCache, |
| @@ -64,6 +66,11 @@ public: | |||
| 64 | { | 66 | { |
| 65 | sView = "percent"; | 67 | sView = "percent"; |
| 66 | } | 68 | } |
| 69 | |||
| 70 | int procViewPlain( int argc, char *argv[] ) | ||
| 71 | { | ||
| 72 | sView = "plain"; | ||
| 73 | } | ||
| 67 | 74 | ||
| 68 | int procViewMake( int argc, char *argv[] ) | 75 | int procViewMake( int argc, char *argv[] ) |
| 69 | { | 76 | { |
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 @@ | |||
| 3 | extern struct PluginInfo plain; | 3 | extern struct PluginInfo plain; |
| 4 | extern struct PluginInfo percent; | 4 | extern struct PluginInfo percent; |
| 5 | extern struct PluginInfo make; | 5 | extern struct PluginInfo make; |
| 6 | extern struct PluginInfo plainpct; | ||
| 6 | 7 | ||
| 7 | ViewerFactory::ViewerFactory() | 8 | ViewerFactory::ViewerFactory() |
| 8 | { | 9 | { |
| 9 | registerBuiltinPlugin( &plain ); | 10 | registerBuiltinPlugin( &plain ); |
| 10 | registerBuiltinPlugin( &percent ); | 11 | registerBuiltinPlugin( &percent ); |
| 11 | registerBuiltinPlugin( &make ); | 12 | registerBuiltinPlugin( &make ); |
| 13 | registerBuiltinPlugin( &plainpct ); | ||
| 12 | } | 14 | } |
| 13 | 15 | ||
| 14 | ViewerFactory::~ViewerFactory() | 16 | 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 @@ | |||
| 1 | #include "viewerplainpct.h" | ||
| 2 | #include "perform.h" | ||
| 3 | #include "plugger.h" | ||
| 4 | #include "math.h" | ||
| 5 | |||
| 6 | PluginInterface2( plainpct, ViewerPlainPct, Viewer, "Mike Buland", 0, 1 ); | ||
| 7 | |||
| 8 | ViewerPlainPct::ViewerPlainPct() : | ||
| 9 | bRunClean( true ) | ||
| 10 | { | ||
| 11 | } | ||
| 12 | |||
| 13 | ViewerPlainPct::~ViewerPlainPct() | ||
| 14 | { | ||
| 15 | } | ||
| 16 | |||
| 17 | void ViewerPlainPct::beginCommand( Action::eAction nAct, const std::string &sTarget ) | ||
| 18 | { | ||
| 19 | Cmd cmd; | ||
| 20 | if( sCmd.empty() ) | ||
| 21 | cmd.nLevel = 0; | ||
| 22 | else | ||
| 23 | cmd.nLevel = sCmd.front().nLevel+1; | ||
| 24 | |||
| 25 | cmd.bCmdClean = true; | ||
| 26 | cmd.sTarget = sTarget; | ||
| 27 | |||
| 28 | sCmd.push_front( cmd ); | ||
| 29 | } | ||
| 30 | |||
| 31 | void ViewerPlainPct::endCommand() | ||
| 32 | { | ||
| 33 | if( sCmd.front().bCmdClean == false ) | ||
| 34 | printf("\n"); | ||
| 35 | sCmd.pop_front(); | ||
| 36 | iCC++; | ||
| 37 | } | ||
| 38 | |||
| 39 | void ViewerPlainPct::indent() | ||
| 40 | { | ||
| 41 | if( sCmd.empty() ) return; | ||
| 42 | int jmax = sCmd.front().nLevel; | ||
| 43 | for( int j = 0; j < jmax; j++ ) | ||
| 44 | { | ||
| 45 | printf(" "); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | void ViewerPlainPct::printHead() | ||
| 50 | { | ||
| 51 | if( sCmd.front().bCmdClean == true ) | ||
| 52 | { | ||
| 53 | bRunClean = false; | ||
| 54 | sCmd.front().bCmdClean = false; | ||
| 55 | indent(); | ||
| 56 | printf("--- [%d/%d] %s ---\n", iCC, iTC, sCmd.front().sTarget.c_str() ); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | void ViewerPlainPct::beginRequiresCheck( bool bCached, const std::string &sName ) | ||
| 61 | { | ||
| 62 | printHead(); | ||
| 63 | indent(); | ||
| 64 | printf("[%3d%%] deps: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), sName.c_str() ); | ||
| 65 | } | ||
| 66 | |||
| 67 | void ViewerPlainPct::endRequiresCheck() | ||
| 68 | { | ||
| 69 | iCP++; | ||
| 70 | bDidReq = true; | ||
| 71 | } | ||
| 72 | |||
| 73 | void ViewerPlainPct::beginPerform( Perform *pPerform ) | ||
| 74 | { | ||
| 75 | printHead(); | ||
| 76 | indent(); | ||
| 77 | printf("[%3d%%] %8s: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), pPerform->getRule().c_str(), pPerform->getTarget().c_str() ); | ||
| 78 | } | ||
| 79 | |||
| 80 | void ViewerPlainPct::endPerform() | ||
| 81 | { | ||
| 82 | if(!bDidReq) | ||
| 83 | iCP++; | ||
| 84 | bDidReq = false; | ||
| 85 | } | ||
| 86 | |||
| 87 | void ViewerPlainPct::beginPerforms( int nCount ) | ||
| 88 | { | ||
| 89 | iTP = nCount; | ||
| 90 | iCP = 1; | ||
| 91 | bDidReq = false; | ||
| 92 | } | ||
| 93 | |||
| 94 | void ViewerPlainPct::beginAction( const std::string &sName, int nCommands ) | ||
| 95 | { | ||
| 96 | iTC = nCommands; | ||
| 97 | iCC = 1; | ||
| 98 | } | ||
| 99 | |||
| 100 | void ViewerPlainPct::endAction() | ||
| 101 | { | ||
| 102 | if( bRunClean == true ) | ||
| 103 | { | ||
| 104 | printf("Nothing to be done.\n\n"); | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
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 @@ | |||
| 1 | #ifndef VIEWER_PLAIN_H | ||
| 2 | #define VIEWER_PLAIN_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <list> | ||
| 6 | #include "viewer.h" | ||
| 7 | |||
| 8 | class ViewerPlainPct : public Viewer | ||
| 9 | { | ||
| 10 | public: | ||
| 11 | ViewerPlainPct(); | ||
| 12 | virtual ~ViewerPlainPct(); | ||
| 13 | |||
| 14 | virtual void beginCommand( Action::eAction nAct, const std::string &sTarget ); | ||
| 15 | virtual void endCommand(); | ||
| 16 | |||
| 17 | virtual void beginRequiresCheck( bool bCached, const std::string &sName ); | ||
| 18 | virtual void endRequiresCheck(); | ||
| 19 | virtual void beginPerform( Perform *pPerform ); | ||
| 20 | virtual void endPerform(); | ||
| 21 | virtual void beginPerforms( int nCount ); | ||
| 22 | |||
| 23 | virtual void beginAction( const std::string &sName, int nCommands ); | ||
| 24 | |||
| 25 | virtual void endAction(); | ||
| 26 | |||
| 27 | void printHead(); | ||
| 28 | void indent(); | ||
| 29 | |||
| 30 | private: | ||
| 31 | bool bDidReq; | ||
| 32 | int iTP, iCP, iTC, iCC; | ||
| 33 | |||
| 34 | bool bRunClean; | ||
| 35 | typedef struct | ||
| 36 | { | ||
| 37 | int nLevel; | ||
| 38 | bool bCmdClean; | ||
| 39 | std::string sTarget; | ||
| 40 | } Cmd; | ||
| 41 | typedef std::list<Cmd> CmdStack; | ||
| 42 | CmdStack sCmd; | ||
| 43 | }; | ||
| 44 | |||
| 45 | #endif | ||
