aboutsummaryrefslogtreecommitdiff
path: root/src/builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/builder.h')
-rw-r--r--src/builder.h196
1 files changed, 0 insertions, 196 deletions
diff --git a/src/builder.h b/src/builder.h
deleted file mode 100644
index c570dbb..0000000
--- a/src/builder.h
+++ /dev/null
@@ -1,196 +0,0 @@
1#ifndef BUILDER_H
2#define BUILDER_H
3
4#include <string>
5#include <list>
6#include <map>
7#include "build.tab.h"
8#include "exceptionbase.h"
9#include "staticstring.h"
10#include "regexp.h"
11#include "cache.h"
12
13subExceptionDecl( BuildException )
14
15class Builder;
16class Action;
17class Command;
18class Rule;
19class Target;
20class Viewer;
21class Cache;
22
23#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld )
24YY_DECL;
25
26class Builder
27{
28 struct ltstr
29 {
30 bool operator()(const char* s1, const char* s2) const
31 {
32 return strcmp(s1, s2) < 0;
33 }
34 };
35
36public:
37 Builder( Viewer &rView );
38 virtual ~Builder();
39
40 void load( const char *sFN );
41 void build( const char *sAct=NULL );
42 void execute( Action *pAct );
43
44 void error( YYLTYPE *locp, const std::string &m );
45 void error( const std::string &m );
46
47 std::string file;
48
49 Viewer &view()
50 {
51 return rView;
52 }
53
54 void startList( int tokType );
55 void setFilter( const char *sRegExp );
56 void augmentList( const char *sFrom );
57 void addListItem( const char *sItem );
58 void clearList();
59 void endList();
60
61 void addTarget( int tokType, const char *sName );
62 void setTargetInputType( int tokType );
63 void addTargetInput( const char *sInput );
64 void setTargetRule( const char *sRule );
65 void endTarget();
66
67 void setCache( const std::string &sFile );
68 void add( Action *pAct );
69 void add( Command *pCmd );
70 void addRegexCommand( int nType, const char *sReg );
71 void add( Rule *pRule );
72 void add( Target *pTarg );
73 void varSet( const char *sName, const char *sValue );
74 void varAddSet( const char *sName, const char *sValue );
75 Rule *getRule( const char *sName );
76 std::list<Rule *> findRuleChain( Rule *pRule );
77 void processRequires( std::list<std::string> &lInput );
78 void requires( const char *sBase, const char *sReq );
79 void requiresFromCommand( const char *sBase, const char *sReq );
80 void genRequiresFor( const char *sName, time_t tNewTime );
81 std::list<std::string> findTargets( const char *sRegex );
82 void requiresRegexp( bool on )
83 {
84 bReqRegexp = on;
85 }
86 bool isRequiresRegexp()
87 {
88 return bReqRegexp;
89 }
90 void setContext( const char *sCont );
91 void setContext();
92
93 bool hasDefaultAction()
94 {
95 return pDefaultAction != NULL;
96 }
97
98 void debug();
99
100 Rule *lastRule()
101 {
102 return pLastAddedRule;
103 }
104
105 Target *lastTarget()
106 {
107 return pLastAddedTarget;
108 }
109
110 void setTmp( const char *s )
111 {
112 sTmp = s;
113 }
114
115 const char *getTmp()
116 {
117 return sTmp;
118 }
119
120 Target *getTarget( const char *sName )
121 {
122 if( mTarget.find( sName ) == mTarget.end() )
123 throw BuildException("Target %s not found.", sName );
124
125 return mTarget[sName];
126 }
127
128 std::list<std::string> *getRequires( const char *sReq )
129 {
130 if( mRequires.find(sReq) == mRequires.end() )
131 return NULL;
132 return mRequires[sReq];
133 }
134
135 typedef std::map<std::string, std::string> varmap;
136 varmap *regexVars( RegExp *re );
137 void regexVars( RegExp *re, varmap &map );
138 std::string varRepl( const char *sSrc, const char *cont, varmap *mExtra );
139
140 std::string cmdToString( const char *sCmd );
141
142private:
143 void requiresNormal( const char *sBase, const char *sReq );
144 void requiresRegexp( const char *sBase, const char *sReq );
145 void checkVar( const char *cont, const char *sName );
146 void scanBegin();
147 void scanEnd();
148
149 bool hasVar( varmap *pMap, std::string &var );
150
151 Action *pDefaultAction;
152 Action *pLastAddedAction;
153 std::map<const char *, Action *, ltstr> mAction;
154
155 Rule *pLastAddedRule;
156 std::map<const char *, Rule *, ltstr> mRule;
157
158 Target *pLastAddedTarget;
159 std::map<const char *, Target *, ltstr> mTarget;
160
161 varmap mVar;
162
163 std::map<std::string, std::list<std::string> *> mRequires;
164
165 typedef std::list<std::pair<RegExp *, std::string> > regreqlist;
166 regreqlist lRequiresRegexp;
167 regreqlist lRequiresRegexpCommand;
168
169 std::map<std::string, varmap> mContVar;
170 StaticString sContext;
171
172 StaticString sTmp;
173
174 bool bReqRegexp;
175
176 Viewer &rView;
177
178 StaticString sCacheFile;
179 class Cache cRequires;
180
181 std::list<std::pair<std::string,std::map<std::string,std::string> > > lTok;
182 bool bTokFiltered;
183 int nTokType;
184 RegExp rTok;
185
186 int nTargetType;
187 int nTargetInputType;
188 std::string sTargetName;
189 std::list<std::string> lsTargetInput;
190 std::string sTargetRule;
191 bool bUsingList;
192};
193
194void cleanList( std::list<std::string> &lst );
195
196#endif