aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp9
-rw-r--r--src/viewerfactory.cpp2
-rw-r--r--src/viewerplainpct.cpp107
-rw-r--r--src/viewerplainpct.h45
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 @@
3extern struct PluginInfo plain; 3extern struct PluginInfo plain;
4extern struct PluginInfo percent; 4extern struct PluginInfo percent;
5extern struct PluginInfo make; 5extern struct PluginInfo make;
6extern struct PluginInfo plainpct;
6 7
7ViewerFactory::ViewerFactory() 8ViewerFactory::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
14ViewerFactory::~ViewerFactory() 16ViewerFactory::~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
6PluginInterface2( plainpct, ViewerPlainPct, Viewer, "Mike Buland", 0, 1 );
7
8ViewerPlainPct::ViewerPlainPct() :
9 bRunClean( true )
10{
11}
12
13ViewerPlainPct::~ViewerPlainPct()
14{
15}
16
17void 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
31void ViewerPlainPct::endCommand()
32{
33 if( sCmd.front().bCmdClean == false )
34 printf("\n");
35 sCmd.pop_front();
36 iCC++;
37}
38
39void 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
49void 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
60void 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
67void ViewerPlainPct::endRequiresCheck()
68{
69 iCP++;
70 bDidReq = true;
71}
72
73void 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
80void ViewerPlainPct::endPerform()
81{
82 if(!bDidReq)
83 iCP++;
84 bDidReq = false;
85}
86
87void ViewerPlainPct::beginPerforms( int nCount )
88{
89 iTP = nCount;
90 iCP = 1;
91 bDidReq = false;
92}
93
94void ViewerPlainPct::beginAction( const std::string &sName, int nCommands )
95{
96 iTC = nCommands;
97 iCC = 1;
98}
99
100void 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
8class ViewerPlainPct : public Viewer
9{
10public:
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
30private:
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