aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile51
-rw-r--r--Makefile.slim24
-rw-r--r--build.conf41
-rwxr-xr-xcheckinst.sh10
-rw-r--r--congo86
-rw-r--r--regexptest.cpp47
-rw-r--r--src/action.cpp53
-rw-r--r--src/action.h66
-rw-r--r--src/bfilt/c++/bfilt-c++.l64
-rw-r--r--src/build.cpp442
-rw-r--r--src/build.h107
-rw-r--r--src/build.l173
-rw-r--r--src/build.y278
-rw-r--r--src/buildparser.cpp613
-rw-r--r--src/buildparser.h192
-rw-r--r--src/cache.cpp149
-rw-r--r--src/cache.h33
-rw-r--r--src/function.cpp25
-rw-r--r--src/function.h23
-rw-r--r--src/functioncommandtolist.cpp68
-rw-r--r--src/functioncommandtolist.h21
-rw-r--r--src/functiondirectoriesin.cpp69
-rw-r--r--src/functiondirectoriesin.h21
-rw-r--r--src/functionfactory.cpp22
-rw-r--r--src/functionfactory.h20
-rw-r--r--src/functionfilesin.cpp58
-rw-r--r--src/functionfilesin.h21
-rw-r--r--src/functionregexp.cpp86
-rw-r--r--src/functionregexp.h21
-rw-r--r--src/functiontargets.cpp35
-rw-r--r--src/functiontargets.h21
-rw-r--r--src/functiontostring.cpp33
-rw-r--r--src/functiontostring.h21
-rw-r--r--src/main.cpp172
-rw-r--r--src/parser.cpp27
-rw-r--r--src/parser.h40
-rw-r--r--src/perform.cpp26
-rw-r--r--src/perform.h55
-rw-r--r--src/performcommand.cpp35
-rw-r--r--src/performcommand.h21
-rw-r--r--src/performfactory.cpp12
-rw-r--r--src/performfactory.h20
-rw-r--r--src/regexp.cpp78
-rw-r--r--src/regexp.h36
-rw-r--r--src/rule.cpp159
-rw-r--r--src/rule.h86
-rw-r--r--src/stringproc.cpp12
-rw-r--r--src/stringproc.h33
-rw-r--r--src/stringprocbuild.cpp54
-rw-r--r--src/stringprocbuild.h20
-rw-r--r--src/target.cpp31
-rw-r--r--src/target.h63
-rw-r--r--src/targetfactory.cpp12
-rw-r--r--src/targetfactory.h20
-rw-r--r--src/targetfile.cpp158
-rw-r--r--src/targetfile.h28
-rw-r--r--src/viewer.cpp70
-rw-r--r--src/viewer.h38
-rw-r--r--src/viewercolorpct.cpp129
-rw-r--r--src/viewercolorpct.h49
-rw-r--r--src/viewerfactory.cpp20
-rw-r--r--src/viewerfactory.h20
-rw-r--r--src/viewermake.cpp19
-rw-r--r--src/viewermake.h20
-rw-r--r--src/viewerpercent.cpp129
-rw-r--r--src/viewerpercent.h39
-rw-r--r--src/viewerplain.cpp87
-rw-r--r--src/viewerplain.h39
-rw-r--r--src/viewerplainpct.cpp128
-rw-r--r--src/viewerplainpct.h49
70 files changed, 0 insertions, 5028 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index c1cf095..0000000
--- a/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
1LIBBU:=$(foreach f,paramproc.h paramproc.cpp fstring.h fstring.cpp exceptionbase.cpp exceptionbase.h archive.cpp archive.h archival.cpp archival.h plugger.h plugger.cpp singleton.h hash.cpp hash.h file.h file.cpp stream.h stream.cpp list.h list.cpp set.h set.cpp trace.h trace.cpp util.h fbasicstring.cpp fbasicstring.h sharedcore.cpp sharedcore.h archivebase.cpp archivebase.h util.h util.cpp,src/$f)
2SRC:=$(sort $(wildcard src/*.cpp) $(patsubst src/%,src/bu/%,$(filter %.cpp,$(LIBBU))))
3OBJ:=src/build.yy.o src/build.tab.o $(patsubst %.cpp,%.o,$(SRC))
4REV:=$(shell svn info | grep "Revision" | cut -d\ -f2)
5VER:=r$(REV)
6PKG:=build-$(VER).tar.bz2
7
8.PHONY: all extern clean distclean package
9# .SILENT:
10
11all: extern build
12
13package: clean distclean extern $(PKG)
14
15$(PKG):
16 mkdir build-$(VER)
17 mkdir build-$(VER)/src
18 mkdir build-$(VER)/src/bu
19 cp -a src/*.{cpp,h,y,l} build-$(VER)/src
20 cp -a src/bu/*.{cpp,h} build-$(VER)/src/bu
21 cp -a build.conf build-$(VER)
22 cp -a Makefile.slim build-$(VER)/Makefile
23 tar -c build-$(VER) | bzip2 -9 > $(PKG)
24 rm -Rf build-$(VER)
25
26clean:
27 -rm -Rf build $(OBJ)
28
29distclean:
30 -rm -Rf $(LIBBU)
31 -rm -Rf src/bu
32
33extern: $(LIBBU)
34
35$(LIBBU):
36 if [ ! -f src/bu/$@ ]; then mkdir -p src/bu; wget -nv -Psrc/bu http://svn.xagasoft.com/libbu++/trunk/$@; fi
37
38build: src/build.yy.c src/build.tab.c $(OBJ)
39 g++ -ggdb -ldl -o build $(OBJ)
40
41%.o: %.cpp
42 g++ -ggdb -Isrc -c -o $@ $<
43
44%.o: %.c
45 g++ -ggdb -Isrc -c -o $@ $<
46
47%.yy.c: %.l
48 flex --bison-bridge --bison-locations -o $@ $<
49
50%.tab.c: %.y
51 bison -v -b$(patsubst %.tab.c,%,$@) $<
diff --git a/Makefile.slim b/Makefile.slim
deleted file mode 100644
index d12435f..0000000
--- a/Makefile.slim
+++ /dev/null
@@ -1,24 +0,0 @@
1SRC:=$(sort $(wildcard src/*.cpp) $(wildcard src/bu/*.cpp))
2OBJ:=src/build.yy.o src/build.tab.o $(patsubst %.cpp,%.o,$(SRC))
3
4.PHONY: all clean
5
6all: build
7
8clean:
9 -rm -Rf build $(OBJ)
10
11build: src/build.yy.c src/build.tab.c $(OBJ)
12 g++ -ggdb -ldl -o build $(OBJ)
13
14%.o: %.cpp
15 g++ -ggdb -Isrc -c -o $@ $<
16
17%.o: %.c
18 g++ -ggdb -Isrc -c -o $@ $<
19
20%.yy.c: %.l
21 flex --bison-bridge --bison-locations -o $@ $<
22
23%.tab.c: %.y
24 bison -v -b$(patsubst %.tab.c,%,$@) $<
diff --git a/build.conf b/build.conf
deleted file mode 100644
index b52528c..0000000
--- a/build.conf
+++ /dev/null
@@ -1,41 +0,0 @@
1# build.conf for build, kind of whacky, eh?
2
3default action: check targets()
4
5set "CXXFLAGS" += "-ggdb"
6
7"build":
8 rule "exe",
9 target file,
10 requires "libbu++/libbu++.a",
11 set "LDFLAGS" += "-Llibbu++ -Wl,-Bstatic -lbu++ -Wl,-Bdynamic -ldl",
12 set "CXXFLAGS" += "-Ilibbu++",
13 set "FLEXFLAGS" = "--bison-bridge --bison-locations",
14 input filesIn("src") filter regexp(".*\\.(cpp|y|l)$")
15
16directoriesIn("src/bfilt", "bfilt-"):
17 rule "exe",
18 target file,
19 input filesIn("{fulldir}") filter regexp(".*\\.(cpp|y|l)$")
20
21rule "exe":
22 matches regexp("(.*)\\.o$"),
23 aggregate toString(" "),
24 perform command("g++ -o {target} {match} {LDFLAGS}")
25
26rule "cpp":
27 matches regexp("(.*)\\.(cpp|c)$"),
28 produces "{re:1}.o",
29 requires commandToList("g++ -M {CXXFLAGS} {match}", "make"),
30 perform command("g++ {CXXFLAGS} -c -o {target} {match}")
31
32rule "bison":
33 matches regexp("(.*)\\.y$"),
34 produces ["{re:1}.tab.c", "{re:1}.tab.h", "{re:1}.output"],
35 perform command("bison -v -b{re:1} {match}")
36
37rule "flex":
38 matches regexp("(.*)\\.l$"),
39 produces "{re:1}.yy.c",
40 perform command("flex {FLEXFLAGS} -o {target} {match}")
41
diff --git a/checkinst.sh b/checkinst.sh
deleted file mode 100755
index d6da889..0000000
--- a/checkinst.sh
+++ /dev/null
@@ -1,10 +0,0 @@
1#!/bin/bash
2
3CMD="ln -svf $PWD/build /usr/bin; ln -svf $PWD/bfilt-c++ /usr/bin"
4
5if [ $UID == 0 ]; then
6 bash -c "$CMD"
7else
8 echo This script needs root access...
9 su root -c "$CMD"
10fi
diff --git a/congo b/congo
deleted file mode 100644
index f64cd9b..0000000
--- a/congo
+++ /dev/null
@@ -1,86 +0,0 @@
1#
2# Simple build.conf test file
3#
4# you can have as many actions as you'd like, the one that's run by default is
5# called "default action", you need a default action.
6#
7# Actions are filled with a comma-seperated list of commands, like "check xxx"
8# to check to see if a target needs to be rebuilt
9#
10default action: check congo, check congod
11
12#
13# This action will only build the server program
14#
15server action: check congod
16
17#
18# After that, it helps to define some targets, things that commands usually
19# refer to and interact with.
20#
21
22#
23# "create file" will do just what it says, create a file based on some
24# information and a rule.
25#
26# "from files in" tells us that a list of directories follows, and the input
27# list for the rule should be built from these files.
28#
29# "using rule" tells us which rule to use to actuall create the file
30#
31create file congod from files in src/congod, src/shared using rule exe
32create file congo from files in src/congo, src/shared using rule exe
33
34create files "modules/db{name}.so" from directories in src/congod/db ...
35 from files in "src/congod/db/{name}" using rule lib
36
37#
38# After all of that, some targets or list items may have their own additional
39# dependancies, depending on the rule that built them. You can define these
40# extra dependancies using "xxx requires yyy" which will force the system to
41# attempt to create yyy before xxx.
42#
43congod requires libcongo.a
44congo requires libcongo.a
45
46#
47# There are a number of variables that the rules can use, including any in the
48# environment. Sometimes you want to modify these, to do that you can use "set"
49# and the name of the variable, along with what to do to it.
50#
51# You can use '=' to set the value, destroying what was there, or '+=' to add
52# the new text to the variable, this will assume that the text you provide is
53# made up of space-delimited tokens, and will ensure spaces surround them when
54# they are added.
55#
56set CXXFLAGS += "-Ilibbu++/src"
57set LDFLAGS += "-Llibbu++ -lbu++"
58
59#
60# Sometimes individual targets or list items require special settings, this is
61# easy since build maintians a seperate set of variables for any items that need
62# special support.
63#
64# Currently you can only set, for an item, later you may be able to do more.
65#
66for congo set LDFLAGS += "-lreadline"
67
68#
69# Finally, no file is complete without some rules. Rules determine how to
70# fulfill target checking based on some input data. Generally this is going to
71# be creating an executable from a list of source files.
72#
73#
74# First specify the rule name, then you can filter the input list, if desired,
75# in two ways. You can use items that match a regular expression, and execute
76# the rule once for the whole list collectively, or once for each element that
77# made it through the filter.
78#
79# Within the perform, there are several things that could go there, for now,
80# just command, which takes a string, you can use {} for variable substitution.
81#
82rule exe matches all /(.*)\.o/ perform command ...
83 "g++ {matches} {LDFLAGS} -o {target}"
84
85rule cpp matches one /(.*)\.cpp/ produces {1}.o perform command ...
86 "g++ {CXXFLAGS} -o {target} {match}"
diff --git a/regexptest.cpp b/regexptest.cpp
deleted file mode 100644
index 01597be..0000000
--- a/regexptest.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
1#include <stdio.h>
2#include <regex.h>
3#include <string>
4
5int test( const char *str, const char *sRegExp )
6{
7 printf("Compiling: %s\n", sRegExp );
8 regex_t r;
9 if( regcomp( &r, sRegExp, REG_EXTENDED|REG_NEWLINE ) )
10 {
11 printf("Error compiling regular expression.\n");
12 return 0;
13 }
14
15 printf("Compiled, %d sub expressions.\n", r.re_nsub );
16
17 int nMatch = r.re_nsub+1;
18 regmatch_t *match = new regmatch_t[nMatch];
19 if( regexec( &r, str, nMatch, match, 0 ) )
20 {
21 printf("Regular expression did not match.\n");
22 return 0;
23 }
24
25 printf("Match!\nSubstrings:\n");
26 for( int j = 0; j < nMatch; j++ )
27 {
28 printf(" %d: (%d-%d) %s\n",
29 j,
30 match[j].rm_so, match[j].rm_eo,
31 std::string(str+match[j].rm_so, match[j].rm_eo-match[j].rm_so ).c_str()
32 );
33 }
34
35 delete[] match;
36 regfree( &r );
37}
38
39int main( int argc, char *argv[] )
40{
41 printf("Regular expression test:\n\n");
42
43 test( argv[1], argv[2] );
44
45 return 0;
46}
47
diff --git a/src/action.cpp b/src/action.cpp
deleted file mode 100644
index 2588caa..0000000
--- a/src/action.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
1#include "action.h"
2
3Action::Action()
4{
5}
6
7Action::~Action()
8{
9}
10
11void Action::addCommand( eAction act, const std::string &sWhat, bool bIsGroup )
12{
13 lCmds.push_back( Cmd( act, sWhat, bIsGroup ) );
14}
15
16void Action::begin()
17{
18 i = lCmds.begin();
19}
20
21bool Action::isEnded()
22{
23 return i == lCmds.end();
24}
25
26void Action::next()
27{
28 i++;
29}
30
31Action::eAction Action::getAct()
32{
33 return (*i).act;
34}
35
36std::string Action::getWhat()
37{
38 return (*i).sWhat;
39}
40
41bool Action::isGroup()
42{
43 return (*i).bIsGroup;
44}
45
46void Action::setMode( eAction nAct )
47{
48 for( CmdList::iterator j = lCmds.begin(); j != lCmds.end(); j++ )
49 {
50 (*j).act = nAct;
51 }
52}
53
diff --git a/src/action.h b/src/action.h
deleted file mode 100644
index 929c1c5..0000000
--- a/src/action.h
+++ /dev/null
@@ -1,66 +0,0 @@
1#ifndef ACTION_H
2#define ACTION_H
3
4#include <stdint.h>
5
6#include <string>
7#include <list>
8
9class Action
10{
11public:
12 enum eAction
13 {
14 actCheck,
15 actClean
16 };
17public:
18 Action();
19 virtual ~Action();
20
21 typedef struct Cmd
22 {
23 Cmd( eAction act, const std::string &sWhat, bool bIsGroup ) :
24 act( act ), sWhat( sWhat ), bIsGroup( bIsGroup )
25 {}
26 eAction act;
27 std::string sWhat;
28 bool bIsGroup;
29 } Cmd;
30
31 void addCommand( eAction act, const std::string &sWhat, bool bIsGroup );
32
33 void begin();
34 bool isEnded();
35 void next();
36
37 int size()
38 {
39 return lCmds.size();
40 }
41
42 eAction getAct();
43 std::string getWhat();
44 bool isGroup();
45
46 void setName( const std::string &sName )
47 {
48 this->sName = sName;
49 }
50
51 std::string getName()
52 {
53 return sName;
54 }
55
56 void setMode( eAction nAct );
57
58private:
59 typedef std::list<Cmd> CmdList;
60 CmdList lCmds;
61 CmdList::iterator i;
62 std::string sName;
63
64};
65
66#endif
diff --git a/src/bfilt/c++/bfilt-c++.l b/src/bfilt/c++/bfilt-c++.l
deleted file mode 100644
index 4e71649..0000000
--- a/src/bfilt/c++/bfilt-c++.l
+++ /dev/null
@@ -1,64 +0,0 @@
1%{
2# include <string>
3
4int nBC = 0;
5%}
6
7%s hasT
8%x inWith
9%x inT
10%option noyywrap nounput batch
11
12%%
13
14"operator<<" { ECHO; }
15"operator>>" { ECHO; }
16"operator". { ECHO; }
17
18"<<" { ECHO; }
19">>" { ECHO; }
20" <<" { ECHO; }
21" >>" { ECHO; }
22"'<'" { ECHO; }
23"'>'" { ECHO; }
24
25"<anonymous>" { ECHO; }
26
27\n+ {
28 BEGIN( INITIAL );
29 nBC = false;
30 ECHO;
31}
32
33" <" { ECHO; }
34
35"<" {
36 BEGIN( inT );
37 printf("<...>");
38 nBC++;
39}
40
41<inT>"<" {
42 nBC++;
43
44}
45<inT>[^<>]* { }
46<inT>">" {
47 nBC--;
48 if( nBC == 0 )
49 BEGIN( hasT );
50}
51
52<hasT>" [with"[^\]]*"]" { }
53
54%%
55
56int main()
57{
58 yyin = stdin;
59
60 yylex();
61
62 return 0;
63}
64
diff --git a/src/build.cpp b/src/build.cpp
deleted file mode 100644
index dd6db1e..0000000
--- a/src/build.cpp
+++ /dev/null
@@ -1,442 +0,0 @@
1#include "build.h"
2#include "function.h"
3#include "viewerfactory.h"
4#include "bu/archive.h"
5#include "bu/file.h"
6
7#include <stdlib.h>
8
9subExceptionDef( BuildException );
10
11Build::Build() :
12 pStrProc( NULL ),
13 pView( NULL ),
14 bCacheUpdated( false )
15{
16}
17
18Build::~Build()
19{
20 if( sCacheName.size() > 0 && bCacheUpdated )
21 {
22 try
23 {
24 Bu::File f( sCacheName.c_str(),
25 Bu::File::Write|Bu::File::Create|Bu::File::Truncate );
26 Bu::Archive ar( f, Bu::Archive::save );
27
28 ar << cRequires;
29 }
30 catch( Bu::ExceptionBase &e )
31 {
32 }
33 }
34}
35
36void Build::setView( const std::string &sView )
37{
38 pView = ViewerFactory::getInstance().instantiate( sView.c_str() );
39}
40
41void Build::setCache( const std::string &sFileName )
42{
43 sCacheName = sFileName;
44
45 try
46 {
47 Bu::File f( sCacheName.c_str(), Bu::File::Read );
48 Bu::Archive ar( f, Bu::Archive::load );
49
50 ar >> cRequires;
51 }
52 catch( Bu::ExceptionBase &e )
53 {
54 }
55}
56
57void Build::setStringProc( StringProc *pStrProc )
58{
59 delete this->pStrProc;
60 this->pStrProc = pStrProc;
61}
62
63std::string Build::replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra )
64{
65 if( pStrProc == NULL )
66 throw BuildException(
67 "No valid string processor was registered with the Build object."
68 );
69
70 return pStrProc->replVars( sSrc, pCont, mExtra );
71}
72
73void Build::execAction( const std::string &sWhat )
74{
75 if( mAction.find( sWhat ) == mAction.end() )
76 throw BuildException(
77 "No action matches %s, check your build.conf.",
78 sWhat.c_str()
79 );
80
81 Action *pAct = mAction[sWhat];
82
83 pView->beginAction( sWhat, pAct->size() );
84
85 for( pAct->begin(); !pAct->isEnded(); pAct->next() )
86 {
87 if( pAct->isGroup() )
88 {
89 if( mGroup.find( pAct->getWhat() ) == mGroup.end() )
90 throw BuildException(
91 "No group matches %s in action %s.",
92 pAct->getWhat().c_str(),
93 sWhat.c_str()
94 );
95 TargetList &sl = mGroup[pAct->getWhat()];
96 for( TargetList::iterator i = sl.begin(); i != sl.end(); i++ )
97 {
98 Target *pTarget = *i;
99 if( !pTarget->wasRun() )
100 pTarget->run( pAct->getAct(), *this );
101 }
102 }
103 else
104 {
105 if( mTarget.find( pAct->getWhat() ) == mTarget.end() )
106 throw BuildException(
107 "No target matches %s in action %s.",
108 pAct->getWhat().c_str(),
109 sWhat.c_str()
110 );
111 Target *pTarget = mTarget[pAct->getWhat()];
112 //pView->beginCommand( pAct->getAct(), pAct->getWhat() );
113 if( !pTarget->wasRun() )
114 pTarget->run( pAct->getAct(), *this );
115 //pView->endCommand();
116 }
117 }
118
119 pView->endAction();
120
121 return;
122}
123
124void Build::addTarget( Target *pTarget )
125{
126 TargetMap::iterator i = mTarget.find( pTarget->getName() );
127 if( i == mTarget.end() )
128 {
129 mTarget[pTarget->getName()] = pTarget;
130 }
131 else
132 {
133 throw BuildException("Merging targets isn't working yet.");
134 }
135}
136
137void Build::addRequires( const std::string &who, const std::string &what )
138{
139 mRequires[who].push_back( what );
140}
141
142void Build::addRule( Rule *pRule )
143{
144 mRule[pRule->getName()] = pRule;
145}
146
147Rule *Build::getRule( const std::string &name )
148{
149 if( mRule.find( name ) == mRule.end() )
150 throw BuildException("No rule named %s found.", name.c_str() );
151
152 return mRule[name];
153}
154
155void Build::addAction( Action *pAction )
156{
157 mAction[pAction->getName()] = pAction;
158}
159
160void Build::set( const std::string &cont, const std::string &var, const std::string &val )
161{
162 if( cont == "" )
163 {
164 mVars[var] = replVars( val, NULL, NULL );
165 }
166 else
167 {
168 StringList cl;
169 cl.push_front( cont );
170 mContVars[cont][var] = replVars( val, &cl, NULL );
171 }
172}
173
174void Build::setAdd( const std::string &cont, const std::string &var, const std::string &val )
175{
176 if( cont == "" )
177 {
178 mVars[var] = getVar( NULL, var, NULL ) + " " + replVars( val, NULL, NULL );
179 }
180 else
181 {
182 StringList cl;
183 cl.push_front( cont );
184 mContVars[cont][var] = getVar( &cl, var, NULL ) + " " + replVars( val, &cl, NULL );
185 }
186}
187
188void Build::copyContext( const std::string &src, const std::string &dest )
189{
190 if( mContVars.find(src) == mContVars.end() )
191 return;
192
193 VarMap &d = mContVars[dest];
194 VarMap &s = mContVars[src];
195 for( VarMap::iterator i = s.begin(); i != s.end(); i++ )
196 d[(*i).first] = (*i).second;
197}
198
199std::string Build::getVar( const StringList *cont, const std::string &var, VarMap *mExtra )
200{
201 if( mExtra != NULL )
202 {
203 if( mExtra->find(var) == mExtra->end() )
204 {
205 return getVar( cont, var, NULL );
206 }
207 return (*mExtra)[var];
208 }
209
210 if( cont == NULL )
211 {
212 if( mVars.find(var) == mVars.end() )
213 {
214 if( getenv( var.c_str() ) == NULL )
215 {
216 mVars[var] = "";
217 }
218 else
219 {
220 mVars[var] = getenv( var.c_str() );
221 }
222 }
223 return mVars[var];
224 }
225 else
226 {
227 if( cont->empty() )
228 {
229 return getVar( NULL, var, NULL );
230 }
231 std::string sTop = cont->front();
232 if( mContVars[sTop].find(var) == mContVars[sTop].end() )
233 {
234 ((StringList *)cont)->pop_front();
235 mContVars[sTop][var] = getVar( cont, var, NULL );
236 ((StringList *)cont)->push_front( sTop );
237 }
238 return mContVars[sTop][var];
239 }
240}
241
242void Build::debugDump()
243{
244 printf("Requires:\n");
245 for( ReqMap::iterator i = mRequires.begin(); i != mRequires.end(); i++ )
246 {
247 printf(" %s: ", (*i).first.c_str() );
248
249 for( StringList::iterator j = (*i).second.begin();
250 j != (*i).second.end(); j++ )
251 {
252 if( j != (*i).second.begin() )
253 printf(", ");
254 printf("%s", (*j).c_str() );
255 }
256 printf("\n");
257 }
258
259 printf("Targets:\n");
260 for( TargetMap::iterator i = mTarget.begin(); i != mTarget.end(); i++ )
261 {
262 printf(" %s:\n", (*i).first.c_str() );
263 printf(" Rule: %s\n", (*i).second->getRule().c_str() );
264 printf(" Input: ");
265 for( StringList::iterator j = (*i).second->getInput().begin();
266 j != (*i).second->getInput().end(); j++ )
267 {
268 if( j != (*i).second->getInput().begin() )
269 printf(", ");
270 printf("%s", (*j).c_str() );
271 }
272 printf("\n");
273 }
274
275 printf("Global Variables:\n");
276 for( VarMap::iterator i = mVars.begin(); i != mVars.end(); i++ )
277 {
278 printf(" \"%s\" = \"%s\"\n", (*i).first.c_str(), (*i).second.c_str() );
279 }
280
281 printf("Context Variables:\n");
282 for( ContextMap::iterator i = mContVars.begin(); i != mContVars.end(); i++ )
283 {
284 printf(" %s:\n", (*i).first.c_str() );
285
286 for( VarMap::iterator j = (*i).second.begin();
287 j != (*i).second.end(); j++ )
288 {
289 printf(" \"%s\" = \"%s\"\n",
290 (*j).first.c_str(),
291 (*j).second.c_str()
292 );
293 }
294 }
295
296 printf("Rules:\n");
297 for( RuleMap::iterator i = mRule.begin(); i != mRule.end(); i++ )
298 {
299 printf(" %s:\n", (*i).first.c_str() );
300 printf(" Matches: func\n");
301 printf(" Filters: %d\n", (*i).second->getFilterList().size() );
302 printf(" Performs: %d\n", (*i).second->getPerformList().size() );
303 printf(" Produces:\n");
304 printf(" Requires:\n");
305 }
306
307 printf("Actions:\n");
308 for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ )
309 {
310 printf(" %s: ", (*i).first.c_str() );
311 for( (*i).second->begin(); !(*i).second->isEnded(); (*i).second->next() )
312 {
313 printf("%d:%s ", (*i).second->getAct(), (*i).second->getWhat().c_str() );
314 }
315 printf("\n");
316 }
317
318 printf("Groups:\n");
319 for( GroupMap::iterator i = mGroup.begin(); i != mGroup.end(); i++ )
320 {
321 printf(" %s: ", (*i).first.c_str() );
322 for( TargetList::iterator j = (*i).second.begin();
323 j != (*i).second.end(); j++ )
324 {
325 if( j != (*i).second.begin() ) printf(", ");
326 printf("%s", (*j)->getName().c_str() );
327 }
328 printf("\n");
329 }
330}
331
332RuleList Build::findChainRules( Rule *pHead )
333{
334 RuleList lOut;
335 FunctionList &lMatches = pHead->getMatchesList();
336
337 for( RuleMap::iterator i = mRule.begin(); i != mRule.end(); i++ )
338 {
339 if( (*i).second == pHead )
340 continue;
341
342 for( FunctionList::iterator j = lMatches.begin();
343 j != lMatches.end(); j++ )
344 {
345 StringList lTmp;
346 (*j)->execute( NULL, (*i).second->getProducesList(), lTmp );
347 if( !lTmp.empty() )
348 {
349 lOut.push_back( (*i).second );
350 break;
351 }
352 }
353 }
354
355 return lOut;
356}
357
358StringList &Build::getRequires( std::string sName )
359{
360 return mRequires[sName];
361}
362
363bool Build::getCached( const std::string &sID, int nTime, StringList &lOut )
364{
365 Cache::Entry *pEnt = cRequires.get( sID );
366 if( pEnt == NULL )
367 return false;
368 if( pEnt->tCreated < nTime )
369 return false;
370
371 lOut.insert( lOut.end(), pEnt->lData.begin(), pEnt->lData.end() );
372
373 return true;
374}
375
376void Build::updateCache( const std::string &sID, FunctionList &lFunc, StringList &lOut )
377{
378 Cache::Entry *pEnt = new Cache::Entry;
379 getView()->beginRequiresCheck( false, sID );
380 for( FunctionList::iterator f = lFunc.begin(); f != lFunc.end(); f++ )
381 {
382 StringList lTmpIn;
383 lTmpIn.push_back( sID );
384 (*f)->execute( this, lTmpIn, pEnt->lData );
385 }
386 getView()->endRequiresCheck();
387
388 lOut.insert( lOut.end(), pEnt->lData.begin(), pEnt->lData.end() );
389 cRequires.put( sID, pEnt );
390
391 pEnt->tCreated = time( NULL );
392
393 bCacheUpdated = true;
394}
395
396void Build::chainTarget( const std::string &sName )
397{
398 TargetMap::iterator i = mTarget.find(sName);
399 if( i == mTarget.end() ) return;
400
401 if( !(*i).second->wasRun() )
402 (*i).second->run( Action::actCheck, *this );
403}
404
405void Build::printInfo()
406{
407 printf("---- Build Info ----\n");
408 printf("Valid actions: ");
409 for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ )
410 {
411 if( i != mAction.begin() ) printf(", ");
412 if( (*i).first == "" )
413 printf("*default*");
414 else
415 printf("%s", (*i).first.c_str() );
416 }
417 printf("\n\n");
418}
419
420void Build::setMode( Action::eAction nAct )
421{
422 for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ )
423 {
424 (*i).second->setMode( nAct );
425 }
426}
427
428void Build::addToGroup( const std::string &sGroup, Target *pTarget )
429{
430 if( mGroup.find( sGroup ) == mGroup.end() )
431 {
432 mGroup[sGroup] = TargetList();
433 }
434
435 mGroup[sGroup].push_back( pTarget );
436}
437
438bool Build::hasAction( const std::string &str )
439{
440 return mAction.find( str ) != mAction.end();
441}
442
diff --git a/src/build.h b/src/build.h
deleted file mode 100644
index 1ffb547..0000000
--- a/src/build.h
+++ /dev/null
@@ -1,107 +0,0 @@
1#ifndef BUILD_H
2#define BUILD_H
3
4#include <stdint.h>
5
6#include <map>
7#include <string>
8
9#include "bu/exceptionbase.h"
10#include "rule.h"
11#include "target.h"
12#include "action.h"
13#include "stringproc.h"
14#include "cache.h"
15
16subExceptionDecl( BuildException );
17typedef std::map<std::string, std::string> VarMap;
18typedef std::map<std::string, Target *> TargetMap;
19typedef std::list<std::string> StringList;
20typedef std::map<std::string, StringList> ReqMap;
21typedef std::map<std::string, VarMap> ContextMap;
22typedef std::map<std::string, Rule *> RuleMap;
23typedef std::list<Rule *> RuleList;
24typedef std::map<std::string, Action *> ActionMap;
25typedef std::list<Target *> TargetList;
26typedef std::map<std::string, TargetList> GroupMap;
27
28class Viewer;
29
30class Build
31{
32public:
33 Build();
34 virtual ~Build();
35
36 void execAction( const std::string &sWhat );
37
38 /**
39 * Adds a target to the build. If the target already exists, this will
40 * attempt to merge them as best it can. If there are any conflicts, it
41 * will throw an exception.
42 *@param pTarget A pointer to a Target object that Build takes ownership of.
43 */
44 void addTarget( Target *pTarget );
45 void addRequires( const std::string &who, const std::string &what );
46 void addRule( Rule *pRule );
47 void addAction( Action *pAction );
48 bool hasAction( const std::string &str );
49 void addToGroup( const std::string &sGroup, Target *pTarget );
50
51 void set( const std::string &cont, const std::string &var, const std::string &val );
52 void setAdd( const std::string &cont, const std::string &var, const std::string &val );
53 void copyContext( const std::string &src, const std::string &dest );
54 std::string getVar( const StringList *cont, const std::string &var, VarMap *mExtra );
55
56 Rule *getRule( const std::string &name );
57
58 void debugDump();
59
60 void setStringProc( StringProc *pStrProc );
61 std::string replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra );
62 RuleList findChainRules( Rule *pHead );
63 StringList &getRequires( std::string sName );
64
65 Viewer *getView()
66 {
67 return pView;
68 }
69
70 TargetMap &getTargetMap()
71 {
72 return mTarget;
73 }
74
75 void setView( const std::string &sView );
76
77 void setCache( const std::string &sFileName );
78 bool getCached( const std::string &sID, int nTime, StringList &lOut );
79 void updateCache( const std::string &sID, FunctionList &lFunc, StringList &lOut );
80
81 void chainTarget( const std::string &sName );
82
83 void printInfo();
84
85 void setMode( Action::eAction nAct );
86
87private:
88 TargetMap mTarget;
89 ReqMap mRequires;
90 VarMap mVars;
91 ContextMap mContVars;
92 RuleMap mRule;
93 ActionMap mAction;
94 StringProc *pStrProc;
95 Viewer *pView;
96 Cache cRequires;
97 bool bCacheUpdated;
98 std::string sCacheName;
99 GroupMap mGroup;
100
101 //std::map<std::string, Rule *> mRule;
102 //Action *pActDefault;
103 //std::map<std::string, Action *> mAction;
104
105};
106
107#endif
diff --git a/src/build.l b/src/build.l
deleted file mode 100644
index 9065a49..0000000
--- a/src/build.l
+++ /dev/null
@@ -1,173 +0,0 @@
1%{
2# include <string>
3# include <string.h>
4# include "buildparser.h"
5# include "build.tab.h"
6
7char *stringdup( const char *sin )
8{
9 char *n = new char[strlen(sin)+1];
10 strcpy( n, sin );
11 return n;
12}
13
14std::string strbuf;
15%}
16
17%x strsq
18%x strdq
19%x cmdstr
20%x comment
21%option noyywrap nounput batch debug
22
23%{
24# define YY_USER_ACTION yylloc->last_column += yyleng;
25%}
26%%
27
28[,:=[\]()] return yytext[0];
29"+=" return TOK_ADDSET;
30
31"default" return TOK_DEFAULT;
32"action" return TOK_ACTION;
33"rule" return TOK_RULE;
34"requires" return TOK_REQUIRES;
35"set" return TOK_SET;
36"matches" return TOK_MATCHES;
37"perform" return TOK_PERFORM;
38"produces" return TOK_PRODUCES;
39"check" return TOK_CHECK;
40"clean" return TOK_CLEAN;
41"target" return TOK_TARGET;
42"input" return TOK_INPUT;
43"filter" return TOK_FILTER;
44"prefix" return TOK_PREFIX;
45"aggregate" return TOK_AGGREGATE;
46"group" return TOK_GROUP;
47
48\n+ {
49 yylloc->last_line += yyleng;
50 yylloc->first_line = yylloc->last_line;
51 yylloc->first_column = yylloc->last_column = 0;
52}
53
54[ \t\r]* {
55 yylloc->first_line = yylloc->last_line;
56 yylloc->first_column = yylloc->last_column+1;
57}
58
59"#".* /* single line comment */
60
61[a-zA-Z][a-zA-Z0-9]* {
62 {
63 if( bld.isTarget( yytext ) )
64 {
65 yylval->strval = stringdup( yytext );
66 return TARGETTYPE;
67 }
68 else if( bld.isPerform( yytext ) )
69 {
70 yylval->strval = stringdup( yytext );
71 return PERFORM;
72 }
73 else if( bld.isFunction( yytext ) )
74 {
75 yylval->strval = stringdup( yytext );
76 return FUNCTION;
77 }
78 bld.error( yylloc, "Invalid token" );
79 }
80}
81
82\" {
83 BEGIN( strdq );
84 strbuf = "";
85}
86\' {
87 BEGIN( strsq );
88 strbuf = "";
89}
90\` {
91 BEGIN( cmdstr );
92 strbuf = "";
93}
94
95<strdq>[^\\\n\"]+ {
96 strbuf += yytext;
97}
98
99<strsq>[^\\\n\']+ {
100 strbuf += yytext;
101}
102
103<cmdstr>[^\\\n\`]+ {
104 strbuf += yytext;
105}
106
107<strdq,strsq,cmdstr>\\n strbuf += "\n";
108<strdq,strsq,cmdstr>\\t strbuf += "\t";
109<strdq,strsq,cmdstr>\\r strbuf += "\r";
110<strdq,strsq,cmdstr>\\b strbuf += "\b";
111<strdq,strsq,cmdstr>\\f strbuf += "\f";
112<strdq,strsq,cmdstr>\\\\ strbuf += "\\";
113<strdq,strsq,cmdstr>\\\" strbuf += "\"";
114<strdq,strsq,cmdstr>\\\' strbuf += "\'";
115<strdq,strsq,cmdstr>\\\` strbuf += "`";
116<strdq,strsq,cmdstr>\\. bld.error( yylloc, "Invalid escape sequence.");
117
118<strdq>\" {
119 BEGIN( INITIAL );
120 yylval->strval = stringdup( strbuf.c_str() );
121 return STRING;
122}
123
124<strsq>\' {
125 BEGIN( INITIAL );
126 yylval->strval = stringdup( strbuf.c_str() );
127 return STRING;
128}
129
130<cmdstr>\` {
131 BEGIN( INITIAL );
132 FILE *fpg = popen( strbuf.c_str(), "r" );
133 strbuf = "";
134 for(;;)
135 {
136 char buf[1024];
137 int nRead = fread( buf, 1, 1024, fpg );
138 if( nRead == 0 ) break;
139 for( int j = 0; j < nRead; j++ )
140 {
141 if( buf[j] == '\n' || buf[j] == '\r' )
142 buf[j] = ' ';
143 }
144 strbuf.append( buf, nRead );
145 if( nRead < 1024 ) break;
146 }
147 yylval->strval = stringdup( strbuf.c_str() );
148 pclose( fpg );
149 return STRING;
150}
151
152. {
153 char buf[] = {"Character x is out of place"};
154 buf[10] = yytext[0];
155 bld.error( yylloc, buf );
156}
157
158%%
159
160void BuildParser::scanBegin()
161{
162 yy_flex_debug = false;
163 if( !(yyin = fopen( file.c_str(), "r" )) )
164 {
165 error( std::string("cannot open file: ") + file );
166 }
167}
168
169void BuildParser::scanEnd()
170{
171 fclose( yyin );
172}
173
diff --git a/src/build.y b/src/build.y
deleted file mode 100644
index 55940e8..0000000
--- a/src/build.y
+++ /dev/null
@@ -1,278 +0,0 @@
1%defines
2%{
3# include <string>
4# include "buildparser.h"
5# include "build.tab.h"
6# include "action.h"
7void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg );
8%}
9
10%parse-param { BuildParser &bld }
11%lex-param { BuildParser &bld }
12%pure-parser
13
14%locations
15
16%debug
17%error-verbose
18%union {
19 char *strval;
20}
21
22%token <strval> STRING "string literal"
23%token <strval> TARGETTYPE "target type"
24%token <strval> FUNCTION "function name"
25%token <strval> PERFORM "perform name"
26
27%token TOK_ADDSET "+="
28%token TOK_DEFAULT "default"
29%token TOK_ACTION "action"
30%token TOK_CHECK "check"
31%token TOK_CLEAN "clean"
32%token TOK_RULE "rule"
33%token TOK_TARGET "target"
34%token TOK_SET "set"
35%token TOK_INPUT "input"
36%token TOK_FILTER "filter"
37%token TOK_PREFIX "prefix"
38%token TOK_REQUIRES "requires"
39%token TOK_MATCHES "matches"
40%token TOK_PERFORM "perform"
41%token TOK_PRODUCES "produces"
42%token TOK_AGGREGATE "aggregate"
43%token TOK_GROUP "group"
44
45%token ',' ':' '=' '(' ')'
46
47%destructor { delete[] $$; } STRING FUNCTION
48
49%%
50
51// General input format
52input:
53 | input rule
54 | input action
55 | input target
56 | input set
57 ;
58
59// Rule interpretation
60rule: TOK_RULE STRING ':'
61 {
62 bld.addRule( $2 );
63 }
64 rulecmds
65 ;
66
67rulecmds: rulecmd
68 | rulecmds ',' rulecmd
69 ;
70
71rulecmd: TOK_MATCHES func
72 {
73 bld.addRuleMatches();
74 }
75 | TOK_PRODUCES list
76 {
77 bld.addRuleProduces();
78 }
79 | TOK_REQUIRES list
80 {
81 bld.addRuleRequires();
82 }
83 | TOK_INPUT TOK_FILTER func
84 {
85 bld.addRuleInputFilter();
86 }
87 | TOK_PERFORM perf
88 {
89 bld.addRulePerform();
90 }
91 | TOK_AGGREGATE func
92 {
93 bld.setRuleAggregate();
94 }
95 ;
96
97// Action interpretation
98action: TOK_DEFAULT TOK_ACTION ':'
99 {
100 bld.addAction();
101 }
102 actioncmds
103 | STRING TOK_ACTION ':'
104 {
105 if( $1[0] == '\0' )
106 bld.error(
107 &yylloc,
108 "You cannot use an empty string as the name of an action."
109 );
110 bld.addAction( $1 );
111 }
112 actioncmds
113 ;
114
115actioncmds: actioncmd
116 | actioncmds ',' actioncmd
117 ;
118
119actioncmd: TOK_CHECK list
120 {
121 bld.addCommand( Action::actCheck );
122 }
123 | TOK_CLEAN list
124 {
125 bld.addCommand( Action::actClean );
126 }
127 | TOK_CHECK TOK_GROUP STRING
128 {
129 bld.addGrpCommand( $3, Action::actCheck );
130 }
131 | TOK_CLEAN TOK_GROUP STRING
132 {
133 bld.addGrpCommand( $3, Action::actClean );
134 }
135 ;
136
137// Target interpretation
138target: list ':'
139 {
140 bld.newTarget();
141 }
142 targetcmds
143 ;
144
145targetcmds: targetcmd
146 | targetcmds ',' targetcmd
147 ;
148
149targetcmd: TOK_RULE STRING
150 {
151 bld.setTargetRule( $2 );
152 }
153 | TOK_TARGET TOK_PREFIX STRING
154 {
155 bld.setTargetPrefix( $3 );
156 }
157 | TOK_TARGET TARGETTYPE
158 {
159 bld.setTargetType( $2 );
160 }
161 | TOK_INPUT list
162 {
163 bld.addTargetInput();
164 }
165 | TOK_REQUIRES list
166 {
167 bld.addTargetRequires();
168 }
169 | TOK_SET targetset
170 | TOK_GROUP STRING
171 {
172 bld.addTargetGroup( $2 );
173 }
174 ;
175
176targetset: STRING '=' STRING
177 {
178 bld.addTargetSet( $1, $3, setSet );
179 }
180 | STRING TOK_ADDSET STRING
181 {
182 bld.addTargetSet( $1, $3, setAdd );
183 }
184 ;
185
186// global set
187set: TOK_SET setwhat
188 ;
189
190setwhat: STRING '=' STRING
191 {
192 bld.addGlobalSet( $1, $3, setSet );
193 }
194 | STRING TOK_ADDSET STRING
195 {
196 bld.addGlobalSet( $1, $3, setAdd );
197 }
198 ;
199
200// list goo
201list: singlelistitem listfilter
202 | '['
203 {
204 bld.newList();
205 }
206 listitems ']' listfilter
207 ;
208
209listfilter:
210 | TOK_FILTER func
211 {
212 bld.filterList();
213 }
214 ;
215
216listitems: listitem
217 | listitems ',' listitem
218 ;
219
220listitem: STRING
221 {
222 bld.addListString( $1 );
223 }
224 | func
225 {
226 bld.addListFunc();
227 }
228 ;
229
230singlelistitem: STRING
231 {
232 bld.newList();
233 bld.addListString( $1 );
234 }
235 | func
236 {
237 bld.newList();
238 bld.addListFunc();
239 }
240 ;
241
242// Function
243func: FUNCTION
244 {
245 bld.newFunctionCall( $1 );
246 }
247 '(' funcparams ')'
248 ;
249
250funcparams:
251 | STRING { bld.addFunctionParam( $1 ); }
252 | funcparams ',' STRING { bld.addFunctionParam( $3 ); }
253 ;
254
255// Perform
256perf: PERFORM
257 {
258 bld.newPerform( $1 );
259 }
260 '(' perfparams ')'
261 ;
262
263perfparams:
264 | STRING
265 {
266 bld.addPerformParam( $1 );
267 }
268 | perfparams ',' STRING
269 {
270 bld.addPerformParam( $3 );
271 }
272 ;
273%%
274
275void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg )
276{
277 bld.error( locp, msg );
278}
diff --git a/src/buildparser.cpp b/src/buildparser.cpp
deleted file mode 100644
index 8f40097..0000000
--- a/src/buildparser.cpp
+++ /dev/null
@@ -1,613 +0,0 @@
1#include "buildparser.h"
2#include "functionfactory.h"
3#include "performfactory.h"
4#include "targetfactory.h"
5#include "action.h"
6#include "build.h"
7#include "rule.h"
8#include "stringprocbuild.h"
9
10BuildParser::BuildParser() :
11 fFunction( FunctionFactory::getInstance() ),
12 fPerform( PerformFactory::getInstance() ),
13 fTarget( TargetFactory::getInstance() )
14{
15}
16
17BuildParser::~BuildParser()
18{
19}
20
21void yyparse( BuildParser &bld );
22extern int yydebug;
23
24Build *BuildParser::load( const std::string &sFile )
25{
26 file = sFile;
27 scanBegin();
28 //yydebug = 1;
29 yyparse( *this );
30 scanEnd();
31
32 return genBuild();
33}
34
35//
36// Target functions
37//
38bool BuildParser::isTarget( const char *sType )
39{
40 return fTarget.hasPlugin( sType );
41}
42
43void BuildParser::newTarget()
44{
45 lTargetTmp.push_back( TargetTmp(lTmp, TargetInfo()) );
46}
47
48void BuildParser::setTargetRule( const char *sRule )
49{
50 lTargetTmp.back().second.sRule = sRule;
51}
52
53void BuildParser::setTargetPrefix( const char *sPrefix )
54{
55 lTargetTmp.back().second.sPrefix = sPrefix;
56}
57
58void BuildParser::setTargetType( const char *sType )
59{
60 lTargetTmp.back().second.sType = sType;
61}
62
63void BuildParser::addTargetInput()
64{
65 lTargetTmp.back().second.lInput.first.insert(
66 lTargetTmp.back().second.lInput.first.end(),
67 lTmp.first.begin(), lTmp.first.end()
68 );
69 lTargetTmp.back().second.lInput.second = lTmp.second;
70}
71
72void BuildParser::addTargetRequires()
73{
74 lTargetTmp.back().second.lRequires.first.insert(
75 lTargetTmp.back().second.lRequires.first.end(),
76 lTmp.first.begin(), lTmp.first.end()
77 );
78 lTargetTmp.back().second.lRequires.second = lTmp.second;
79}
80
81void BuildParser::addTargetSet( const char *sVar, const char *sVal, int nHow )
82{
83 lTargetTmp.back().second.lVar.push_back( SetVar( sVar, sVal, nHow ) );
84}
85
86void BuildParser::addTargetGroup( const char *sGroup )
87{
88 lTargetTmp.back().second.lGroups.push_back( sGroup );
89}
90
91//
92// Function functions
93//
94bool BuildParser::isFunction( const char *sFunc )
95{
96 return fFunction.hasPlugin( sFunc );
97}
98
99void BuildParser::newFunctionCall( const char *sName )
100{
101 pTmpFunc = fFunction.instantiate( sName );
102}
103
104void BuildParser::addFunctionParam( const char *sParam )
105{
106 pTmpFunc->addParam( sParam );
107}
108
109//
110// List functions
111//
112void BuildParser::newList()
113{
114 lTmp.first.clear();
115 lTmp.second = NULL;
116}
117
118void BuildParser::addListString( const char *str )
119{
120 lTmp.first.push_back( BuildListItem(str, NULL) );
121}
122
123void BuildParser::addListFunc()
124{
125 lTmp.first.push_back( BuildListItem("", pTmpFunc ) );
126}
127
128void BuildParser::filterList()
129{
130 lTmp.second = pTmpFunc;
131 //StringList lTmp2;
132 //StringList lIn = buildToStringList( lTmp, StringList() );
133 //pTmpFunc->execute( NULL, lIn, lTmp2 );
134 //lTmp.clear();
135 //for( StringList::iterator i = lTmp2.begin(); i != lTmp2.end(); i++ )
136 //{
137 // lTmp.push_back( BuildListItem( *i, NULL ) );
138 //}
139}
140
141void BuildParser::buildListFilter( BuildList &lSrc )
142{
143 if( lSrc.second == NULL )
144 return;
145
146 StringList lTmp2;
147 StringList lIn = buildToStringList( lSrc, StringList() );
148 pTmpFunc->execute( NULL, lIn, lTmp2 );
149 lSrc.first.clear();
150 delete lSrc.second;
151 for( StringList::iterator i = lTmp2.begin(); i != lTmp2.end(); i++ )
152 {
153 lSrc.first.push_back( BuildListItem( *i, NULL ) );
154 }
155}
156
157StringList BuildParser::buildToStringList( const BuildList &lSrc, const StringList &lIn, Build *pPass )
158{
159 StringList lOut;
160
161 for( BuildListCore::const_iterator i = lSrc.first.begin();
162 i != lSrc.first.end(); i++ )
163 {
164 if( (*i).second )
165 {
166 (*i).second->execute( pPass, lIn, lOut );
167 }
168 else
169 {
170 lOut.push_back( (*i).first );
171 }
172 }
173
174 if( lSrc.second )
175 {
176 StringList lTmp;
177 lSrc.second->execute( pPass, lOut, lTmp );
178 lOut.swap( lTmp );
179 }
180
181 return lOut;
182}
183
184StringList BuildParser::buildToStringListDup( const BuildList &lSrc, const StringList &lIn, Build &bld, const std::string &sCont, VarMap *mExtra, Build *pPass )
185{
186 StringList lOut;
187
188 for( BuildListCore::const_iterator i = lSrc.first.begin();
189 i != lSrc.first.end(); i++ )
190 {
191 if( (*i).second )
192 {
193 StringList l;
194 l.push_back( sCont );
195 Function *pTmp = (*i).second->duplicate( bld, &l, mExtra );
196 pTmp->execute( pPass, lIn, lOut );
197 delete pTmp;
198 }
199 else
200 {
201 StringList l;
202 l.push_back( sCont );
203 lOut.push_back( bld.replVars( (*i).first, &l, mExtra ) );
204 }
205 }
206
207 if( lSrc.second )
208 {
209 StringList lTmp;
210 lSrc.second->execute( pPass, lOut, lTmp );
211 lOut.swap( lTmp );
212 }
213
214 return lOut;
215}
216
217//
218// Rule functions
219//
220void BuildParser::addRule( const char *sName )
221{
222 lRuleTmp.push_back( RuleInfo() );
223 lRuleTmp.back().sName = sName;
224 lRuleTmp.back().pAggregate = NULL;
225}
226
227void BuildParser::addRuleMatches()
228{
229 lRuleTmp.back().pMatches = pTmpFunc;
230}
231
232void BuildParser::addRuleProduces()
233{
234 lRuleTmp.back().lProduces.first.insert(
235 lRuleTmp.back().lProduces.first.end(),
236 lTmp.first.begin(), lTmp.first.end()
237 );
238}
239
240void BuildParser::addRuleRequires()
241{
242 lRuleTmp.back().lRequires.first.insert(
243 lRuleTmp.back().lRequires.first.end(),
244 lTmp.first.begin(), lTmp.first.end()
245 );
246}
247
248void BuildParser::addRuleInputFilter()
249{
250 lRuleTmp.back().lFilter.push_back( pTmpFunc );
251}
252
253void BuildParser::addRulePerform()
254{
255 lRuleTmp.back().lPerform.push_back( pTmpPerform );
256}
257
258void BuildParser::setRuleAggregate()
259{
260 lRuleTmp.back().pAggregate = pTmpFunc;
261}
262
263//
264// Perform functions
265//
266bool BuildParser::isPerform( const char *sPerf )
267{
268 return fPerform.hasPlugin( sPerf );
269}
270
271void BuildParser::newPerform( const char *sName )
272{
273 pTmpPerform = fPerform.instantiate( sName );
274}
275
276void BuildParser::addPerformParam( const char *sParam )
277{
278 pTmpPerform->addParam( sParam );
279}
280
281//
282// Functions for dealing with actions
283//
284void BuildParser::addAction()
285{
286 lActions.push_back( ActionTmp("", ActionTmpCmdList() ) );
287}
288
289void BuildParser::addAction( const char *sName )
290{
291 lActions.push_back( ActionTmp(sName, ActionTmpCmdList()) );
292}
293
294void BuildParser::addCommand( int nType )
295{
296 lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) );
297}
298
299void BuildParser::addGrpCommand( const char *sGroup, int nType )
300{
301 lActions.back().second.push_back( ActionTmpCmd( nType, sGroup ) );
302}
303
304//
305// Global variable functions
306//
307void BuildParser::addGlobalSet( const char *sVar, const char *sValue, int nHow )
308{
309 lGlobalVars.push_back( SetVar( sVar, sValue, nHow ) );
310}
311
312//
313// Debug
314//
315void BuildParser::debugDump()
316{
317 printf("Actions:\n");
318 for( ActionTmpList::iterator i = lActions.begin();
319 i != lActions.end(); i++ )
320 {
321 if( (*i).first == "" )
322 {
323 printf(" default:\n");
324 }
325 else
326 {
327 printf(" \"%s\":\n", (*i).first.c_str() );
328 }
329 for( ActionTmpCmdList::iterator j = (*i).second.begin();
330 j != (*i).second.end(); j++ )
331 {
332 printf(" %d ", (*j).nAct );
333 if( (*j).bGroup )
334 {
335 printf("!%s", (*j).sGroup.c_str() );
336 }
337 else
338 {
339 printBuildList( (*j).lCmds );
340 }
341 printf("\n");
342 }
343 }
344
345 printf("\nTargets:\n");
346 for( TargetTmpList::iterator i = lTargetTmp.begin();
347 i != lTargetTmp.end(); i++ )
348 {
349 printf(" ");
350 printBuildList( (*i).first );
351 printf(":\n");
352
353 printf(" Rule: %s\n", (*i).second.sRule.c_str() );
354 printf(" Prefix: %s\n", (*i).second.sPrefix.c_str() );
355 printf(" Type: %s\n", (*i).second.sType.c_str() );
356 printf(" Input: ");
357 printBuildList( (*i).second.lInput );
358 printf("\n Requires: ");
359 printBuildList( (*i).second.lRequires );
360 printf("\n Vars:\n");
361
362 for( SetVarList::iterator j = (*i).second.lVar.begin();
363 j != (*i).second.lVar.end(); j++ )
364 {
365 const char *op;
366 switch( (*j).third )
367 {
368 case setSet: op = "="; break;
369 case setAdd: op = "+="; break;
370 }
371 printf(" %s %s %s\n", (*j).first.c_str(), op, (*j).second.c_str() );
372 }
373 }
374
375 printf("\nGlobals:\n");
376 for( SetVarList::iterator j = lGlobalVars.begin();
377 j != lGlobalVars.end(); j++ )
378 {
379 const char *op;
380 switch( (*j).third )
381 {
382 case setSet: op = "="; break;
383 case setAdd: op = "+="; break;
384 }
385 printf(" %s %s %s\n", (*j).first.c_str(), op, (*j).second.c_str() );
386 }
387
388 printf("\nRules:\n");
389 for( RuleTmpList::iterator i = lRuleTmp.begin();
390 i != lRuleTmp.end(); i++ )
391 {
392 printf(" %s:\n", (*i).sName.c_str() );
393 printf(" Matches: func()\n");
394 printf(" Produces: ");
395 printBuildList( (*i).lProduces );
396 printf("\n Requires: ");
397 printBuildList( (*i).lRequires );
398 printf("\n Filters: %d\n", (*i).lFilter.size() );
399 printf(" Performs: %d\n", (*i).lPerform.size() );
400 }
401}
402
403void BuildParser::printBuildList( const BuildList &lst )
404{
405 printf("[");
406 for( BuildListCore::const_iterator k = lst.first.begin();
407 k != lst.first.end(); k++ )
408 {
409 if( k != lst.first.begin() )
410 {
411 printf(", ");
412 }
413 if( (*k).second )
414 {
415 printf("func()");
416 }
417 else
418 {
419 printf("\"%s\"", (*k).first.c_str() );
420 }
421 }
422 printf("]");
423}
424
425//
426// Actually make a build object
427//
428Build *BuildParser::genBuild()
429{
430 Build *bld = new Build;
431 bld->setStringProc( new StringProcBuild( bld ) );
432
433 for( SetVarList::iterator i = lGlobalVars.begin();
434 i != lGlobalVars.end(); i++ )
435 {
436 switch( (*i).third )
437 {
438 case setSet:
439 bld->set( "", (*i).first, (*i).second );
440 break;
441
442 case setAdd:
443 bld->setAdd( "", (*i).first, (*i).second );
444 break;
445 }
446 }
447
448 for( TargetTmpList::iterator i = lTargetTmp.begin();
449 i != lTargetTmp.end(); i++ )
450 {
451 StringList lTargetNames = buildToStringList(
452 (*i).first, StringList(), bld
453 );
454 for( StringList::iterator j = lTargetNames.begin();
455 j != lTargetNames.end(); j++ )
456 {
457 if( (*i).second.sType != "" )
458 {
459 Target *pTarget = fTarget.instantiate(
460 (*i).second.sType.c_str()
461 );
462 pTarget->setName( *j );
463 pTarget->setRule( (*i).second.sRule );
464
465 VarMap mExtra;
466 mExtra["target"] = (*j);
467
468 StringList lInputs = buildToStringListDup(
469 (*i).second.lInput, StringList(),
470 *bld, *j, &mExtra /*, bld <-- should this be here? */
471 );
472 pTarget->getInput().insert(
473 pTarget->getInput().end(),
474 lInputs.begin(), lInputs.end()
475 );
476
477 bld->addTarget( pTarget );
478
479 for( StringList::iterator c = (*i).second.lGroups.begin();
480 c != (*i).second.lGroups.end(); c++ )
481 {
482 bld->addToGroup( *c, pTarget );
483 }
484 }
485 StringList lReqs = buildToStringList(
486 (*i).second.lRequires, StringList()
487 );
488 for( StringList::iterator k = lReqs.begin();
489 k != lReqs.end(); k++ )
490 {
491 bld->addRequires( (*j), (*k) );
492 }
493 for( SetVarList::iterator k = (*i).second.lVar.begin();
494 k != (*i).second.lVar.end(); k++ )
495 {
496 switch( (*k).third )
497 {
498 case setSet:
499 bld->set( *j, (*k).first, (*k).second );
500 break;
501
502 case setAdd:
503 bld->setAdd( *j, (*k).first, (*k).second );
504 break;
505 }
506 }
507 }
508 }
509
510 for( RuleTmpList::iterator i = lRuleTmp.begin(); i != lRuleTmp.end(); i++ )
511 {
512 Rule *pRule = new Rule;
513 pRule->setName( (*i).sName );
514 pRule->getMatchesList().push_back( (*i).pMatches );
515
516 for( FunctionList::iterator j = (*i).lFilter.begin();
517 j != (*i).lFilter.end(); j++ )
518 {
519 pRule->getFilterList().push_back( *j );
520 }
521
522 for( PerformList::iterator j = (*i).lPerform.begin();
523 j != (*i).lPerform.end(); j++ )
524 {
525 pRule->getPerformList().push_back( *j );
526 }
527
528 for( BuildListCore::iterator j = (*i).lProduces.first.begin();
529 j != (*i).lProduces.first.end(); j++ )
530 {
531 if( (*j).second )
532 {
533 throw BuildException(
534 "You cannot have functions in produces lists (rule %s).",
535 (*i).sName.c_str() );
536 }
537 pRule->getProducesList().push_back( (*j).first );
538 }
539
540 if( (*i).pAggregate )
541 {
542 pRule->setAggregate( (*i).pAggregate );
543 }
544
545 for( BuildListCore::iterator j = (*i).lRequires.first.begin();
546 j != (*i).lRequires.first.end(); j++ )
547 {
548 if( (*j).second )
549 {
550 pRule->getReqFuncList().push_back( (*j).second );
551 }
552 else
553 {
554 pRule->getReqStrList().push_back( (*j).first );
555 }
556 }
557
558 bld->addRule( pRule );
559 }
560
561 for( ActionTmpList::iterator i = lActions.begin();
562 i != lActions.end(); i++ )
563 {
564 Action *pAct = new Action;
565 pAct->setName( (*i).first );
566
567 for( ActionTmpCmdList::iterator j = (*i).second.begin();
568 j != (*i).second.end(); j++ )
569 {
570 if( (*j).bGroup )
571 {
572 pAct->addCommand(
573 (Action::eAction)((*j).nAct), (*j).sGroup, true
574 );
575 }
576 else
577 {
578 StringList lWhat = buildToStringList(
579 (*j).lCmds, StringList(), bld
580 );
581
582 for( StringList::iterator k = lWhat.begin();
583 k != lWhat.end(); k++ )
584 {
585 pAct->addCommand( (Action::eAction)((*j).nAct), *k, false );
586 }
587 }
588 }
589
590 bld->addAction( pAct );
591 }
592
593 // Now create an auto check-action for each group where there isn't already
594 // an action.
595 for( TargetTmpList::iterator i = lTargetTmp.begin();
596 i != lTargetTmp.end(); i++ )
597 {
598 for( StringList::iterator j = (*i).second.lGroups.begin();
599 j != (*i).second.lGroups.end(); j++ )
600 {
601 if( !bld->hasAction( (*j) ) )
602 {
603 Action *pAct = new Action;
604 pAct->setName( *j );
605 pAct->addCommand( Action::actCheck, *j, true );
606 bld->addAction( pAct );
607 }
608 }
609 }
610
611 return bld;
612}
613
diff --git a/src/buildparser.h b/src/buildparser.h
deleted file mode 100644
index 516760c..0000000
--- a/src/buildparser.h
+++ /dev/null
@@ -1,192 +0,0 @@
1#ifndef BUILDER_H
2#define BUILDER_H
3
4#include <stdint.h>
5#include <string>
6#include <list>
7#include <utility>
8#include <map>
9#include "build.tab.h"
10#include "parser.h"
11
12class Build;
13class BuildParser;
14class Function;
15class FunctionFactory;
16class Perform;
17class PerformFactory;
18class Target;
19class TargetFactory;
20
21#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, BuildParser &bld )
22YY_DECL;
23
24typedef std::list<std::string> StringList;
25typedef std::list<Function *> FunctionList;
26typedef std::list<Perform *> PerformList;
27typedef std::map<std::string,std::string> VarMap;
28
29template<class tx, class ty, class tz>
30class Triplet
31{
32public:
33 Triplet( const tx &x, const ty &y, const tz &z ) :
34 first( x ), second( y ), third( z )
35 {}
36
37 Triplet( const Triplet &src ) :
38 first( src.first ), second( src.second ), third( src.third )
39 {}
40
41 tx first;
42 ty second;
43 tz third;
44};
45
46enum eSetHow
47{
48 setSet,
49 setAdd
50};
51
52class BuildParser : public Parser
53{
54 typedef std::pair<std::string, Function *> BuildListItem;
55 typedef std::list<BuildListItem> BuildListCore;
56 typedef std::pair<BuildListCore, Function *> BuildList;
57 typedef Triplet<std::string, std::string, int> SetVar;
58 typedef std::list<SetVar> SetVarList;
59public:
60 BuildParser();
61 virtual ~BuildParser();
62
63 Build *load( const std::string &sFile );
64
65private:
66 void scanBegin();
67 void scanEnd();
68
69 Build *genBuild();
70
71public: // Target functions
72 bool isTarget( const char *sType );
73 void newTarget();
74 void setTargetRule( const char *sRule );
75 void setTargetPrefix( const char *sPrefix );
76 void setTargetType( const char *sType );
77 void addTargetInput();
78 void addTargetRequires();
79 void addTargetSet( const char *sVar, const char *sVal, int nHow );
80 void addTargetGroup( const char *sGroup );
81
82private: // Target variables
83 TargetFactory &fTarget;
84 class TargetInfo
85 {
86 public:
87 std::string sRule;
88 std::string sPrefix;
89 std::string sType;
90 BuildList lInput;
91 BuildList lRequires;
92 StringList lGroups;
93 SetVarList lVar;
94 };
95 typedef std::pair<BuildList,TargetInfo> TargetTmp;
96 typedef std::list<TargetTmp> TargetTmpList;
97 TargetTmpList lTargetTmp;
98
99public: // Function functions
100 bool isFunction( const char *sFunc );
101 void newFunctionCall( const char *sName );
102 void addFunctionParam( const char *sParam );
103
104private: // Function variables
105 Function *pTmpFunc;
106 FunctionFactory &fFunction;
107
108public: // Perform functions
109 bool isPerform( const char *sPerf );
110 void newPerform( const char *sName );
111 void addPerformParam( const char *sParam );
112
113private: // Perform variables
114 Perform *pTmpPerform;
115 PerformFactory &fPerform;
116
117public: // List functions
118 void newList();
119 void addListString( const char *str );
120 void addListFunc();
121 void filterList();
122
123 void buildListFilter( BuildList &lSrc );
124 StringList buildToStringList( const BuildList &lSrc, const StringList &lIn, Build *pPass=NULL );
125 StringList buildToStringListDup( const BuildList &lSrc, const StringList &lIn, Build &bld, const std::string &sCont, VarMap *mExtra, Build *pPass=NULL );
126
127private: // List variables
128 BuildList lTmp;
129
130public: // Rules functions
131 void addRule( const char *sName );
132 void addRuleMatches();
133 void addRuleProduces();
134 void addRuleRequires();
135 void addRuleInputFilter();
136 void addRulePerform();
137 void setRuleAggregate();
138
139private: // Rule variables
140 class RuleInfo
141 {
142 public:
143 std::string sName;
144 Function *pMatches;
145 BuildList lProduces;
146 BuildList lRequires;
147 FunctionList lFilter;
148 PerformList lPerform;
149 Function *pAggregate;
150 };
151
152 typedef std::list<RuleInfo> RuleTmpList;
153 RuleTmpList lRuleTmp;
154
155public: // Action functions
156 void addAction();
157 void addAction( const char *sName );
158 void addCommand( int nType );
159 void addGrpCommand( const char *sGroup, int nType );
160
161private: // Action variables
162 typedef struct ActionTmpCmd
163 {
164 ActionTmpCmd( int nAct, BuildList &l ) :
165 nAct( nAct ), bGroup( false ), lCmds( l ) { };
166 ActionTmpCmd( int nAct, const char *s ) :
167 nAct( nAct ), bGroup( true ), sGroup( s ) { };
168 int nAct;
169 bool bGroup;
170 BuildList lCmds;
171 std::string sGroup;
172 } ActionTmpCmd;
173 //typedef std::pair<int, BuildList> ActionTmpCmd;
174 //typedef std::pair<int, std::string> ActionTmpGrpCmd
175 typedef std::list<ActionTmpCmd> ActionTmpCmdList;
176 //typedef std::list<ActionTmpGrpCmd> ActionTmpGrpCmdList;
177 typedef std::pair<std::string, ActionTmpCmdList> ActionTmp;
178 typedef std::list<ActionTmp> ActionTmpList;
179 ActionTmpList lActions;
180
181public: // Global variable functions
182 void addGlobalSet( const char *sVar, const char *sValue, int nHow );
183
184private: // Global variable variables
185 SetVarList lGlobalVars;
186
187public: // Debug
188 void debugDump();
189 void printBuildList( const BuildList &lst );
190};
191
192#endif
diff --git a/src/cache.cpp b/src/cache.cpp
deleted file mode 100644
index d2bf537..0000000
--- a/src/cache.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
1#include "cache.h"
2#include "bu/fstring.h"
3#include "bu/archive.h"
4
5Cache::Cache()
6{
7}
8
9Cache::~Cache()
10{
11 for( std::map<std::string, Entry *>::iterator i = mCache.begin();
12 i != mCache.end(); i++ )
13 {
14 delete (*i).second;
15 }
16}
17
18void Cache::archive( class Bu::ArchiveBase &ar )
19{
20 if( ar.isLoading() )
21 {
22 uint32_t sCache, sData, sIndex;
23
24 ar >> sIndex;
25 Bu::FString *Index = new Bu::FString[sIndex];
26 for( uint32_t i = 0; i < sIndex; i++ )
27 {
28 ar >> Index[i];
29 }
30
31 ar >> sCache;
32 uint32_t nTmp;
33 for( uint32_t i = 0; i < sCache; i++ )
34 {
35 Entry *e = new Entry;
36 ar >> e->tCreated;
37 ar >> sData;
38 std::list<std::string> &lData = e->lData;
39 for( uint32_t j = 0; j < sData; j++ )
40 {
41 ar >> nTmp;
42 lData.push_back( Index[nTmp].getStr() );
43 }
44 ar >> nTmp;
45 mCache[Index[nTmp].getStr()] = e;
46 }
47 /*
48 uint32_t sCache, sData;
49 ar >> sCache;
50 std::string sTmp;
51
52 for( uint32_t i = 0; i < sCache; i++ )
53 {
54 Entry *e = new Entry;
55 ar >> e->tCreated;
56 ar >> sData;
57 std::list<std::string> &lData = e->lData;
58 for( uint32_t j = 0; j < sData; j++ )
59 {
60 ar >> sTmp;
61 lData.push_back( sTmp );
62 }
63 ar >> sTmp;
64 mCache[sTmp] = e;
65 }
66 */
67 }
68 else
69 {
70 std::map<std::string, uint32_t> mIndex;
71 for( std::map<std::string, Entry *>::iterator i = mCache.begin();
72 i != mCache.end(); i++ )
73 {
74 mIndex[(*i).first] = 0;
75 std::list<std::string> &lData = (*i).second->lData;
76 for( std::list<std::string>::iterator j = lData.begin();
77 j != lData.end(); j++ )
78 {
79 mIndex[(*j)] = 0;
80 }
81 }
82
83 ar << (uint32_t)mIndex.size();
84 uint32_t cnt = 0;
85 for( std::map<std::string, uint32_t>::iterator i = mIndex.begin();
86 i != mIndex.end(); i++ )
87 {
88 (*i).second = cnt;
89 cnt++;
90 Bu::FString s( ((*i).first).c_str(), ((*i).first).size() );
91 ar << s;
92 }
93
94 ar << (uint32_t)mCache.size();
95 for( std::map<std::string, Entry *>::iterator i = mCache.begin();
96 i != mCache.end(); i++ )
97 {
98 ar << (*i).second->tCreated;
99 std::list<std::string> &lData = (*i).second->lData;
100 ar << (uint32_t)lData.size();
101 for( std::list<std::string>::iterator j = lData.begin();
102 j != lData.end(); j++ )
103 {
104 ar << mIndex[(*j)];
105 }
106
107 ar << mIndex[(*i).first];
108 }
109
110
111 /*
112 ar << mCache.size();
113 for( std::map<std::string, Entry *>::iterator i = mCache.begin();
114 i != mCache.end(); i++ )
115 {
116 ar << (*i).second->tCreated;
117 std::list<std::string> &lData = (*i).second->lData;
118 ar << lData.size();
119 for( std::list<std::string>::iterator j = lData.begin();
120 j != lData.end(); j++ )
121 {
122 ar << (*j);
123 }
124
125 std::string str = (*i).first;
126 ar << str;
127 }
128 */
129 }
130}
131
132Cache::Entry *Cache::get( const std::string &id )
133{
134 std::map<std::string, Entry *>::iterator i = mCache.find( id );
135 if( i != mCache.end() )
136 return (*i).second;
137
138 return NULL;
139}
140
141void Cache::put( const std::string &id, Entry *data )
142{
143 std::map<std::string, Entry *>::iterator i = mCache.find( id );
144 if( i != mCache.end() )
145 delete (*i).second;
146
147 mCache[id] = data;
148}
149
diff --git a/src/cache.h b/src/cache.h
deleted file mode 100644
index 50264de..0000000
--- a/src/cache.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef CACHE_H
2#define CACHE_H
3
4#include <stdint.h>
5#include <time.h>
6#include "bu/archival.h"
7#include <list>
8#include <map>
9#include <string>
10
11class Cache : public Bu::Archival
12{
13public:
14 Cache();
15 virtual ~Cache();
16
17 virtual void archive( class Bu::ArchiveBase &ar );
18
19 class Entry
20 {
21 public:
22 uint32_t tCreated;
23 std::list<std::string> lData;
24 };
25
26 Entry *get( const std::string &id );
27 void put( const std::string &id, Entry *data );
28
29private:
30 std::map<std::string, Entry *> mCache;
31};
32
33#endif
diff --git a/src/function.cpp b/src/function.cpp
deleted file mode 100644
index 6e4f1d7..0000000
--- a/src/function.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
1#include "function.h"
2
3Function::Function()
4{
5}
6
7Function::~Function()
8{
9}
10
11void Function::addParam( const char *str )
12{
13 lParams.push_back( str );
14}
15
16void Function::copyData( Function *pSrc, Build &bld, const StringList *cont, VarMap *mExtra )
17{
18 lParams.clear();
19 for( std::list<std::string>::iterator i = pSrc->lParams.begin();
20 i != pSrc->lParams.end(); i++ )
21 {
22 lParams.push_back( bld.replVars( *i, cont, mExtra ) );
23 }
24}
25
diff --git a/src/function.h b/src/function.h
deleted file mode 100644
index af0d3fc..0000000
--- a/src/function.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#ifndef FUNCTION_H
2#define FUNCTION_H
3
4#include <stdint.h>
5#include "build.h"
6
7class Function
8{
9public:
10 Function();
11 virtual ~Function();
12
13 void addParam( const char *str );
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput )=0;
15 virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) = 0;
16 void copyData( Function *pSrc, Build &bld, const StringList *cont, VarMap *mExtra );
17
18protected:
19 StringList lParams;
20
21};
22
23#endif
diff --git a/src/functioncommandtolist.cpp b/src/functioncommandtolist.cpp
deleted file mode 100644
index 68c4564..0000000
--- a/src/functioncommandtolist.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
1#include "functioncommandtolist.h"
2#include "bu/plugger.h"
3
4PluginInterface2(commandToList, FunctionCommandToList, Function, "Mike Buland", 0, 1 );
5
6FunctionCommandToList::FunctionCommandToList()
7{
8}
9
10FunctionCommandToList::~FunctionCommandToList()
11{
12}
13
14void FunctionCommandToList::execute( Build *bld, const StringList &lInput, StringList &lOutput )
15{
16 //rView.beginExtraRequiresCheck( s.c_str() );
17 //rView.executeCmd( s.c_str() );
18 FILE *fcmd = popen( lParams.front().c_str(), "r" );
19 std::string rhs;
20 bool bHeader = true;
21 for(;;)
22 {
23 if( feof( fcmd ) )
24 break;
25 int cc = fgetc( fcmd );
26 if( cc == EOF )
27 break;
28 unsigned char c = cc;
29 if( bHeader )
30 {
31 if( c == ':' )
32 bHeader = false;
33 }
34 else
35 {
36 if( c == ' ' || c == '\t' )
37 {
38 if( rhs != "" )
39 {
40 lOutput.push_back( rhs );
41 rhs = "";
42 }
43 }
44 else
45 {
46 if( c == '\\' )
47 c = fgetc( fcmd );
48 if( c != '\n' )
49 rhs += c;
50 }
51 }
52 }
53 if( rhs != "" )
54 {
55 lOutput.push_back( rhs );
56 rhs = "";
57 }
58 pclose( fcmd );
59 //rView.endExtraRequiresCheck();
60}
61
62Function *FunctionCommandToList::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
63{
64 Function *pRet = new FunctionCommandToList();
65 pRet->copyData( this, bld, cont, mExtra );
66 return pRet;
67}
68
diff --git a/src/functioncommandtolist.h b/src/functioncommandtolist.h
deleted file mode 100644
index 05bc393..0000000
--- a/src/functioncommandtolist.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef FUNCTION_COMMAND_TO_LIST_H
2#define FUNCTION__H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionCommandToList : public Function
9{
10public:
11 FunctionCommandToList();
12 virtual ~FunctionCommandToList();
13
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput );
15 virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra );
16
17private:
18
19};
20
21#endif
diff --git a/src/functiondirectoriesin.cpp b/src/functiondirectoriesin.cpp
deleted file mode 100644
index 0ebbbc8..0000000
--- a/src/functiondirectoriesin.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
1#include <dirent.h>
2
3#include "functiondirectoriesin.h"
4#include "bu/plugger.h"
5
6PluginInterface2(directoriesIn, FunctionDirectoriesIn, Function, "Mike Buland", 0, 1 );
7
8FunctionDirectoriesIn::FunctionDirectoriesIn()
9{
10}
11
12FunctionDirectoriesIn::~FunctionDirectoriesIn()
13{
14}
15
16void FunctionDirectoriesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput )
17{
18 DIR *d = opendir( lParams.front().c_str() );
19 if( d == NULL )
20 throw BuildException(
21 "Can't open directory %s.",
22 lParams.front().c_str()
23 );
24
25 struct dirent *e;
26
27 std::string prefix;
28 if( lParams.size() >= 2 )
29 {
30 StringList::iterator i = lParams.begin();
31 i++;
32 prefix = *i;
33 }
34 else
35 {
36 prefix = lParams.front() + "/";
37 }
38
39 while( (e = readdir( d )) )
40 {
41 if( e->d_type == DT_DIR )
42 {
43 if( e->d_name[0] == '.' || e->d_name[0] == '\0' )
44 continue;
45 std::string sOut = prefix + e->d_name;
46 lOutput.push_back( sOut );
47 if( bld )
48 {
49 std::string sV = lParams.front() + "/";
50 sV += e->d_name;
51 bld->set( sOut, "fulldir", sV );
52 }
53 else
54 {
55 printf("no build access.\n");
56 }
57 }
58 }
59
60 closedir( d );
61}
62
63Function *FunctionDirectoriesIn::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
64{
65 Function *pRet = new FunctionDirectoriesIn();
66 pRet->copyData( this, bld, cont, mExtra );
67 return pRet;
68}
69
diff --git a/src/functiondirectoriesin.h b/src/functiondirectoriesin.h
deleted file mode 100644
index 7ec86e3..0000000
--- a/src/functiondirectoriesin.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef FUNCTION_DIRECTORIES_IN_H
2#define FUNCTION_DIRECTORIES_IN_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionDirectoriesIn : public Function
9{
10public:
11 FunctionDirectoriesIn();
12 virtual ~FunctionDirectoriesIn();
13
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput );
15 virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra );
16
17private:
18
19};
20
21#endif
diff --git a/src/functionfactory.cpp b/src/functionfactory.cpp
deleted file mode 100644
index f72e8f6..0000000
--- a/src/functionfactory.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
1#include "functionfactory.h"
2
3extern struct Bu::PluginInfo directoriesIn;
4extern struct Bu::PluginInfo filesIn;
5extern struct Bu::PluginInfo regexp;
6extern struct Bu::PluginInfo toString;
7extern struct Bu::PluginInfo commandToList;
8extern struct Bu::PluginInfo targets;
9
10FunctionFactory::FunctionFactory()
11{
12 registerBuiltinPlugin( &directoriesIn );
13 registerBuiltinPlugin( &filesIn );
14 registerBuiltinPlugin( &regexp );
15 registerBuiltinPlugin( &toString );
16 registerBuiltinPlugin( &commandToList );
17 registerBuiltinPlugin( &targets );
18}
19
20FunctionFactory::~FunctionFactory()
21{
22}
diff --git a/src/functionfactory.h b/src/functionfactory.h
deleted file mode 100644
index 2cc28fe..0000000
--- a/src/functionfactory.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef FUNCTION_FACTORY_H
2#define FUNCTION_FACTORY_H
3
4#include <stdint.h>
5
6#include "bu/plugger.h"
7#include "bu/singleton.h"
8#include "function.h"
9
10class FunctionFactory : public Bu::Plugger<Function>, public Bu::Singleton<FunctionFactory>
11{
12public:
13 FunctionFactory();
14 virtual ~FunctionFactory();
15
16private:
17
18};
19
20#endif
diff --git a/src/functionfilesin.cpp b/src/functionfilesin.cpp
deleted file mode 100644
index 5301cd2..0000000
--- a/src/functionfilesin.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
1#include <dirent.h>
2
3#include "functionfilesin.h"
4#include "bu/plugger.h"
5#include "build.h"
6
7PluginInterface2(filesIn, FunctionFilesIn, Function, "Mike Buland", 0, 1 );
8
9FunctionFilesIn::FunctionFilesIn()
10{
11}
12
13FunctionFilesIn::~FunctionFilesIn()
14{
15}
16
17void FunctionFilesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput )
18{
19 DIR *d = opendir( lParams.front().c_str() );
20 if( d == NULL )
21 throw BuildException(
22 "Can't open directory %s.",
23 lParams.front().c_str()
24 );
25
26 struct dirent *e;
27
28 std::string prefix;
29 if( lParams.size() >= 2 )
30 {
31 StringList::iterator i = lParams.begin();
32 i++;
33 prefix = *i;
34 }
35 else
36 {
37 prefix = lParams.front() + "/";
38 }
39
40 while( (e = readdir( d )) )
41 {
42 if( e->d_type != DT_DIR )
43 {
44 if( e->d_name[0] != '.')
45 lOutput.push_back( prefix + e->d_name );
46 }
47 }
48
49 closedir( d );
50}
51
52Function *FunctionFilesIn::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
53{
54 Function *pRet = new FunctionFilesIn();
55 pRet->copyData( this, bld, cont, mExtra );
56 return pRet;
57}
58
diff --git a/src/functionfilesin.h b/src/functionfilesin.h
deleted file mode 100644
index 904837f..0000000
--- a/src/functionfilesin.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef FUNCTION_FILES_IN_H
2#define FUNCTION_FILES_IN_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionFilesIn : public Function
9{
10public:
11 FunctionFilesIn();
12 virtual ~FunctionFilesIn();
13
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput );
15 virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra );
16
17private:
18
19};
20
21#endif
diff --git a/src/functionregexp.cpp b/src/functionregexp.cpp
deleted file mode 100644
index 2dc18b2..0000000
--- a/src/functionregexp.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
1#include "functionregexp.h"
2#include "bu/plugger.h"
3#include "regexp.h"
4
5PluginInterface2(regexp, FunctionRegexp, Function, "Mike Buland", 0, 1 );
6
7FunctionRegexp::FunctionRegexp()
8{
9}
10
11FunctionRegexp::~FunctionRegexp()
12{
13}
14
15void FunctionRegexp::execute( Build *bld, const StringList &lInput, StringList &lOutput )
16{
17 if( lParams.size() == 1 )
18 {
19 RegExp re( lParams.front().c_str() );
20
21 for( StringList::const_iterator i = lInput.begin();
22 i != lInput.end(); i++ )
23 {
24 if( re.execute( (*i).c_str() ) )
25 {
26 lOutput.push_back( *i );
27 if( bld )
28 {
29 int jmax = re.getNumSubStrings();
30 for( int j = 0; j < jmax; j++ )
31 {
32 char buf[30];
33 sprintf( buf, "re:%d", j );
34 bld->set( *i, buf, re.getSubString( j ) );
35 }
36 }
37 }
38 }
39 }
40 else
41 {
42 if( !bld )
43 {
44 throw BuildException("You apparently can't use regexp with two params here. Isn't that odd?");
45 }
46
47 RegExp re( lParams.front().c_str() );
48 lParams.pop_front();
49 std::string p2 = lParams.front();
50
51 for( StringList::const_iterator i = lInput.begin();
52 i != lInput.end(); i++ )
53 {
54 if( re.execute( (*i).c_str() ) )
55 {
56 VarMap ext;
57 int jmax = re.getNumSubStrings();
58 for( int j = 0; j < jmax; j++ )
59 {
60 char buf[30];
61 sprintf( buf, "re:%d", j );
62 ext[buf] = re.getSubString( j );
63 }
64
65 std::string sNew = bld->replVars( p2, NULL, &ext );
66 lOutput.push_back( sNew );
67
68 for( int j = 0; j < jmax; j++ )
69 {
70 char buf[30];
71 sprintf( buf, "re:%d", j );
72 bld->set( sNew, buf, re.getSubString( j ) );
73 }
74 bld->copyContext( *i, sNew );
75 }
76 }
77 }
78}
79
80Function *FunctionRegexp::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
81{
82 Function *pRet = new FunctionRegexp();
83 pRet->copyData( this, bld, cont, mExtra );
84 return pRet;
85}
86
diff --git a/src/functionregexp.h b/src/functionregexp.h
deleted file mode 100644
index 42fe811..0000000
--- a/src/functionregexp.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef FUNCTION_REGEXP_H
2#define FUNCTION_REGEXP_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionRegexp : public Function
9{
10public:
11 FunctionRegexp();
12 virtual ~FunctionRegexp();
13
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput );
15 virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra );
16
17private:
18
19};
20
21#endif
diff --git a/src/functiontargets.cpp b/src/functiontargets.cpp
deleted file mode 100644
index a94f43e..0000000
--- a/src/functiontargets.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
1#include "functiontargets.h"
2#include "bu/plugger.h"
3#include "build.h"
4
5PluginInterface2(targets, FunctionTargets, Function, "Mike Buland", 0, 1 );
6
7FunctionTargets::FunctionTargets()
8{
9}
10
11FunctionTargets::~FunctionTargets()
12{
13}
14
15void FunctionTargets::execute( Build *bld, const StringList &lInput, StringList &lOutput )
16{
17 if( bld == NULL )
18 {
19 throw BuildException("You cannot call targets() from anywhere, see the manual.");
20 }
21
22 for( TargetMap::iterator i = bld->getTargetMap().begin();
23 i != bld->getTargetMap().end(); i++ )
24 {
25 lOutput.push_back( (*i).first );
26 }
27}
28
29Function *FunctionTargets::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
30{
31 Function *pRet = new FunctionTargets();
32 pRet->copyData( this, bld, cont, mExtra );
33 return pRet;
34}
35
diff --git a/src/functiontargets.h b/src/functiontargets.h
deleted file mode 100644
index f42ce96..0000000
--- a/src/functiontargets.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef FUNCTION_TARGETS_H
2#define FUNCTION_TARGETS_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionTargets : public Function
9{
10public:
11 FunctionTargets();
12 virtual ~FunctionTargets();
13
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput );
15 virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra );
16
17private:
18
19};
20
21#endif
diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp
deleted file mode 100644
index 2fdcc1c..0000000
--- a/src/functiontostring.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
1#include "functiontostring.h"
2#include "bu/plugger.h"
3
4PluginInterface2(toString, FunctionToString, Function, "Mike Buland", 0, 1 );
5
6FunctionToString::FunctionToString()
7{
8}
9
10FunctionToString::~FunctionToString()
11{
12}
13
14void FunctionToString::execute( Build *bld, const StringList &lInput, StringList &lOutput )
15{
16 std::string sOut;
17
18 for( StringList::const_iterator i = lInput.begin(); i != lInput.end(); i++ )
19 {
20 if( i != lInput.begin() ) sOut += " ";
21 sOut += *i;
22 }
23
24 lOutput.push_back( sOut );
25}
26
27Function *FunctionToString::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
28{
29 Function *pRet = new FunctionToString();
30 pRet->copyData( this, bld, cont, mExtra );
31 return pRet;
32}
33
diff --git a/src/functiontostring.h b/src/functiontostring.h
deleted file mode 100644
index d9c5af7..0000000
--- a/src/functiontostring.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef FUNCTION_TO_STRING_H
2#define FUNCTION_TO_STRING_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionToString : public Function
9{
10public:
11 FunctionToString();
12 virtual ~FunctionToString();
13
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput );
15 virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra );
16
17private:
18
19};
20
21#endif
diff --git a/src/main.cpp b/src/main.cpp
deleted file mode 100644
index 1d3dc10..0000000
--- a/src/main.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
1#include "buildparser.h"
2//#include "viewerplain.h"
3//#include "viewerpercent.h"
4//#include "viewermake.h"
5#include "bu/paramproc.h"
6#include "bu/fstring.h"
7#include "build.h"
8#include "action.h"
9
10#include <stdlib.h>
11
12class Param : public Bu::ParamProc
13{
14public:
15 Param() :
16 sFile("build.conf"),
17 sCache(".build.cache"),
18 bDebug( false ),
19 bPostDebug( false ),
20 sView("colorpct"),
21 bInfo( false ),
22 bCleanMode( false ),
23 sDir("")
24 {
25 addHelpBanner("Build r?\n\n");
26 addParam("file", 'f', &sFile,
27 "Set the input script, default: build.conf");
28 addParam("info", 'i', &bInfo,
29 "Display useful info about the loaded config file.", NULL, "true" );
30 addParam("chdir", 'C', &sDir,
31 "Change to the specified dir before doing anything else." );
32 addParam("clean", 'c', &bCleanMode,
33 "Clean instead of checking the given action.", NULL, "true" );
34 addParam('p', mkproc(Param::procViewPercent),
35 "Switch to percent view.");
36 addParam('P', mkproc(Param::procViewPlain),
37 "Switch to plain view.");
38 addParam("color", mkproc(Param::procColorPercent),
39 "Switch to colored percent view.");
40 addParam('m', mkproc(Param::procViewMake),
41 "Switch to 'make' style view.");
42 addParam("cache", &sCache,
43 "Set an alternative cache file, default: .build.cache" );
44 addParam('d', &bDebug,
45 "Display debug info instead of building", NULL, "true" );
46 addParam('D', &bPostDebug,
47 "Display debug info after building", NULL, "true" );
48 addParam("help", mkproc(ParamProc::help),
49 "This help");
50 //pViewer = new ViewerPlain;
51 }
52
53 virtual ~Param()
54 {
55 //delete pViewer;
56 }
57
58 virtual int cmdParam( int argc, char *argv[] )
59 {
60 if( sAction.isSet() )
61 {
62 printf("You can only specify one action per command line.\n\n");
63 exit( 1 );
64 }
65 sAction = argv[0];
66 return 1;
67 }
68
69 int procViewPercent( int argc, char *argv[] )
70 {
71 sView = "percent";
72 }
73
74 int procViewPlain( int argc, char *argv[] )
75 {
76 sView = "plain";
77 }
78
79 int procViewMake( int argc, char *argv[] )
80 {
81 sView = "make";
82 }
83
84 int procColorPercent( int argc, char *argv[] )
85 {
86 sView = "colorpct";
87 }
88
89 Bu::FString sCache;
90 Bu::FString sFile;
91 Bu::FString sView;
92 Bu::FString sDir;
93 Bu::FString sAction;
94 //Viewer *pViewer;
95 bool bDebug;
96 bool bPostDebug;
97 bool bInfo;
98 bool bCleanMode;
99
100private:
101};
102
103int main( int argc, char *argv[] )
104{
105 Param prm;
106 prm.process( argc, argv );
107
108 BuildParser bld;
109 Build *pBuild = NULL;
110
111 char *olddir = NULL;
112
113 try
114 {
115 if( prm.sDir != "" )
116 {
117 olddir = new char[4096];
118 getcwd( olddir, 4096 );
119 chdir( prm.sDir.getStr() );
120 }
121
122 pBuild = bld.load( prm.sFile.getStr() );
123 pBuild->setCache( prm.sCache.getStr() );
124 pBuild->setView( prm.sView.getStr() );
125 if( prm.bCleanMode )
126 pBuild->setMode( Action::actClean );
127
128 if( prm.bInfo )
129 {
130 pBuild->printInfo();
131 delete pBuild;
132 if( olddir ) { chdir( olddir ); delete[] olddir; }
133 return 0;
134 }
135 if( prm.bDebug )
136 {
137 printf("\n\n----------\nDebug dump\n----------\n");
138 pBuild->debugDump();
139 }
140 else
141 {
142 if( prm.sAction.isSet() )
143 pBuild->execAction( prm.sAction.getStr() );
144 else
145 pBuild->execAction("");
146 }
147 if( prm.bPostDebug )
148 {
149 printf("\n\n----------\nDebug dump\n----------\n");
150 pBuild->debugDump();
151 }
152 }
153 catch( BuildException &e )
154 {
155 fputs( e.what(), stderr );
156 fputs( "\n", stderr );
157 if( prm.bPostDebug )
158 {
159 printf("\n\n----------\nDebug dump\n----------\n");
160 pBuild->debugDump();
161 }
162 delete pBuild;
163 if( olddir ) { chdir( olddir ); delete[] olddir; }
164 return 1;
165 }
166
167 delete pBuild;
168 if( olddir ) { chdir( olddir ); delete[] olddir; }
169
170 return 0;
171}
172
diff --git a/src/parser.cpp b/src/parser.cpp
deleted file mode 100644
index d9fd2d0..0000000
--- a/src/parser.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
1#include "parser.h"
2#include "build.h"
3
4Parser::Parser()
5{
6}
7
8Parser::~Parser()
9{
10}
11
12void Parser::error( YYLTYPE *locp, const char *msg )
13{
14 fflush( stdout );
15 throw BuildException("%s: %d.%d-%d.%d: %s",
16 file.c_str(),
17 locp->first_line, locp->first_column,
18 locp->last_line, locp->last_column,
19 msg );
20}
21
22void Parser::error( const std::string &msg )
23{
24 fflush( stdout );
25 throw BuildException("%s", msg.c_str() );
26}
27
diff --git a/src/parser.h b/src/parser.h
deleted file mode 100644
index 675e28b..0000000
--- a/src/parser.h
+++ /dev/null
@@ -1,40 +0,0 @@
1#ifndef PARSER_H
2#define PARSER_H
3
4#include <stdint.h>
5#include <string>
6
7class Build;
8
9#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
10typedef struct YYLTYPE
11{
12 int first_line;
13 int first_column;
14 int last_line;
15 int last_column;
16} YYLTYPE;
17# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
18# define YYLTYPE_IS_DECLARED 1
19# define YYLTYPE_IS_TRIVIAL 1
20#endif
21
22class Parser
23{
24public:
25 Parser();
26 virtual ~Parser();
27
28 virtual void error( YYLTYPE *locp, const char *msg );
29 virtual void error( const std::string &msg );
30
31 virtual Build *load( const std::string &sFile ) = 0;
32
33protected:
34 std::string file;
35
36private:
37
38};
39
40#endif
diff --git a/src/perform.cpp b/src/perform.cpp
deleted file mode 100644
index 25d54c7..0000000
--- a/src/perform.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
1#include "perform.h"
2#include "build.h"
3
4Perform::Perform()
5{
6}
7
8Perform::~Perform()
9{
10}
11
12void Perform::addParam( const char *sParam )
13{
14 lParam.push_back( sParam );
15}
16
17void Perform::copyData( Perform *pSrc, Build &bld, const StringList *cont, VarMap *mExtra )
18{
19 lParam.clear();
20 for( std::list<std::string>::iterator i = pSrc->lParam.begin();
21 i != pSrc->lParam.end(); i++ )
22 {
23 lParam.push_back( bld.replVars( *i, cont, mExtra ) );
24 }
25}
26
diff --git a/src/perform.h b/src/perform.h
deleted file mode 100644
index 031e007..0000000
--- a/src/perform.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef PERFORM_H
2#define PERFORM_H
3
4#include <stdint.h>
5#include <list>
6#include <string>
7#include <map>
8
9typedef std::map<std::string,std::string> VarMap;
10typedef std::list<std::string> StringList;
11
12class Build;
13
14class Perform
15{
16public:
17 Perform();
18 virtual ~Perform();
19
20 void addParam( const char *sParam );
21 virtual Perform *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) = 0;
22 virtual void execute( Build &bld ) = 0;
23 void copyData( Perform *pSrc, Build &bld, const StringList *cont, VarMap *mExtra );
24 std::string getTarget()
25 {
26 return sTarget;
27 }
28 void setTarget( std::string sTarget )
29 {
30 this->sTarget = sTarget;
31 }
32
33 std::list<class Function *> &getReqFuncs()
34 {
35 return lReqFuncs;
36 }
37
38 void setRule( const std::string &sRule )
39 {
40 this->sRule = sRule;
41 }
42
43 std::string &getRule()
44 {
45 return sRule;
46 }
47
48protected:
49 std::list<std::string> lParam;
50 std::string sTarget;
51 std::string sRule;
52 std::list<class Function *> lReqFuncs;
53};
54
55#endif
diff --git a/src/performcommand.cpp b/src/performcommand.cpp
deleted file mode 100644
index 65827c5..0000000
--- a/src/performcommand.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
1#include "performcommand.h"
2#include "bu/plugger.h"
3#include "build.h"
4#include "viewer.h"
5
6#include <stdlib.h>
7
8PluginInterface2(command, PerformCommand, Perform, "Mike Buland", 0, 1 );
9
10PerformCommand::PerformCommand()
11{
12}
13
14PerformCommand::~PerformCommand()
15{
16}
17
18Perform *PerformCommand::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
19{
20 Perform *pRet = new PerformCommand();
21 pRet->copyData( this, bld, cont, mExtra );
22 return pRet;
23}
24
25void PerformCommand::execute( Build &bld )
26{
27 bld.getView()->executeCmd( lParam.front() );
28 int n = system( lParam.front().c_str() );
29 if( n != 0 )
30 throw BuildException(
31 "Command exited with error code %d.",
32 WEXITSTATUS(n)
33 );
34}
35
diff --git a/src/performcommand.h b/src/performcommand.h
deleted file mode 100644
index 62bf61e..0000000
--- a/src/performcommand.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef PERFORM_COMMAND_H
2#define PERFORM_COMMAND_H
3
4#include <stdint.h>
5
6#include "perform.h"
7
8class PerformCommand : public Perform
9{
10public:
11 PerformCommand();
12 virtual ~PerformCommand();
13
14 virtual Perform *duplicate( Build &bld, const StringList *cont, VarMap *mExtra );
15 virtual void execute( Build &bld );
16
17private:
18
19};
20
21#endif
diff --git a/src/performfactory.cpp b/src/performfactory.cpp
deleted file mode 100644
index 6926a3b..0000000
--- a/src/performfactory.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
1#include "performfactory.h"
2
3extern struct Bu::PluginInfo command;
4
5PerformFactory::PerformFactory()
6{
7 registerBuiltinPlugin( &command );
8}
9
10PerformFactory::~PerformFactory()
11{
12}
diff --git a/src/performfactory.h b/src/performfactory.h
deleted file mode 100644
index 435d9c6..0000000
--- a/src/performfactory.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef PERFORM_FACTORY_H
2#define PERFORM_FACTORY_H
3
4#include <stdint.h>
5
6#include "perform.h"
7#include "bu/plugger.h"
8#include "bu/singleton.h"
9
10class PerformFactory : public Bu::Plugger<Perform>, public Bu::Singleton<PerformFactory>
11{
12public:
13 PerformFactory();
14 virtual ~PerformFactory();
15
16private:
17
18};
19
20#endif
diff --git a/src/regexp.cpp b/src/regexp.cpp
deleted file mode 100644
index 4370667..0000000
--- a/src/regexp.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
1#include "regexp.h"
2#include "build.h" // For BuildException
3#include "bu/fstring.h"
4
5RegExp::RegExp() :
6 bCompiled( false ),
7 aSubStr( NULL )
8{
9}
10
11RegExp::RegExp( const char *sSrc ) :
12 bCompiled( false ),
13 aSubStr( NULL )
14{
15 compile( sSrc );
16}
17
18RegExp::~RegExp()
19{
20 if( bCompiled )
21 {
22 regfree( &re );
23 delete[] aSubStr;
24 }
25}
26
27void RegExp::compile( const char *sSrc )
28{
29 if( bCompiled )
30 {
31 regfree( &re );
32 delete[] aSubStr;
33 bCompiled = false;
34 }
35
36 int nErr = regcomp( &re, sSrc, REG_EXTENDED|REG_NEWLINE );
37 if( nErr )
38 {
39 size_t length = regerror( nErr, &re, NULL, 0 );
40 char *buffer = new char[length];
41 (void) regerror( nErr, &re, buffer, length );
42 Bu::FString s( buffer );
43 delete[] buffer;
44 throw BuildException( s.getStr() );
45 }
46 bCompiled = true;
47 this->sSrc = sSrc;
48
49 nSubStr = re.re_nsub+1;
50 aSubStr = new regmatch_t[nSubStr];
51}
52
53int RegExp::getNumSubStrings()
54{
55 return nSubStr;
56}
57
58bool RegExp::execute( const char *sSrc )
59{
60 sTest = sSrc;
61 if( regexec( &re, sSrc, nSubStr, aSubStr, 0 ) )
62 return false;
63 return true;
64}
65
66std::pair<int,int> RegExp::getSubStringRange( int nIndex )
67{
68 return std::pair<int,int>( aSubStr[nIndex].rm_so, aSubStr[nIndex].rm_eo );
69}
70
71std::string RegExp::getSubString( int nIndex )
72{
73 return std::string(
74 sTest.getStr()+aSubStr[nIndex].rm_so,
75 aSubStr[nIndex].rm_eo - aSubStr[nIndex].rm_so
76 );
77}
78
diff --git a/src/regexp.h b/src/regexp.h
deleted file mode 100644
index a5fab14..0000000
--- a/src/regexp.h
+++ /dev/null
@@ -1,36 +0,0 @@
1#ifndef REG_EXP_H
2#define REG_EXP_H
3
4#include <string>
5#include <stdint.h>
6#include <regex.h>
7#include <utility>
8#include "bu/fstring.h"
9
10class RegExp
11{
12public:
13 RegExp();
14 RegExp( const char *sSrc );
15 virtual ~RegExp();
16
17 void compile( const char *sSrc );
18 int getNumSubStrings();
19 bool execute( const char *sSrc );
20 std::pair<int,int> getSubStringRange( int nIndex );
21 std::string getSubString( int nIndex );
22 const char *getSource()
23 {
24 return sSrc.getStr();
25 }
26
27private:
28 Bu::FString sSrc;
29 Bu::FString sTest;
30 regex_t re;
31 bool bCompiled;
32 int nSubStr;
33 regmatch_t *aSubStr;
34};
35
36#endif
diff --git a/src/rule.cpp b/src/rule.cpp
deleted file mode 100644
index 7924ba4..0000000
--- a/src/rule.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
1#include "rule.h"
2#include "build.h"
3#include "function.h"
4#include "perform.h"
5
6#include <set>
7
8Rule::Rule() :
9 pAggregate( NULL )
10{
11}
12
13Rule::~Rule()
14{
15}
16
17StringList Rule::execute( Build &bld, StringList &lInput, PerformList &lPerf, bool bFirstOnly )
18{
19 StringList lOutput;
20
21 RuleList rl = bld.findChainRules( this );
22
23 for( RuleList::iterator i = rl.begin(); i != rl.end(); i++ )
24 {
25 (*i)->setTarget( sTarget );
26 StringList tmp = (*i)->execute( bld, lInput, lPerf, bFirstOnly );
27 lOutput.insert( lOutput.end(), tmp.begin(), tmp.end() );
28 }
29
30 StringList lMine;
31 for( FunctionList::iterator i = lMatches.begin(); i != lMatches.end(); i++ )
32 {
33 (*i)->execute( &bld, lInput, lMine );
34 }
35
36 StringList lTmp;
37 for( FunctionList::iterator i = lFilter.begin(); i != lFilter.end(); i++ )
38 {
39 (*i)->execute( &bld, lMine, lTmp );
40 lMine.swap( lTmp );
41 lTmp.clear();
42 }
43
44 bool bHasProduces = true;
45 if( lProduces.empty() )
46 {
47 bHasProduces = false;
48 lProduces.push_back( sTarget );
49 }
50
51 {
52 std::set<std::string> sUsed;
53 for( StringList::iterator i = lInput.begin(); i != lInput.end(); i++ )
54 {
55isuck: if( i == lInput.end() ) break;
56 if( sUsed.find( *i ) != sUsed.end() )
57 {
58 StringList::iterator j = i;
59 j++;
60 lInput.erase( i );
61 i = j;
62 goto isuck;
63 }
64 sUsed.insert( *i );
65 }
66 }
67
68 StringList lNewOut;
69 if( pAggregate )
70 {
71 VarMap mTmp;
72 std::string target = lProduces.front();//, lProduces.front(), NULL ).c_str();
73 mTmp["target"] = target;
74 lNewOut.push_back( target );
75
76 for( StringList::iterator i = lMine.begin(); i != lMine.end(); i++ )
77 {
78 bld.addRequires( target, (*i) );
79 }
80 for( StringList::iterator i = lReqStrs.begin();
81 i != lReqStrs.end(); i++ )
82 {
83 bld.addRequires( target, (*i) );
84 }
85
86 StringList lTmp;
87 pAggregate->execute( &bld, lMine, lTmp );
88 mTmp["match"] = lTmp.front();
89
90 for( PerformList::iterator k = lPerform.begin();
91 k != lPerform.end(); k++ )
92 {
93 StringList cont;
94 cont.push_front( target );
95 Perform *p = (*k)->duplicate( bld, &cont, &mTmp );
96 p->setTarget( target );
97 p->setRule( sName );
98 //p->setReqFuncs( &lReqFuncs );
99 lPerf.push_back( p );
100 }
101 }
102 else
103 {
104 for( StringList::iterator i = lMine.begin(); i != lMine.end(); i++ )
105 {
106 for( StringList::iterator j = lProduces.begin();
107 j != lProduces.end(); j++ )
108 //StringList::iterator j = lProduces.begin();
109 {
110 VarMap mTmp;
111 StringList cont;
112 cont.push_front( sTarget );
113 cont.push_front( (*i) );
114 std::string target = bld.replVars( (*j), &cont, NULL );
115 mTmp["target"] = target;
116 lNewOut.push_back( target );
117 mTmp["match"] = (*i);
118 bld.addRequires( target, (*i) );
119 for( StringList::iterator k = lReqStrs.begin();
120 k != lReqStrs.end(); k++ )
121 {
122 bld.addRequires( target, (*k) );
123 }
124 for( PerformList::iterator k = lPerform.begin();
125 k != lPerform.end(); k++ )
126 {
127 StringList cont2;
128 cont2.push_front( sTarget );
129 cont2.push_front( (*i) );
130 cont2.push_front( target );
131 Perform *p = (*k)->duplicate( bld, &cont2, &mTmp );
132 p->setTarget( target );
133 p->setRule( sName );
134 for( FunctionList::iterator f = lReqFuncs.begin();
135 f != lReqFuncs.end(); f++ )
136 {
137 p->getReqFuncs().push_back(
138 (*f)->duplicate( bld, &cont2, &mTmp )
139 );
140 }
141 lPerf.push_back( p );
142 }
143 if( bFirstOnly )
144 break;
145 }
146 }
147 }
148
149 lInput.insert( lInput.end(), lNewOut.begin(), lNewOut.end() );
150 lOutput.insert( lOutput.end(), lNewOut.begin(), lNewOut.end() );
151
152 if( bHasProduces == false )
153 {
154 lProduces.clear();
155 }
156
157 return lOutput;
158}
159
diff --git a/src/rule.h b/src/rule.h
deleted file mode 100644
index c6e8336..0000000
--- a/src/rule.h
+++ /dev/null
@@ -1,86 +0,0 @@
1#ifndef RULE_H
2#define RULE_H
3
4#include <stdint.h>
5#include <string>
6#include <list>
7
8class Function;
9class Perform;
10class Build;
11
12typedef std::list<Function *> FunctionList;
13typedef std::list<Perform *> PerformList;
14typedef std::list<std::string> StringList;
15
16class Rule
17{
18public:
19 Rule();
20 virtual ~Rule();
21
22 StringList execute( Build &bld, StringList &lInput, PerformList &lPerf, bool bFirstOnly=true );
23
24 void setTarget( const std::string &sTarget )
25 {
26 this->sTarget = sTarget;
27 }
28
29 std::string getName()
30 {
31 return sName;
32 }
33
34 void setName( const std::string &sName )
35 {
36 this->sName = sName;
37 }
38
39 FunctionList &getFilterList()
40 {
41 return lFilter;
42 }
43
44 PerformList &getPerformList()
45 {
46 return lPerform;
47 }
48
49 FunctionList &getMatchesList()
50 {
51 return lMatches;
52 }
53
54 StringList &getProducesList()
55 {
56 return lProduces;
57 }
58
59 void setAggregate( Function *pAggregate )
60 {
61 this->pAggregate = pAggregate;
62 }
63
64 StringList &getReqStrList()
65 {
66 return lReqStrs;
67 }
68
69 FunctionList &getReqFuncList()
70 {
71 return lReqFuncs;
72 }
73
74private:
75 std::string sName;
76 FunctionList lMatches;
77 FunctionList lFilter;
78 PerformList lPerform;
79 StringList lProduces;
80 std::string sTarget;
81 Function *pAggregate;
82 StringList lReqStrs;
83 FunctionList lReqFuncs;
84};
85
86#endif
diff --git a/src/stringproc.cpp b/src/stringproc.cpp
deleted file mode 100644
index 23abca9..0000000
--- a/src/stringproc.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
1#include "stringproc.h"
2
3StringProc::StringProc( Build *pBld ) :
4 pBld( pBld )
5{
6}
7
8StringProc::~StringProc()
9{
10}
11
12
diff --git a/src/stringproc.h b/src/stringproc.h
deleted file mode 100644
index d408601..0000000
--- a/src/stringproc.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef STRING_PROC_H
2#define STRING_PROC_H
3
4#include <stdint.h>
5#include <string>
6#include <map>
7#include <list>
8
9class Build;
10
11typedef std::map<std::string,std::string> VarMap;
12typedef std::list<std::string> StringList;
13
14class StringProc
15{
16public:
17 StringProc( Build *pBld );
18 virtual ~StringProc();
19
20 virtual std::string replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra )=0;
21
22protected:
23 Build *getBuild()
24 {
25 return pBld;
26 }
27
28private:
29 Build *pBld;
30
31};
32
33#endif
diff --git a/src/stringprocbuild.cpp b/src/stringprocbuild.cpp
deleted file mode 100644
index 419d819..0000000
--- a/src/stringprocbuild.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
1#include "stringprocbuild.h"
2#include "build.h"
3
4StringProcBuild::StringProcBuild( Build *pBld ) :
5 StringProc( pBld )
6{
7}
8
9StringProcBuild::~StringProcBuild()
10{
11}
12
13std::string StringProcBuild::replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra )
14{
15 std::string sDes, sBuf;
16 int nMode = 0;
17
18 int nLen = sSrc.size();
19 for( int j = 0; j < nLen; j++ )
20 {
21 if( sSrc[j] == '{' )
22 {
23 sBuf = "";
24 nMode = 1;
25 }
26 else if( nMode == 0 )
27 {
28 sDes += sSrc[j];
29 }
30 else if( nMode == 1 )
31 {
32 if( sSrc[j] == '}' )
33 {
34 sDes += getBuild()->getVar( pCont, sBuf, mExtra );
35 nMode = 0;
36 }
37 else
38 {
39 sBuf += sSrc[j];
40 }
41 }
42 }
43
44 if( nMode == 1 )
45 {
46 throw BuildException(
47 "Unterminated variable replacement found: \"%s\"",
48 sSrc.c_str()
49 );
50 }
51
52 return sDes;
53}
54
diff --git a/src/stringprocbuild.h b/src/stringprocbuild.h
deleted file mode 100644
index f3cf3b4..0000000
--- a/src/stringprocbuild.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef STRING_PROC_BUILD_H
2#define STRING_PROC_BUILD_H
3
4#include <stdint.h>
5
6#include "stringproc.h"
7
8class StringProcBuild : public StringProc
9{
10public:
11 StringProcBuild( Build *pBld );
12 virtual ~StringProcBuild();
13
14 virtual std::string replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra );
15
16private:
17
18};
19
20#endif
diff --git a/src/target.cpp b/src/target.cpp
deleted file mode 100644
index 3150c38..0000000
--- a/src/target.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
1#include "target.h"
2#include "build.h"
3#include "viewer.h"
4
5Target::Target() :
6 bRun( false )
7{
8}
9
10Target::~Target()
11{
12}
13
14void Target::run( Action::eAction nAct, Build &bld )
15{
16 bRun = true;
17
18 bld.getView()->beginCommand( nAct, sName );
19 switch( nAct )
20 {
21 case Action::actCheck:
22 check( bld );
23 break;
24
25 case Action::actClean:
26 clean( bld );
27 break;
28 }
29 bld.getView()->endCommand();
30}
31
diff --git a/src/target.h b/src/target.h
deleted file mode 100644
index f51e0e0..0000000
--- a/src/target.h
+++ /dev/null
@@ -1,63 +0,0 @@
1#ifndef TARGET_H
2#define TARGET_H
3
4#include <stdint.h>
5
6#include <string>
7#include <list>
8
9#include "action.h"
10
11typedef std::list<std::string> StringList;
12
13class Build;
14
15class Target
16{
17public:
18 Target();
19 virtual ~Target();
20
21 void run( Action::eAction nAct, Build &bld );
22 virtual void check( Build &bld ) = 0;
23 virtual void clean( Build &bld ) = 0;
24
25 void setName( const std::string &sName )
26 {
27 this->sName = sName;
28 }
29
30 std::string getName()
31 {
32 return sName;
33 }
34
35 void setRule( const std::string &sRule )
36 {
37 this->sRule = sRule;
38 }
39
40 std::string getRule()
41 {
42 return sRule;
43 }
44
45 StringList &getInput()
46 {
47 return lInput;
48 }
49
50 bool wasRun()
51 {
52 return bRun;
53 }
54
55
56private:
57 std::string sName;
58 std::string sRule;
59 StringList lInput;
60 bool bRun;
61};
62
63#endif
diff --git a/src/targetfactory.cpp b/src/targetfactory.cpp
deleted file mode 100644
index a0bc0b0..0000000
--- a/src/targetfactory.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
1#include "targetfactory.h"
2
3extern struct Bu::PluginInfo file;
4
5TargetFactory::TargetFactory()
6{
7 registerBuiltinPlugin( &file );
8}
9
10TargetFactory::~TargetFactory()
11{
12}
diff --git a/src/targetfactory.h b/src/targetfactory.h
deleted file mode 100644
index ee1fc2a..0000000
--- a/src/targetfactory.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef TARGET_FACTORY_H
2#define TARGET_FACTORY_H
3
4#include <stdint.h>
5
6#include "bu/plugger.h"
7#include "bu/singleton.h"
8#include "target.h"
9
10class TargetFactory : public Bu::Plugger<Target>, public Bu::Singleton<TargetFactory>
11{
12public:
13 TargetFactory();
14 virtual ~TargetFactory();
15
16private:
17
18};
19
20#endif
diff --git a/src/targetfile.cpp b/src/targetfile.cpp
deleted file mode 100644
index 0e2d43e..0000000
--- a/src/targetfile.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
1#include "targetfile.h"
2#include "bu/plugger.h"
3#include "rule.h"
4#include "build.h"
5#include "perform.h"
6#include "function.h"
7#include "viewer.h"
8
9#include <set>
10
11PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 );
12
13TargetFile::TargetFile()
14{
15}
16
17TargetFile::~TargetFile()
18{
19}
20
21void TargetFile::check( Build &bld )
22{
23 Rule *pRule = bld.getRule( getRule() );
24 PerformList lPerf;
25 pRule->setTarget( getName() );
26 StringList lFinal = pRule->execute( bld, getInput(), lPerf );
27
28 {
29 std::set<std::string> sUsed;
30 for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ )
31 {
32isuck: if( i == lPerf.end() ) break;
33 if( sUsed.find( (*i)->getTarget() ) != sUsed.end() )
34 {
35 PerformList::iterator j = i;
36 j++;
37 delete *i;
38 lPerf.erase( i );
39 i = j;
40 goto isuck;
41 }
42 sUsed.insert( (*i)->getTarget() );
43 }
44 }
45
46 bld.getView()->beginPerforms( lPerf.size() );
47
48 for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ )
49 {
50 StringList &reqs = bld.getRequires( (*i)->getTarget() );
51 for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ )
52 {
53 bld.chainTarget( *j );
54 }
55 }
56
57 for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ )
58 {
59 time_t tTarget = getTime( bld, (*i)->getTarget() );
60 StringList &reqs = bld.getRequires( (*i)->getTarget() );
61 bool bExtras = false, bBuilt = false, bUpdate = false;
62 for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ )
63 {
64 //bld.chainTarget( *j );
65 if( getTime( bld, *j ) > tTarget )
66 {
67 if( bUpdate == false )
68 bld.getView()->skipRequiresCheck( false, (*i)->getTarget() ) ;
69 bld.getView()->beginPerform( *i );
70 (*i)->execute( bld );
71 bld.getView()->endPerform();
72 updateTime( (*i)->getTarget() );
73 bBuilt = true;
74 break;
75 }
76 if( bExtras == false )
77 {
78 StringList::iterator jj = j;
79 jj++;
80 if( jj == reqs.end() )
81 {
82 if( !bld.getCached( (*i)->getTarget(), tTarget, reqs ) )
83 {
84 bld.updateCache( (*i)->getTarget(), (*i)->getReqFuncs(), reqs );
85 bUpdate = true;
86 }
87 bExtras = true;
88 }
89 }
90 }
91 if( bBuilt == false )
92 {
93 if( bUpdate == false )
94 {
95 bld.getView()->skipRequiresCheck( false, (*i)->getTarget() );
96 }
97 bld.getView()->skipPerform( *i );
98 }
99 }
100
101 bld.getView()->endPerforms();
102}
103
104void TargetFile::clean( Build &bld )
105{
106 Rule *pRule = bld.getRule( getRule() );
107 PerformList lPerf;
108 pRule->setTarget( getName() );
109 StringList lFinal = pRule->execute( bld, getInput(), lPerf, false );
110
111 bld.getView()->beginPerforms( lPerf.size() );
112
113 for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ )
114 {
115 if( access( (*i)->getTarget().c_str(), W_OK ) == 0 )
116 {
117 (*i)->setRule("clean");
118 bld.getView()->beginPerform( *i );
119 unlink( (*i)->getTarget().c_str() );
120 bld.getView()->endPerform();
121 }
122 }
123
124 bld.getView()->endPerforms();
125}
126
127time_t TargetFile::getTime( Build &bld, std::string str )
128{
129 std::map<std::string, time_t>::iterator i = mTimes.find( str );
130 if( i != mTimes.end() )
131 {
132 //nCache++;
133 //bld.view().beginRequiresCheck( true, str.c_str() );
134 //bld.view().endRequiresCheck();
135 return (*i).second;
136 }
137
138 //bld.view().beginRequiresCheck( false, str.c_str() );
139 struct stat st;
140 stat( str.c_str(), &st );
141
142 mTimes[str] = st.st_mtime;
143
144 //nNew++;
145
146 //bld.view().endRequiresCheck();
147
148 return st.st_mtime;
149}
150
151void TargetFile::updateTime( std::string str )
152{
153 struct stat st;
154 stat( str.c_str(), &st );
155
156 mTimes[str] = st.st_mtime;
157}
158
diff --git a/src/targetfile.h b/src/targetfile.h
deleted file mode 100644
index 368e252..0000000
--- a/src/targetfile.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#ifndef TARGET_FILE_H
2#define TARGET_FILE_H
3
4#include <stdint.h>
5#include <map>
6#include <sys/types.h>
7#include <sys/stat.h>
8#include <unistd.h>
9
10#include "target.h"
11
12class TargetFile : public Target
13{
14public:
15 TargetFile();
16 virtual ~TargetFile();
17
18 virtual void check( Build &bld );
19 virtual void clean( Build &bld );
20
21 time_t getTime( class Build &bld, std::string str );
22 void updateTime( std::string str );
23
24private:
25 std::map<std::string, time_t> mTimes;
26};
27
28#endif
diff --git a/src/viewer.cpp b/src/viewer.cpp
deleted file mode 100644
index 1f3b26f..0000000
--- a/src/viewer.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
1#include "viewer.h"
2
3Viewer::Viewer()
4{
5}
6
7Viewer::~Viewer()
8{
9}
10
11void Viewer::beginAction( const std::string &sName, int nCommands )
12{
13}
14
15void Viewer::endAction()
16{
17}
18
19void Viewer::beginCommand( Action::eAction nAct, const std::string &sTarget )
20{
21}
22
23void Viewer::beginPerforms( int nCount )
24{
25}
26
27void Viewer::endPerforms()
28{
29}
30
31void Viewer::endCommand()
32{
33}
34
35void Viewer::beginRequiresCheck( bool bCached, const std::string &sName )
36{
37}
38
39void Viewer::endRequiresCheck()
40{
41}
42
43void Viewer::skipRequiresCheck( bool bCached, const std::string &sName )
44{
45}
46
47void Viewer::beginPerform( Perform *pPerform )
48{
49}
50
51void Viewer::endPerform()
52{
53}
54
55void Viewer::skipPerform( Perform *pPerform )
56{
57}
58
59void Viewer::beginExecute()
60{
61}
62
63void Viewer::endExecute()
64{
65}
66
67void Viewer::executeCmd( const std::string &sCmd )
68{
69}
70
diff --git a/src/viewer.h b/src/viewer.h
deleted file mode 100644
index 7ee6b21..0000000
--- a/src/viewer.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef VIEWER_H
2#define VIEWER_H
3
4#include <stdint.h>
5#include <string>
6#include "action.h"
7
8class Perform;
9
10class Viewer
11{
12public:
13 Viewer();
14 virtual ~Viewer();
15
16 virtual void beginAction( const std::string &sName, int nCommands );
17 virtual void endAction();
18
19 virtual void beginCommand( Action::eAction nAct, const std::string &sTarget );
20 virtual void endCommand();
21 virtual void beginPerforms( int nCount );
22 virtual void endPerforms();
23
24 virtual void beginRequiresCheck( bool bCached, const std::string &sName );
25 virtual void endRequiresCheck();
26 virtual void skipRequiresCheck( bool bCached, const std::string &sName );
27 virtual void beginPerform( Perform *pPerform );
28 virtual void endPerform();
29 virtual void skipPerform( Perform *pPerform );
30 virtual void beginExecute();
31 virtual void endExecute();
32 virtual void executeCmd( const std::string &sCmd );
33
34private:
35
36};
37
38#endif
diff --git a/src/viewercolorpct.cpp b/src/viewercolorpct.cpp
deleted file mode 100644
index 5bc3cba..0000000
--- a/src/viewercolorpct.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
1#include "viewercolorpct.h"
2#include "perform.h"
3#include "bu/plugger.h"
4#include <math.h>
5
6PluginInterface2( colorpct, ViewerColorPct, Viewer, "Mike Buland", 0, 1 );
7
8ViewerColorPct::ViewerColorPct() :
9 bRunClean( true )
10{
11}
12
13ViewerColorPct::~ViewerColorPct()
14{
15}
16
17void ViewerColorPct::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 ViewerColorPct::endCommand()
32{
33 if( sCmd.front().bCmdClean == false )
34 printf("\n");
35 sCmd.pop_front();
36 if(sCmd.empty())
37 iCC++;
38}
39
40void ViewerColorPct::indent()
41{
42 if( sCmd.empty() ) return;
43 int jmax = sCmd.front().nLevel;
44 for( int j = 0; j < jmax; j++ )
45 {
46 printf(" ");
47 }
48}
49
50void ViewerColorPct::printHead()
51{
52 if( sCmd.front().bCmdClean == true )
53 {
54 bRunClean = false;
55 sCmd.front().bCmdClean = false;
56 indent();
57 if(sCmd.size() > 1)
58 printf("\033[37;22m--- \033[36m%s\033[37m ---\033[0m\n", sCmd.front().sTarget.c_str() );
59 else
60 printf("\033[37;1m--- [\033[32m%d/%d\033[37m] \033[36m%s\033[37m ---\033[0m\n", iCC, iTC, sCmd.front().sTarget.c_str() );
61 }
62}
63
64void ViewerColorPct::printPerform(const char *sRule, const char *sTarget)
65{
66 int iPct = (int)round(
67 ((double)sCmd.front().iCP/(double)sCmd.front().iTP)*100.0
68 );
69 if(sCmd.size() > 1)
70 printf( "\033[37;22m[\033[32m%3d%%\033[37m] \033[35m%8s\033[37m: %s\033[0m\n", iPct, sRule, sTarget );
71 else
72 printf( "\033[37;1m[\033[32m%3d%%\033[37m] \033[35m%8s\033[37m: %s\033[0m\n", iPct, sRule, sTarget );
73}
74
75void ViewerColorPct::beginRequiresCheck( bool bCached, const std::string &sName )
76{
77 printHead();
78 indent();
79 printPerform("deps", sName.c_str());
80}
81
82void ViewerColorPct::endRequiresCheck()
83{
84 sCmd.front().iCP++;
85}
86
87void ViewerColorPct::skipRequiresCheck( bool bCached, const std::string &sName )
88{
89 sCmd.front().iCP++;
90}
91
92void ViewerColorPct::beginPerform( Perform *pPerform )
93{
94 printHead();
95 indent();
96 printPerform(pPerform->getRule().c_str(), pPerform->getTarget().c_str());
97}
98
99void ViewerColorPct::endPerform()
100{
101 sCmd.front().iCP++;
102}
103
104void ViewerColorPct::skipPerform( Perform *pPerform )
105{
106 sCmd.front().iCP++;
107}
108
109void ViewerColorPct::beginPerforms( int nCount )
110{
111 sCmd.front().iTP = nCount*2;
112 sCmd.front().iCP = 1;
113}
114
115void ViewerColorPct::beginAction( const std::string &sName, int nCommands )
116{
117 iTC = nCommands;
118 iCC = 1;
119}
120
121void ViewerColorPct::endAction()
122{
123 if( bRunClean == true )
124 {
125 printf("Nothing to be done.\n\n");
126 }
127 printf("\033[0m");
128}
129
diff --git a/src/viewercolorpct.h b/src/viewercolorpct.h
deleted file mode 100644
index dc810c1..0000000
--- a/src/viewercolorpct.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#ifndef VIEWER_COLOR_PCT_H
2#define VIEWER_COLOR_PCT_H
3
4#include <stdint.h>
5#include <list>
6#include "viewer.h"
7
8class ViewerColorPct : public Viewer
9{
10public:
11 ViewerColorPct();
12 virtual ~ViewerColorPct();
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 skipRequiresCheck( bool bCached, const std::string &sName );
24 virtual void skipPerform( Perform *pPerform );
25
26 virtual void beginAction( const std::string &sName, int nCommands );
27
28 virtual void endAction();
29
30 void printPerform(const char *sRule, const char *sTarget);
31 void printHead();
32 void indent();
33
34private:
35 int iTC, iCC;
36
37 bool bRunClean;
38 typedef struct
39 {
40 int nLevel;
41 bool bCmdClean;
42 std::string sTarget;
43 int iTP, iCP;
44 } Cmd;
45 typedef std::list<Cmd> CmdStack;
46 CmdStack sCmd;
47};
48
49#endif
diff --git a/src/viewerfactory.cpp b/src/viewerfactory.cpp
deleted file mode 100644
index 5726e56..0000000
--- a/src/viewerfactory.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
1#include "viewerfactory.h"
2
3extern struct Bu::PluginInfo plain;
4extern struct Bu::PluginInfo percent;
5extern struct Bu::PluginInfo make;
6extern struct Bu::PluginInfo plainpct;
7extern struct Bu::PluginInfo colorpct;
8
9ViewerFactory::ViewerFactory()
10{
11 registerBuiltinPlugin( &plain );
12 registerBuiltinPlugin( &percent );
13 registerBuiltinPlugin( &make );
14 registerBuiltinPlugin( &plainpct );
15 registerBuiltinPlugin( &colorpct );
16}
17
18ViewerFactory::~ViewerFactory()
19{
20}
diff --git a/src/viewerfactory.h b/src/viewerfactory.h
deleted file mode 100644
index ffa5b31..0000000
--- a/src/viewerfactory.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef VIEWER_FACTORY_H
2#define VIEWER_FACTORY_H
3
4#include <stdint.h>
5
6#include "viewer.h"
7#include "bu/plugger.h"
8#include "bu/singleton.h"
9
10class ViewerFactory : public Bu::Plugger<Viewer>, public Bu::Singleton<ViewerFactory>
11{
12public:
13 ViewerFactory();
14 virtual ~ViewerFactory();
15
16private:
17
18};
19
20#endif
diff --git a/src/viewermake.cpp b/src/viewermake.cpp
deleted file mode 100644
index ed11b5f..0000000
--- a/src/viewermake.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
1#include "viewermake.h"
2#include "perform.h"
3#include "bu/plugger.h"
4
5PluginInterface2( make, ViewerMake, Viewer, "Mike Buland", 0, 1 );
6
7ViewerMake::ViewerMake()
8{
9}
10
11ViewerMake::~ViewerMake()
12{
13}
14
15void ViewerMake::executeCmd( const std::string &sCmd )
16{
17 printf("%s\n", sCmd.c_str() );
18}
19
diff --git a/src/viewermake.h b/src/viewermake.h
deleted file mode 100644
index 11b8741..0000000
--- a/src/viewermake.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef VIEWER_MAKE_H
2#define VIEWER_MAKE_H
3
4#include <stdint.h>
5
6#include "viewer.h"
7
8class ViewerMake : public Viewer
9{
10public:
11 ViewerMake();
12 virtual ~ViewerMake();
13
14 virtual void executeCmd( const std::string &sCmd );
15
16private:
17
18};
19
20#endif
diff --git a/src/viewerpercent.cpp b/src/viewerpercent.cpp
deleted file mode 100644
index baca82a..0000000
--- a/src/viewerpercent.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
1#include "viewerpercent.h"
2#include "perform.h"
3#include "bu/plugger.h"
4
5#include <sys/ioctl.h>
6#include <stdio.h>
7#include <stdlib.h>
8
9PluginInterface2( percent, ViewerPercent, Viewer, "Mike Buland", 0, 1 );
10
11ViewerPercent::ViewerPercent() :
12 nWidth( 15 )
13{
14}
15
16ViewerPercent::~ViewerPercent()
17{
18}
19
20void ViewerPercent::beginAction( const std::string &sName, int nCommands )
21{
22 nTotalCommands = nCommands;
23 nCurCommand = 0;
24}
25
26void ViewerPercent::endAction()
27{
28}
29
30void ViewerPercent::beginCommand( Action::eAction nAct, const std::string &sTarget )
31{
32 this->sTarget = sTarget;
33 nCurCommand++;
34
35 struct winsize scrn;
36
37 ioctl( fileno( stdout ), TIOCGWINSZ, &scrn );
38
39 nTermWidth = scrn.ws_col;
40}
41
42void ViewerPercent::endCommand()
43{
44 printf("\n");
45 fflush(stdout);
46}
47
48void ViewerPercent::beginPerforms( int nCount )
49{
50 nTotalPerforms = nCount;
51 nCurPerform = 0;
52 nLastLen = 0;
53}
54
55void ViewerPercent::endPerforms()
56{
57 nCurPerform = nTotalPerforms;
58
59 printPercent("");
60}
61
62void ViewerPercent::beginRequiresCheck( bool bCached, const std::string &sName )
63{
64}
65
66void ViewerPercent::endRequiresCheck()
67{
68}
69
70void ViewerPercent::beginPerform( Perform *pPerform )
71{
72 nCurPerform++;
73 printPercent( pPerform->getTarget() );
74}
75
76void ViewerPercent::printPercent( const std::string &sCur )
77{
78 char buf[2048];
79 char *bi = buf;
80 int nLen = sprintf( buf, "\r[%d/%d] %s [",
81 nCurCommand, nTotalCommands,
82 sTarget.c_str() );
83 bi += nLen;
84 int jmax = nCurPerform*nWidth/nTotalPerforms;
85 for( int j = 0; j < jmax; j++ )
86 {
87 *bi = '#';
88 bi++;
89 }
90 jmax = nWidth-jmax;
91 for( int j = 0; j < jmax; j++ )
92 {
93 *bi = ' ';
94 bi++;
95 }
96 nLen += nWidth;
97 nLen += sprintf( bi, "] %-2d%% %s",
98 nCurPerform*100/nTotalPerforms,
99 sCur.c_str() );
100 bi = buf + nLen;
101 if( (int)(bi - buf) >= nTermWidth )
102 {
103 nLastLen = nLen = nTermWidth;
104 strcpy( buf+nTermWidth-3, "...");
105 }
106 else
107 {
108 if( nLastLen > nLen )
109 {
110 jmax = nLastLen-nLen;
111 for( int j = 0; j < jmax; j++ )
112 {
113 *bi = ' ';
114 bi++;
115 }
116 }
117 nLastLen = nLen;
118 *bi = '\0';
119 }
120
121 fputs( buf, stdout );
122
123 fflush( stdout );
124}
125
126void ViewerPercent::endPerform()
127{
128}
129
diff --git a/src/viewerpercent.h b/src/viewerpercent.h
deleted file mode 100644
index d40ca1b..0000000
--- a/src/viewerpercent.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#ifndef VIEWER_PERCENT_H
2#define VIEWER_PERCENT_H
3
4#include <stdint.h>
5
6#include "viewer.h"
7
8class ViewerPercent : public Viewer
9{
10public:
11 ViewerPercent();
12 virtual ~ViewerPercent();
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 virtual void endPerforms();
23 virtual void beginAction( const std::string &sName, int nCommands );
24 virtual void endAction();
25
26 void printPercent( const std::string &sCur );
27
28private:
29 int nTotalCommands;
30 int nCurCommand;
31 int nTotalPerforms;
32 int nCurPerform;
33 std::string sTarget;
34 int nLastLen;
35 int nWidth;
36 int nTermWidth;
37};
38
39#endif
diff --git a/src/viewerplain.cpp b/src/viewerplain.cpp
deleted file mode 100644
index 3e65f21..0000000
--- a/src/viewerplain.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
1#include "viewerplain.h"
2#include "perform.h"
3#include "bu/plugger.h"
4
5PluginInterface2( plain, ViewerPlain, Viewer, "Mike Buland", 0, 1 );
6
7ViewerPlain::ViewerPlain() :
8 bRunClean( true )
9{
10}
11
12ViewerPlain::~ViewerPlain()
13{
14}
15
16void ViewerPlain::beginCommand( Action::eAction nAct, const std::string &sTarget )
17{
18 Cmd cmd;
19 if( sCmd.empty() )
20 cmd.nLevel = 0;
21 else
22 cmd.nLevel = sCmd.front().nLevel+1;
23
24 cmd.bCmdClean = true;
25 cmd.sTarget = sTarget;
26
27 sCmd.push_front( cmd );
28}
29
30void ViewerPlain::endCommand()
31{
32 if( sCmd.front().bCmdClean == false )
33 printf("\n");
34 sCmd.pop_front();
35}
36
37void ViewerPlain::indent()
38{
39 if( sCmd.empty() ) return;
40 int jmax = sCmd.front().nLevel;
41 for( int j = 0; j < jmax; j++ )
42 {
43 printf(" ");
44 }
45}
46
47void ViewerPlain::printHead()
48{
49 if( sCmd.front().bCmdClean == true )
50 {
51 bRunClean = false;
52 sCmd.front().bCmdClean = false;
53 indent();
54 printf("--- %s ---\n", sCmd.front().sTarget.c_str() );
55 }
56}
57
58void ViewerPlain::beginRequiresCheck( bool bCached, const std::string &sName )
59{
60 printHead();
61 indent();
62 printf(" deps: %s\n", sName.c_str() );
63}
64
65void ViewerPlain::endRequiresCheck()
66{
67}
68
69void ViewerPlain::beginPerform( Perform *pPerform )
70{
71 printHead();
72 indent();
73 printf(" %8s: %s\n", pPerform->getRule().c_str(), pPerform->getTarget().c_str() );
74}
75
76void ViewerPlain::endPerform()
77{
78}
79
80void ViewerPlain::endAction()
81{
82 if( bRunClean == true )
83 {
84 printf("Nothing to be done.\n\n");
85 }
86}
87
diff --git a/src/viewerplain.h b/src/viewerplain.h
deleted file mode 100644
index 118ae80..0000000
--- a/src/viewerplain.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#ifndef VIEWER_PLAIN_H
2#define VIEWER_PLAIN_H
3
4#include <stdint.h>
5#include <list>
6#include "viewer.h"
7
8class ViewerPlain : public Viewer
9{
10public:
11 ViewerPlain();
12 virtual ~ViewerPlain();
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
22 virtual void endAction();
23
24 void printHead();
25 void indent();
26
27private:
28 bool bRunClean;
29 typedef struct
30 {
31 int nLevel;
32 bool bCmdClean;
33 std::string sTarget;
34 } Cmd;
35 typedef std::list<Cmd> CmdStack;
36 CmdStack sCmd;
37};
38
39#endif
diff --git a/src/viewerplainpct.cpp b/src/viewerplainpct.cpp
deleted file mode 100644
index 4d9fa7b..0000000
--- a/src/viewerplainpct.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
1#include "viewerplainpct.h"
2#include "perform.h"
3#include "bu/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 if(sCmd.empty())
37 iCC++;
38}
39
40void ViewerPlainPct::indent()
41{
42 if( sCmd.empty() ) return;
43 int jmax = sCmd.front().nLevel;
44 for( int j = 0; j < jmax; j++ )
45 {
46 printf(" ");
47 }
48}
49
50void ViewerPlainPct::printHead()
51{
52 if( sCmd.front().bCmdClean == true )
53 {
54 bRunClean = false;
55 sCmd.front().bCmdClean = false;
56 indent();
57 if(sCmd.size() > 1)
58 printf("--- %s ---\n", sCmd.front().sTarget.c_str() );
59 else
60 printf("--- [%d/%d] %s ---\n", iCC, iTC, sCmd.front().sTarget.c_str() );
61 }
62}
63
64void ViewerPlainPct::printPerform(const char *sRule, const char *sTarget)
65{
66 int iPct = (int)round(
67 ((double)sCmd.front().iCP/(double)sCmd.front().iTP)*100.0
68 );
69 if(sCmd.size() > 1)
70 printf( "[%3d%%] %8s: %s\n", iPct, sRule, sTarget );
71 else
72 printf( "[%3d%%] %8s: %s\n", iPct, sRule, sTarget );
73}
74
75void ViewerPlainPct::beginRequiresCheck( bool bCached, const std::string &sName )
76{
77 printHead();
78 indent();
79 printPerform("deps", sName.c_str());
80}
81
82void ViewerPlainPct::endRequiresCheck()
83{
84 sCmd.front().iCP++;
85}
86
87void ViewerPlainPct::skipRequiresCheck( bool bCached, const std::string &sName )
88{
89 sCmd.front().iCP++;
90}
91
92void ViewerPlainPct::beginPerform( Perform *pPerform )
93{
94 printHead();
95 indent();
96 printPerform(pPerform->getRule().c_str(), pPerform->getTarget().c_str());
97}
98
99void ViewerPlainPct::endPerform()
100{
101 sCmd.front().iCP++;
102}
103
104void ViewerPlainPct::skipPerform( Perform *pPerform )
105{
106 sCmd.front().iCP++;
107}
108
109void ViewerPlainPct::beginPerforms( int nCount )
110{
111 sCmd.front().iTP = nCount*2;
112 sCmd.front().iCP = 1;
113}
114
115void ViewerPlainPct::beginAction( const std::string &sName, int nCommands )
116{
117 iTC = nCommands;
118 iCC = 1;
119}
120
121void ViewerPlainPct::endAction()
122{
123 if( bRunClean == true )
124 {
125 printf("Nothing to be done.\n\n");
126 }
127}
128
diff --git a/src/viewerplainpct.h b/src/viewerplainpct.h
deleted file mode 100644
index 63bc00d..0000000
--- a/src/viewerplainpct.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#ifndef VIEWER_PLAIN_PCT_H
2#define VIEWER_PLAIN_PCT_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 skipRequiresCheck( bool bCached, const std::string &sName );
24 virtual void skipPerform( Perform *pPerform );
25
26 virtual void beginAction( const std::string &sName, int nCommands );
27
28 virtual void endAction();
29
30 void printPerform(const char *sRule, const char *sTarget);
31 void printHead();
32 void indent();
33
34private:
35 int iTC, iCC;
36
37 bool bRunClean;
38 typedef struct
39 {
40 int nLevel;
41 bool bCmdClean;
42 std::string sTarget;
43 int iTP, iCP;
44 } Cmd;
45 typedef std::list<Cmd> CmdStack;
46 CmdStack sCmd;
47};
48
49#endif