aboutsummaryrefslogtreecommitdiff
path: root/src/viewdefault.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-21 18:04:02 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-21 18:04:02 +0000
commitfb28f6800864176be2ffca29e8e664b641f33170 (patch)
treeba9180ac442939edc4eacbe1fdae93c5a7f87cee /src/viewdefault.cpp
parent51e21a316be6e052251b3dfc7d671061ebd67cee (diff)
downloadbuild-fb28f6800864176be2ffca29e8e664b641f33170.tar.gz
build-fb28f6800864176be2ffca29e8e664b641f33170.tar.bz2
build-fb28f6800864176be2ffca29e8e664b641f33170.tar.xz
build-fb28f6800864176be2ffca29e8e664b641f33170.zip
m3 is copied into trunk, we should be good to go, now.
Diffstat (limited to '')
-rw-r--r--src/viewdefault.cpp170
1 files changed, 170 insertions, 0 deletions
diff --git a/src/viewdefault.cpp b/src/viewdefault.cpp
new file mode 100644
index 0000000..c38c62f
--- /dev/null
+++ b/src/viewdefault.cpp
@@ -0,0 +1,170 @@
1#include "viewdefault.h"
2#include "target.h"
3
4#include <bu/plugger.h>
5
6#include <bu/sio.h>
7using namespace Bu;
8
9PluginInterface3( pluginViewDefault, default, ViewDefault, View,
10 "Mike Buland", 0, 1 );
11
12#define ESC "\x1b"
13
14#define C_RESET ESC "[0m"
15#define C_RED ESC "[31m"
16#define C_GREEN ESC "[32m"
17#define C_YELLOW ESC "[33m"
18#define C_BLUE ESC "[34m"
19#define C_MAGENTA ESC "[35m"
20#define C_CYAN ESC "[36m"
21#define C_WHITE ESC "[37m"
22#define C_DEFAULT ESC "[39m"
23
24#define C_BR_RED ESC "[1;31m"
25#define C_BR_GREEN ESC "[1;32m"
26#define C_BR_YELLOW ESC "[1;33m"
27#define C_BR_BLUE ESC "[1;34m"
28#define C_BR_MAGENTA ESC "[1;35m"
29#define C_BR_CYAN ESC "[1;36m"
30#define C_BR_WHITE ESC "[1;37m"
31
32ViewDefault::ViewDefault() :
33 bFirst( true ),
34 iDepth( 0 ),
35 iTotal( 0 ),
36 iCurrent( 0 )
37{
38}
39
40ViewDefault::~ViewDefault()
41{
42}
43
44void ViewDefault::beginAction( const Bu::FString &/*sAction*/ )
45{
46}
47
48void ViewDefault::endAction()
49{
50}
51
52void ViewDefault::skipTarget( const Bu::FString &/*sProfile*/,
53 const Target &/*rTarget*/ )
54{
55 iCurrent++;
56}
57
58void ViewDefault::beginTarget( const Bu::FString &sProfile,
59 const Target &rTarget )
60{
61 if( iDepth == 0 )
62 {
63 iTotal = rTarget.getDepCount();
64 iCurrent = 0;
65 if( bFirst == false )
66 {
67 sio << sio.nl;
68 }
69 bFirst = false;
70 sio << C_BR_WHITE << " --- " << C_BR_CYAN << sProfile << " "
71 << rTarget.getOutputList().first() << C_BR_WHITE << " --- "
72 << C_RESET << sio.nl;
73 }
74 iDepth++;
75}
76
77void ViewDefault::processTarget( const Bu::FString &/*sProfile*/,
78 const Target &rTarget )
79{
80 iCurrent++;
81
82 int iPct = (iTotal>0)?(iCurrent*100/iTotal):(100);
83 sio << C_BR_WHITE << "[" << C_BR_GREEN << Fmt(3) << iPct
84 << "%" << C_BR_WHITE << "] " << C_BR_MAGENTA
85 << Fmt(10) << rTarget.getDisplay() << C_BR_WHITE
86 << ": " << rTarget.getOutputList().first() << C_RESET << sio.nl;
87}
88
89void ViewDefault::endTarget()
90{
91 iDepth--;
92}
93
94void ViewDefault::buildRequires( const Target &rTarget )
95{
96 int iPct = (iTotal>0)?(iCurrent*100/iTotal):(100);
97 sio << C_BR_WHITE << "[" << C_BR_GREEN << Fmt(3) << iPct
98 << "%" << C_BR_WHITE << "] " << C_BR_MAGENTA
99 << Fmt(10) << "deps" << C_BR_WHITE
100 << ": " << rTarget.getOutputList().first() << C_RESET << sio.nl;
101}
102
103void ViewDefault::cmdStarted( const Bu::FString &/*sCmd*/ )
104{
105}
106
107void ViewDefault::cmdFinished( const Bu::FString &sStdOut,
108 const Bu::FString &sStdErr, long /*iExit*/ )
109{
110 if( sStdOut )
111 {
112 Bu::FString::const_iterator b;
113 b = sStdOut.begin();
114 while( b )
115 {
116 Bu::FString::const_iterator e, max;
117 max = b + 78;
118 for( e = b; e != max && *e != '\n'; e++ ) { }
119 sio << C_BR_GREEN << "| " << C_RESET << FString( b, e ) << sio.nl;
120 b = e;
121 if( *b == '\n' )
122 b++;
123 }
124 sio << C_BR_GREEN << "\\-----" << C_RESET << sio.nl;
125 }
126 if( sStdErr )
127 {
128 Bu::FString::const_iterator b;
129 b = sStdErr.begin();
130 while( b )
131 {
132 Bu::FString::const_iterator e, max;
133 max = b + 78;
134 for( e = b; e != max && *e != '\n'; e++ ) { }
135 sio << C_BR_RED << "| " << C_RESET << FString( b, e ) << sio.nl;
136 b = e;
137 if( *b == '\n' )
138 b++;
139 }
140 sio << C_BR_RED << "\\-----" << C_RESET << sio.nl;
141 }
142 //sio << C_BR_WHITE << "[" << C_BR_GREEN << sStdOut << C_BR_WHITE << "]" << sio.nl;
143 //sio << C_BR_WHITE << "[" << C_BR_RED << sStdErr << C_BR_WHITE << "]" << sio.nl;
144}
145
146void ViewDefault::userError( const Bu::FString &sMsg )
147{
148 sio << C_BR_RED << "Error: " << sMsg << C_RESET << sio.nl;
149}
150
151void ViewDefault::userWarning( const Bu::FString &sMsg )
152{
153 sio << C_BR_YELLOW << "Warning: " << sMsg << C_RESET << sio.nl;
154}
155
156void ViewDefault::userNotice( const Bu::FString &sMsg )
157{
158 sio << C_BR_GREEN << "Notice: " << sMsg << C_RESET << sio.nl;
159}
160
161void ViewDefault::sysError( const Bu::FString &sMsg )
162{
163 sio << C_BR_RED << sMsg << C_RESET << sio.nl;
164}
165
166void ViewDefault::sysWarning( const Bu::FString &sMsg )
167{
168 sio << C_BR_YELLOW << sMsg << C_RESET << sio.nl;
169}
170