diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-09-12 00:22:33 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-09-12 00:22:33 +0000 |
commit | d19ada0aa88aba1c7b439035c0028440ac860ec3 (patch) | |
tree | fb8cde98650aa66fcdb736b045f541eac1b8b93a | |
parent | 97d529fac68105f0d3d34c699a4ac10489c705e8 (diff) | |
download | build-d19ada0aa88aba1c7b439035c0028440ac860ec3.tar.gz build-d19ada0aa88aba1c7b439035c0028440ac860ec3.tar.bz2 build-d19ada0aa88aba1c7b439035c0028440ac860ec3.tar.xz build-d19ada0aa88aba1c7b439035c0028440ac860ec3.zip |
Build now builds, it has viewers, and dependancy checking, and everything works.
Now we have to add cleaning, caching, and more viewer hooks / viewers.
Diffstat (limited to '')
33 files changed, 638 insertions, 55 deletions
@@ -4,7 +4,8 @@ default action: check "build" | |||
4 | "clean" action: clean "build" | 4 | "clean" action: clean "build" |
5 | "rebuild" action: clean "build", check "build" | 5 | "rebuild" action: clean "build", check "build" |
6 | 6 | ||
7 | set "CXXFLAGS" += "-ggdb" | 7 | set "CXXFLAGS" += "-ggdb -Ilibbu++/src" |
8 | set "LDFLAGS" += "-Llibbu++ -lbu++ -ldl" | ||
8 | 9 | ||
9 | "build": | 10 | "build": |
10 | rule "exe", | 11 | rule "exe", |
@@ -15,13 +16,13 @@ set "CXXFLAGS" += "-ggdb" | |||
15 | 16 | ||
16 | rule "exe": | 17 | rule "exe": |
17 | matches regexp("(.*)\\.o$"), | 18 | matches regexp("(.*)\\.o$"), |
18 | input filter toString(), | 19 | aggregate toString(" "), |
19 | perform command("g++ {LDFLAGS} -o {target} {match}") | 20 | perform command("g++ -o {target} {match} {LDFLAGS}") |
20 | 21 | ||
21 | rule "cpp": | 22 | rule "cpp": |
22 | matches regexp("(.*)\\.cpp$"), | 23 | matches regexp("(.*)\\.(cpp|c)$"), |
23 | produces "{re:1}.o", | 24 | produces "{re:1}.o", |
24 | requires commandToList("g++ -M {match}", "make"), | 25 | requires commandToList("g++ -M {CXXFLAGS} {match}", "make"), |
25 | perform command("g++ {CXXFLAGS} -c -o {target} {match}") | 26 | perform command("g++ {CXXFLAGS} -c -o {target} {match}") |
26 | 27 | ||
27 | rule "bison": | 28 | rule "bison": |
diff --git a/src/build.cpp b/src/build.cpp index 255cbd3..5c0b721 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -1,10 +1,14 @@ | |||
1 | #include "build.h" | 1 | #include "build.h" |
2 | #include "function.h" | ||
3 | #include "viewerfactory.h" | ||
2 | 4 | ||
3 | subExceptionDef( BuildException ); | 5 | subExceptionDef( BuildException ); |
4 | 6 | ||
5 | Build::Build() : | 7 | Build::Build() : |
6 | pStrProc( NULL ) | 8 | pStrProc( NULL ), |
9 | pView( NULL ) | ||
7 | { | 10 | { |
11 | pView = ViewerFactory::getInstance().instantiate("plain"); | ||
8 | } | 12 | } |
9 | 13 | ||
10 | Build::~Build() | 14 | Build::~Build() |
@@ -46,6 +50,7 @@ void Build::execAction( const std::string &sWhat ) | |||
46 | sWhat.c_str() | 50 | sWhat.c_str() |
47 | ); | 51 | ); |
48 | Target *pTarget = mTarget[pAct->getWhat()]; | 52 | Target *pTarget = mTarget[pAct->getWhat()]; |
53 | pView->beginCommand( pAct->getAct(), pAct->getWhat(), 0 ); | ||
49 | switch( pAct->getAct() ) | 54 | switch( pAct->getAct() ) |
50 | { | 55 | { |
51 | case Action::actCheck: | 56 | case Action::actCheck: |
@@ -56,6 +61,7 @@ void Build::execAction( const std::string &sWhat ) | |||
56 | pTarget->clean( *this ); | 61 | pTarget->clean( *this ); |
57 | break; | 62 | break; |
58 | } | 63 | } |
64 | pView->endCommand(); | ||
59 | } | 65 | } |
60 | 66 | ||
61 | return; | 67 | return; |
@@ -234,3 +240,34 @@ void Build::debugDump() | |||
234 | } | 240 | } |
235 | } | 241 | } |
236 | 242 | ||
243 | RuleList Build::findChainRules( Rule *pHead ) | ||
244 | { | ||
245 | RuleList lOut; | ||
246 | FunctionList &lMatches = pHead->getMatchesList(); | ||
247 | |||
248 | for( RuleMap::iterator i = mRule.begin(); i != mRule.end(); i++ ) | ||
249 | { | ||
250 | if( (*i).second == pHead ) | ||
251 | continue; | ||
252 | |||
253 | for( FunctionList::iterator j = lMatches.begin(); | ||
254 | j != lMatches.end(); j++ ) | ||
255 | { | ||
256 | StringList lTmp; | ||
257 | (*j)->execute( NULL, (*i).second->getProducesList(), lTmp ); | ||
258 | if( !lTmp.empty() ) | ||
259 | { | ||
260 | lOut.push_back( (*i).second ); | ||
261 | break; | ||
262 | } | ||
263 | } | ||
264 | } | ||
265 | |||
266 | return lOut; | ||
267 | } | ||
268 | |||
269 | StringList &Build::getRequires( std::string sName ) | ||
270 | { | ||
271 | return mRequires[sName]; | ||
272 | } | ||
273 | |||
diff --git a/src/build.h b/src/build.h index 080304b..31c8bde 100644 --- a/src/build.h +++ b/src/build.h | |||
@@ -14,6 +14,15 @@ | |||
14 | 14 | ||
15 | subExceptionDecl( BuildException ); | 15 | subExceptionDecl( BuildException ); |
16 | typedef std::map<std::string, std::string> VarMap; | 16 | typedef std::map<std::string, std::string> VarMap; |
17 | typedef std::map<std::string, Target *> TargetMap; | ||
18 | typedef std::list<std::string> StringList; | ||
19 | typedef std::map<std::string, StringList> ReqMap; | ||
20 | typedef std::map<std::string, VarMap> ContextMap; | ||
21 | typedef std::map<std::string, Rule *> RuleMap; | ||
22 | typedef std::list<Rule *> RuleList; | ||
23 | typedef std::map<std::string, Action *> ActionMap; | ||
24 | |||
25 | class Viewer; | ||
17 | 26 | ||
18 | class Build | 27 | class Build |
19 | { | 28 | { |
@@ -44,15 +53,15 @@ public: | |||
44 | 53 | ||
45 | void setStringProc( StringProc *pStrProc ); | 54 | void setStringProc( StringProc *pStrProc ); |
46 | std::string replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra ); | 55 | std::string replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra ); |
56 | RuleList findChainRules( Rule *pHead ); | ||
57 | StringList &getRequires( std::string sName ); | ||
47 | 58 | ||
48 | private: | 59 | Viewer *getView() |
49 | typedef std::map<std::string, Target *> TargetMap; | 60 | { |
50 | typedef std::list<std::string> StringList; | 61 | return pView; |
51 | typedef std::map<std::string, StringList> ReqMap; | 62 | } |
52 | typedef std::map<std::string, VarMap> ContextMap; | ||
53 | typedef std::map<std::string, Rule *> RuleMap; | ||
54 | typedef std::map<std::string, Action *> ActionMap; | ||
55 | 63 | ||
64 | private: | ||
56 | TargetMap mTarget; | 65 | TargetMap mTarget; |
57 | ReqMap mRequires; | 66 | ReqMap mRequires; |
58 | VarMap mVars; | 67 | VarMap mVars; |
@@ -60,6 +69,7 @@ private: | |||
60 | RuleMap mRule; | 69 | RuleMap mRule; |
61 | ActionMap mAction; | 70 | ActionMap mAction; |
62 | StringProc *pStrProc; | 71 | StringProc *pStrProc; |
72 | Viewer *pView; | ||
63 | 73 | ||
64 | //std::map<std::string, Rule *> mRule; | 74 | //std::map<std::string, Rule *> mRule; |
65 | //Action *pActDefault; | 75 | //Action *pActDefault; |
diff --git a/src/build.l b/src/build.l index 41abaf4..49275c8 100644 --- a/src/build.l +++ b/src/build.l | |||
@@ -34,6 +34,7 @@ std::string strbuf; | |||
34 | "input" return TOK_INPUT; | 34 | "input" return TOK_INPUT; |
35 | "filter" return TOK_FILTER; | 35 | "filter" return TOK_FILTER; |
36 | "prefix" return TOK_PREFIX; | 36 | "prefix" return TOK_PREFIX; |
37 | "aggregate" return TOK_AGGREGATE; | ||
37 | 38 | ||
38 | \n+ { | 39 | \n+ { |
39 | yylloc->last_line += yyleng; | 40 | yylloc->last_line += yyleng; |
diff --git a/src/build.y b/src/build.y index bb30d84..0853bd9 100644 --- a/src/build.y +++ b/src/build.y | |||
@@ -39,6 +39,7 @@ void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg ); | |||
39 | %token TOK_MATCHES "matches" | 39 | %token TOK_MATCHES "matches" |
40 | %token TOK_PERFORM "perform" | 40 | %token TOK_PERFORM "perform" |
41 | %token TOK_PRODUCES "produces" | 41 | %token TOK_PRODUCES "produces" |
42 | %token TOK_AGGREGATE "aggregate" | ||
42 | 43 | ||
43 | %token ',' ':' '=' '(' ')' | 44 | %token ',' ':' '=' '(' ')' |
44 | 45 | ||
@@ -86,6 +87,10 @@ rulecmd: TOK_MATCHES func | |||
86 | { | 87 | { |
87 | bld.addRulePerform(); | 88 | bld.addRulePerform(); |
88 | } | 89 | } |
90 | | TOK_AGGREGATE func | ||
91 | { | ||
92 | bld.setRuleAggregate(); | ||
93 | } | ||
89 | ; | 94 | ; |
90 | 95 | ||
91 | // Action interpretation | 96 | // Action interpretation |
diff --git a/src/buildparser.cpp b/src/buildparser.cpp index f855990..6c3337f 100644 --- a/src/buildparser.cpp +++ b/src/buildparser.cpp | |||
@@ -121,7 +121,7 @@ void BuildParser::filterList() | |||
121 | { | 121 | { |
122 | StringList lTmp2; | 122 | StringList lTmp2; |
123 | StringList lIn = buildToStringList( lTmp, StringList() ); | 123 | StringList lIn = buildToStringList( lTmp, StringList() ); |
124 | pTmpFunc->execute( lIn, lTmp2 ); | 124 | pTmpFunc->execute( NULL, lIn, lTmp2 ); |
125 | lTmp.clear(); | 125 | lTmp.clear(); |
126 | for( StringList::iterator i = lTmp2.begin(); i != lTmp2.end(); i++ ) | 126 | for( StringList::iterator i = lTmp2.begin(); i != lTmp2.end(); i++ ) |
127 | { | 127 | { |
@@ -137,7 +137,7 @@ StringList BuildParser::buildToStringList( const BuildList &lSrc, const StringLi | |||
137 | { | 137 | { |
138 | if( (*i).second ) | 138 | if( (*i).second ) |
139 | { | 139 | { |
140 | (*i).second->execute( lIn, lOut ); | 140 | (*i).second->execute( NULL, lIn, lOut ); |
141 | } | 141 | } |
142 | else | 142 | else |
143 | { | 143 | { |
@@ -155,6 +155,7 @@ void BuildParser::addRule( const char *sName ) | |||
155 | { | 155 | { |
156 | lRuleTmp.push_back( RuleInfo() ); | 156 | lRuleTmp.push_back( RuleInfo() ); |
157 | lRuleTmp.back().sName = sName; | 157 | lRuleTmp.back().sName = sName; |
158 | lRuleTmp.back().pAggregate = NULL; | ||
158 | } | 159 | } |
159 | 160 | ||
160 | void BuildParser::addRuleMatches() | 161 | void BuildParser::addRuleMatches() |
@@ -188,6 +189,11 @@ void BuildParser::addRulePerform() | |||
188 | lRuleTmp.back().lPerform.push_back( pTmpPerform ); | 189 | lRuleTmp.back().lPerform.push_back( pTmpPerform ); |
189 | } | 190 | } |
190 | 191 | ||
192 | void BuildParser::setRuleAggregate() | ||
193 | { | ||
194 | lRuleTmp.back().pAggregate = pTmpFunc; | ||
195 | } | ||
196 | |||
191 | // | 197 | // |
192 | // Perform functions | 198 | // Perform functions |
193 | // | 199 | // |
@@ -431,14 +437,35 @@ Build *BuildParser::genBuild() | |||
431 | pRule->getPerformList().push_back( *j ); | 437 | pRule->getPerformList().push_back( *j ); |
432 | } | 438 | } |
433 | 439 | ||
434 | /*StringList lITmp = buildToStringList( | 440 | for( BuildList::iterator j = (*i).lProduces.begin(); |
435 | (*i).lProduces, StringList() | 441 | j != (*i).lProduces.end(); j++ ) |
436 | ); | 442 | { |
443 | if( (*j).second ) | ||
444 | { | ||
445 | throw BuildException( | ||
446 | "You cannot have functions in produces lists (rule %s).", | ||
447 | (*i).sName.c_str() ); | ||
448 | } | ||
449 | pRule->getProducesList().push_back( (*j).first ); | ||
450 | } | ||
437 | 451 | ||
438 | for( StringList::iterator i = lITmp.begin(); i != lITmp.end(); i++ ) | 452 | if( (*i).pAggregate ) |
439 | { | 453 | { |
440 | get | 454 | pRule->setAggregate( (*i).pAggregate ); |
441 | }*/ | 455 | } |
456 | |||
457 | for( BuildList::iterator j = (*i).lRequires.begin(); | ||
458 | j != (*i).lRequires.end(); j++ ) | ||
459 | { | ||
460 | if( (*j).second ) | ||
461 | { | ||
462 | pRule->getReqFuncList().push_back( (*j).second ); | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | pRule->getReqStrList().push_back( (*j).first ); | ||
467 | } | ||
468 | } | ||
442 | 469 | ||
443 | bld->addRule( pRule ); | 470 | bld->addRule( pRule ); |
444 | } | 471 | } |
diff --git a/src/buildparser.h b/src/buildparser.h index 2e1924c..dda2d80 100644 --- a/src/buildparser.h +++ b/src/buildparser.h | |||
@@ -127,6 +127,7 @@ public: // Rules functions | |||
127 | void addRuleRequires(); | 127 | void addRuleRequires(); |
128 | void addRuleInputFilter(); | 128 | void addRuleInputFilter(); |
129 | void addRulePerform(); | 129 | void addRulePerform(); |
130 | void setRuleAggregate(); | ||
130 | 131 | ||
131 | private: // Rule variables | 132 | private: // Rule variables |
132 | class RuleInfo | 133 | class RuleInfo |
@@ -138,6 +139,7 @@ private: // Rule variables | |||
138 | BuildList lRequires; | 139 | BuildList lRequires; |
139 | FunctionList lFilter; | 140 | FunctionList lFilter; |
140 | PerformList lPerform; | 141 | PerformList lPerform; |
142 | Function *pAggregate; | ||
141 | }; | 143 | }; |
142 | 144 | ||
143 | typedef std::list<RuleInfo> RuleTmpList; | 145 | typedef std::list<RuleInfo> RuleTmpList; |
diff --git a/src/function.cpp b/src/function.cpp index e7554e1..8debbe9 100644 --- a/src/function.cpp +++ b/src/function.cpp | |||
@@ -13,3 +13,13 @@ void Function::addParam( const char *str ) | |||
13 | lParams.push_back( str ); | 13 | lParams.push_back( str ); |
14 | } | 14 | } |
15 | 15 | ||
16 | void Function::copyData( Function *pSrc, Build &bld, const std::string &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 index 73dcb01..7035d2f 100644 --- a/src/function.h +++ b/src/function.h | |||
@@ -11,7 +11,9 @@ public: | |||
11 | virtual ~Function(); | 11 | virtual ~Function(); |
12 | 12 | ||
13 | void addParam( const char *str ); | 13 | void addParam( const char *str ); |
14 | virtual void execute( const StringList &lInput, StringList &lOutput )=0; | 14 | virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput )=0; |
15 | virtual Function *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) = 0; | ||
16 | void copyData( Function *pSrc, Build &bld, const std::string &cont, VarMap *mExtra ); | ||
15 | 17 | ||
16 | protected: | 18 | protected: |
17 | StringList lParams; | 19 | StringList lParams; |
diff --git a/src/functioncommandtolist.cpp b/src/functioncommandtolist.cpp index 46762b5..708db5b 100644 --- a/src/functioncommandtolist.cpp +++ b/src/functioncommandtolist.cpp | |||
@@ -11,7 +11,58 @@ FunctionCommandToList::~FunctionCommandToList() | |||
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
14 | void FunctionCommandToList::execute( const StringList &lInput, StringList &lOutput ) | 14 | void FunctionCommandToList::execute( Build *bld, const StringList &lInput, StringList &lOutput ) |
15 | { | 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 | |||
62 | Function *FunctionCommandToList::duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) | ||
63 | { | ||
64 | Function *pRet = new FunctionCommandToList(); | ||
65 | pRet->copyData( this, bld, cont, mExtra ); | ||
66 | return pRet; | ||
16 | } | 67 | } |
17 | 68 | ||
diff --git a/src/functioncommandtolist.h b/src/functioncommandtolist.h index 176e40f..c74ce29 100644 --- a/src/functioncommandtolist.h +++ b/src/functioncommandtolist.h | |||
@@ -11,7 +11,8 @@ public: | |||
11 | FunctionCommandToList(); | 11 | FunctionCommandToList(); |
12 | virtual ~FunctionCommandToList(); | 12 | virtual ~FunctionCommandToList(); |
13 | 13 | ||
14 | virtual void execute( const StringList &lInput, StringList &lOutput ); | 14 | virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); |
15 | virtual Function *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ); | ||
15 | 16 | ||
16 | private: | 17 | private: |
17 | 18 | ||
diff --git a/src/functiondirectoriesin.cpp b/src/functiondirectoriesin.cpp index 9452489..0e90dbc 100644 --- a/src/functiondirectoriesin.cpp +++ b/src/functiondirectoriesin.cpp | |||
@@ -11,7 +11,14 @@ FunctionDirectoriesIn::~FunctionDirectoriesIn() | |||
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
14 | void FunctionDirectoriesIn::execute( const StringList &lInput, StringList &lOutput ) | 14 | void FunctionDirectoriesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput ) |
15 | { | 15 | { |
16 | } | 16 | } |
17 | 17 | ||
18 | Function *FunctionDirectoriesIn::duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) | ||
19 | { | ||
20 | Function *pRet = new FunctionDirectoriesIn(); | ||
21 | pRet->copyData( this, bld, cont, mExtra ); | ||
22 | return pRet; | ||
23 | } | ||
24 | |||
diff --git a/src/functiondirectoriesin.h b/src/functiondirectoriesin.h index ba1b2e4..c387577 100644 --- a/src/functiondirectoriesin.h +++ b/src/functiondirectoriesin.h | |||
@@ -11,7 +11,8 @@ public: | |||
11 | FunctionDirectoriesIn(); | 11 | FunctionDirectoriesIn(); |
12 | virtual ~FunctionDirectoriesIn(); | 12 | virtual ~FunctionDirectoriesIn(); |
13 | 13 | ||
14 | virtual void execute( const StringList &lInput, StringList &lOutput ); | 14 | virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); |
15 | virtual Function *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ); | ||
15 | 16 | ||
16 | private: | 17 | private: |
17 | 18 | ||
diff --git a/src/functionfilesin.cpp b/src/functionfilesin.cpp index 3e1233a..e3d8e92 100644 --- a/src/functionfilesin.cpp +++ b/src/functionfilesin.cpp | |||
@@ -14,7 +14,7 @@ FunctionFilesIn::~FunctionFilesIn() | |||
14 | { | 14 | { |
15 | } | 15 | } |
16 | 16 | ||
17 | void FunctionFilesIn::execute( const StringList &lInput, StringList &lOutput ) | 17 | void FunctionFilesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput ) |
18 | { | 18 | { |
19 | DIR *d = opendir( lParams.front().c_str() ); | 19 | DIR *d = opendir( lParams.front().c_str() ); |
20 | if( d == NULL ) | 20 | if( d == NULL ) |
@@ -38,3 +38,10 @@ void FunctionFilesIn::execute( const StringList &lInput, StringList &lOutput ) | |||
38 | closedir( d ); | 38 | closedir( d ); |
39 | } | 39 | } |
40 | 40 | ||
41 | Function *FunctionFilesIn::duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) | ||
42 | { | ||
43 | Function *pRet = new FunctionFilesIn(); | ||
44 | pRet->copyData( this, bld, cont, mExtra ); | ||
45 | return pRet; | ||
46 | } | ||
47 | |||
diff --git a/src/functionfilesin.h b/src/functionfilesin.h index b660301..dc504b9 100644 --- a/src/functionfilesin.h +++ b/src/functionfilesin.h | |||
@@ -11,7 +11,8 @@ public: | |||
11 | FunctionFilesIn(); | 11 | FunctionFilesIn(); |
12 | virtual ~FunctionFilesIn(); | 12 | virtual ~FunctionFilesIn(); |
13 | 13 | ||
14 | virtual void execute( const StringList &lInput, StringList &lOutput ); | 14 | virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); |
15 | virtual Function *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ); | ||
15 | 16 | ||
16 | private: | 17 | private: |
17 | 18 | ||
diff --git a/src/functionregexp.cpp b/src/functionregexp.cpp index d1491e6..57a1725 100644 --- a/src/functionregexp.cpp +++ b/src/functionregexp.cpp | |||
@@ -12,7 +12,7 @@ FunctionRegexp::~FunctionRegexp() | |||
12 | { | 12 | { |
13 | } | 13 | } |
14 | 14 | ||
15 | void FunctionRegexp::execute( const StringList &lInput, StringList &lOutput ) | 15 | void FunctionRegexp::execute( Build *bld, const StringList &lInput, StringList &lOutput ) |
16 | { | 16 | { |
17 | if( lParams.size() == 1 ) | 17 | if( lParams.size() == 1 ) |
18 | { | 18 | { |
@@ -24,6 +24,16 @@ void FunctionRegexp::execute( const StringList &lInput, StringList &lOutput ) | |||
24 | if( re.execute( (*i).c_str() ) ) | 24 | if( re.execute( (*i).c_str() ) ) |
25 | { | 25 | { |
26 | lOutput.push_back( *i ); | 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 | } | ||
27 | } | 37 | } |
28 | } | 38 | } |
29 | } | 39 | } |
@@ -32,3 +42,10 @@ void FunctionRegexp::execute( const StringList &lInput, StringList &lOutput ) | |||
32 | } | 42 | } |
33 | } | 43 | } |
34 | 44 | ||
45 | Function *FunctionRegexp::duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) | ||
46 | { | ||
47 | Function *pRet = new FunctionRegexp(); | ||
48 | pRet->copyData( this, bld, cont, mExtra ); | ||
49 | return pRet; | ||
50 | } | ||
51 | |||
diff --git a/src/functionregexp.h b/src/functionregexp.h index 9fa2eb4..1dfd91e 100644 --- a/src/functionregexp.h +++ b/src/functionregexp.h | |||
@@ -11,7 +11,8 @@ public: | |||
11 | FunctionRegexp(); | 11 | FunctionRegexp(); |
12 | virtual ~FunctionRegexp(); | 12 | virtual ~FunctionRegexp(); |
13 | 13 | ||
14 | virtual void execute( const StringList &lInput, StringList &lOutput ); | 14 | virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); |
15 | virtual Function *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ); | ||
15 | 16 | ||
16 | private: | 17 | private: |
17 | 18 | ||
diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp index a76705a..0a7bb48 100644 --- a/src/functiontostring.cpp +++ b/src/functiontostring.cpp | |||
@@ -11,7 +11,23 @@ FunctionToString::~FunctionToString() | |||
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
14 | void FunctionToString::execute( const StringList &lInput, StringList &lOutput ) | 14 | void FunctionToString::execute( Build *bld, const StringList &lInput, StringList &lOutput ) |
15 | { | 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 | |||
27 | Function *FunctionToString::duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) | ||
28 | { | ||
29 | Function *pRet = new FunctionToString(); | ||
30 | pRet->copyData( this, bld, cont, mExtra ); | ||
31 | return pRet; | ||
16 | } | 32 | } |
17 | 33 | ||
diff --git a/src/functiontostring.h b/src/functiontostring.h index 5e64256..4779712 100644 --- a/src/functiontostring.h +++ b/src/functiontostring.h | |||
@@ -11,7 +11,8 @@ public: | |||
11 | FunctionToString(); | 11 | FunctionToString(); |
12 | virtual ~FunctionToString(); | 12 | virtual ~FunctionToString(); |
13 | 13 | ||
14 | virtual void execute( const StringList &lInput, StringList &lOutput ); | 14 | virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); |
15 | virtual Function *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ); | ||
15 | 16 | ||
16 | private: | 17 | private: |
17 | 18 | ||
diff --git a/src/main.cpp b/src/main.cpp index 02cb9d6..9106a74 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -91,8 +91,6 @@ int main( int argc, char *argv[] ) | |||
91 | // printf("\n\n----------\nDebug dump\n----------\n"); | 91 | // printf("\n\n----------\nDebug dump\n----------\n"); |
92 | // bld.debugDump(); | 92 | // bld.debugDump(); |
93 | //} | 93 | //} |
94 | // printf("\n\n----------\nDebug dump\n----------\n"); | ||
95 | // pBuild->debugDump(); | ||
96 | //else | 94 | //else |
97 | { | 95 | { |
98 | if( prm.sAction > 0 ) | 96 | if( prm.sAction > 0 ) |
@@ -100,6 +98,8 @@ int main( int argc, char *argv[] ) | |||
100 | else | 98 | else |
101 | pBuild->execAction(""); | 99 | pBuild->execAction(""); |
102 | } | 100 | } |
101 | //printf("\n\n----------\nDebug dump\n----------\n"); | ||
102 | //pBuild->debugDump(); | ||
103 | 103 | ||
104 | delete pBuild; | 104 | delete pBuild; |
105 | } | 105 | } |
diff --git a/src/perform.h b/src/perform.h index 93c8b9a..ea8d5e3 100644 --- a/src/perform.h +++ b/src/perform.h | |||
@@ -17,7 +17,8 @@ public: | |||
17 | virtual ~Perform(); | 17 | virtual ~Perform(); |
18 | 18 | ||
19 | void addParam( const char *sParam ); | 19 | void addParam( const char *sParam ); |
20 | virtual Perform *duplicate( Build &bld, const std::string &cont ) = 0; | 20 | virtual Perform *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) = 0; |
21 | virtual void execute( Build &bld ) = 0; | ||
21 | void copyData( Perform *pSrc, Build &bld, const std::string &cont, VarMap *mExtra ); | 22 | void copyData( Perform *pSrc, Build &bld, const std::string &cont, VarMap *mExtra ); |
22 | std::string getTarget() | 23 | std::string getTarget() |
23 | { | 24 | { |
@@ -28,9 +29,26 @@ public: | |||
28 | this->sTarget = sTarget; | 29 | this->sTarget = sTarget; |
29 | } | 30 | } |
30 | 31 | ||
31 | private: | 32 | std::list<class Function *> &getReqFuncs() |
33 | { | ||
34 | return lReqFuncs; | ||
35 | } | ||
36 | |||
37 | void setRule( const std::string &sRule ) | ||
38 | { | ||
39 | this->sRule = sRule; | ||
40 | } | ||
41 | |||
42 | std::string &getRule() | ||
43 | { | ||
44 | return sRule; | ||
45 | } | ||
46 | |||
47 | protected: | ||
32 | std::list<std::string> lParam; | 48 | std::list<std::string> lParam; |
33 | std::string sTarget; | 49 | std::string sTarget; |
50 | std::string sRule; | ||
51 | std::list<class Function *> lReqFuncs; | ||
34 | }; | 52 | }; |
35 | 53 | ||
36 | #endif | 54 | #endif |
diff --git a/src/performcommand.cpp b/src/performcommand.cpp index 6963022..f6da4ac 100644 --- a/src/performcommand.cpp +++ b/src/performcommand.cpp | |||
@@ -11,10 +11,15 @@ PerformCommand::~PerformCommand() | |||
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
14 | Perform *PerformCommand::duplicate( Build &bld, const std::string &cont ) | 14 | Perform *PerformCommand::duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) |
15 | { | 15 | { |
16 | Perform *pRet = new PerformCommand(); | 16 | Perform *pRet = new PerformCommand(); |
17 | pRet->copyData( this, bld, cont, NULL ); | 17 | pRet->copyData( this, bld, cont, mExtra ); |
18 | return pRet; | 18 | return pRet; |
19 | } | 19 | } |
20 | 20 | ||
21 | void PerformCommand::execute( Build &bld ) | ||
22 | { | ||
23 | system( lParam.front().c_str() ); | ||
24 | } | ||
25 | |||
diff --git a/src/performcommand.h b/src/performcommand.h index b6f7f11..d128845 100644 --- a/src/performcommand.h +++ b/src/performcommand.h | |||
@@ -11,7 +11,8 @@ public: | |||
11 | PerformCommand(); | 11 | PerformCommand(); |
12 | virtual ~PerformCommand(); | 12 | virtual ~PerformCommand(); |
13 | 13 | ||
14 | virtual Perform *duplicate( Build &bld, const std::string &cont ); | 14 | virtual Perform *duplicate( Build &bld, const std::string &cont, VarMap *mExtra ); |
15 | virtual void execute( Build &bld ); | ||
15 | 16 | ||
16 | private: | 17 | private: |
17 | 18 | ||
diff --git a/src/rule.cpp b/src/rule.cpp index 4919eef..c5ed1c2 100644 --- a/src/rule.cpp +++ b/src/rule.cpp | |||
@@ -1,6 +1,10 @@ | |||
1 | #include "rule.h" | 1 | #include "rule.h" |
2 | #include "build.h" | ||
3 | #include "function.h" | ||
4 | #include "perform.h" | ||
2 | 5 | ||
3 | Rule::Rule() | 6 | Rule::Rule() : |
7 | pAggregate( NULL ) | ||
4 | { | 8 | { |
5 | } | 9 | } |
6 | 10 | ||
@@ -12,6 +16,112 @@ StringList Rule::execute( Build &bld, StringList &lInput, PerformList &lPerf ) | |||
12 | { | 16 | { |
13 | StringList lOutput; | 17 | StringList lOutput; |
14 | 18 | ||
19 | RuleList rl = bld.findChainRules( this ); | ||
20 | |||
21 | for( RuleList::iterator i = rl.begin(); i != rl.end(); i++ ) | ||
22 | { | ||
23 | StringList tmp = (*i)->execute( bld, lInput, lPerf ); | ||
24 | lOutput.insert( lOutput.end(), tmp.begin(), tmp.end() ); | ||
25 | } | ||
26 | |||
27 | StringList lMine; | ||
28 | for( FunctionList::iterator i = lMatches.begin(); i != lMatches.end(); i++ ) | ||
29 | { | ||
30 | (*i)->execute( &bld, lInput, lMine ); | ||
31 | } | ||
32 | |||
33 | StringList lTmp; | ||
34 | for( FunctionList::iterator i = lFilter.begin(); i != lFilter.end(); i++ ) | ||
35 | { | ||
36 | (*i)->execute( &bld, lMine, lTmp ); | ||
37 | lMine.swap( lTmp ); | ||
38 | lTmp.clear(); | ||
39 | } | ||
40 | |||
41 | bool bHasProduces = true; | ||
42 | if( lProduces.empty() ) | ||
43 | { | ||
44 | bHasProduces = false; | ||
45 | lProduces.push_back( sTarget ); | ||
46 | } | ||
47 | |||
48 | StringList lNewOut; | ||
49 | if( pAggregate ) | ||
50 | { | ||
51 | VarMap mTmp; | ||
52 | std::string target = lProduces.front();//, lProduces.front(), NULL ).c_str(); | ||
53 | mTmp["target"] = target; | ||
54 | lNewOut.push_back( target ); | ||
55 | |||
56 | for( StringList::iterator i = lMine.begin(); i != lMine.end(); i++ ) | ||
57 | { | ||
58 | bld.addRequires( target, (*i) ); | ||
59 | } | ||
60 | for( StringList::iterator i = lReqStrs.begin(); | ||
61 | i != lReqStrs.end(); i++ ) | ||
62 | { | ||
63 | bld.addRequires( target, (*i) ); | ||
64 | } | ||
65 | |||
66 | StringList lTmp; | ||
67 | pAggregate->execute( &bld, lMine, lTmp ); | ||
68 | mTmp["match"] = lTmp.front(); | ||
69 | |||
70 | for( PerformList::iterator k = lPerform.begin(); | ||
71 | k != lPerform.end(); k++ ) | ||
72 | { | ||
73 | Perform *p = (*k)->duplicate( bld, target, &mTmp ); | ||
74 | p->setTarget( target ); | ||
75 | p->setRule( sName ); | ||
76 | //p->setReqFuncs( &lReqFuncs ); | ||
77 | lPerf.push_back( p ); | ||
78 | } | ||
79 | } | ||
80 | else | ||
81 | { | ||
82 | for( StringList::iterator i = lMine.begin(); i != lMine.end(); i++ ) | ||
83 | { | ||
84 | for( StringList::iterator j = lProduces.begin(); | ||
85 | j != lProduces.end(); j++ ) | ||
86 | { | ||
87 | VarMap mTmp; | ||
88 | std::string target = bld.replVars( (*j), (*i), NULL ); | ||
89 | mTmp["target"] = target; | ||
90 | lNewOut.push_back( target ); | ||
91 | mTmp["match"] = (*i); | ||
92 | bld.addRequires( target, (*i) ); | ||
93 | for( StringList::iterator k = lReqStrs.begin(); | ||
94 | k != lReqStrs.end(); k++ ) | ||
95 | { | ||
96 | bld.addRequires( target, (*k) ); | ||
97 | } | ||
98 | for( PerformList::iterator k = lPerform.begin(); | ||
99 | k != lPerform.end(); k++ ) | ||
100 | { | ||
101 | Perform *p = (*k)->duplicate( bld, (*i), &mTmp ); | ||
102 | p->setTarget( target ); | ||
103 | p->setRule( sName ); | ||
104 | for( FunctionList::iterator f = lReqFuncs.begin(); | ||
105 | f != lReqFuncs.end(); f++ ) | ||
106 | { | ||
107 | p->getReqFuncs().push_back( | ||
108 | (*f)->duplicate( bld, (*i), &mTmp ) | ||
109 | ); | ||
110 | } | ||
111 | lPerf.push_back( p ); | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | lInput.insert( lInput.end(), lNewOut.begin(), lNewOut.end() ); | ||
118 | lOutput.insert( lOutput.end(), lNewOut.begin(), lNewOut.end() ); | ||
119 | |||
120 | if( bHasProduces == false ) | ||
121 | { | ||
122 | lProduces.clear(); | ||
123 | } | ||
124 | |||
15 | return lOutput; | 125 | return lOutput; |
16 | } | 126 | } |
17 | 127 | ||
@@ -21,6 +21,11 @@ public: | |||
21 | 21 | ||
22 | StringList execute( Build &bld, StringList &lInput, PerformList &lPerf ); | 22 | StringList execute( Build &bld, StringList &lInput, PerformList &lPerf ); |
23 | 23 | ||
24 | void setTarget( const std::string &sTarget ) | ||
25 | { | ||
26 | this->sTarget = sTarget; | ||
27 | } | ||
28 | |||
24 | std::string getName() | 29 | std::string getName() |
25 | { | 30 | { |
26 | return sName; | 31 | return sName; |
@@ -46,11 +51,36 @@ public: | |||
46 | return lMatches; | 51 | return lMatches; |
47 | } | 52 | } |
48 | 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 | |||
49 | private: | 74 | private: |
50 | std::string sName; | 75 | std::string sName; |
51 | FunctionList lMatches; | 76 | FunctionList lMatches; |
52 | FunctionList lFilter; | 77 | FunctionList lFilter; |
53 | PerformList lPerform; | 78 | PerformList lPerform; |
79 | StringList lProduces; | ||
80 | std::string sTarget; | ||
81 | Function *pAggregate; | ||
82 | StringList lReqStrs; | ||
83 | FunctionList lReqFuncs; | ||
54 | }; | 84 | }; |
55 | 85 | ||
56 | #endif | 86 | #endif |
diff --git a/src/targetfile.cpp b/src/targetfile.cpp index dc9e597..0299f9d 100644 --- a/src/targetfile.cpp +++ b/src/targetfile.cpp | |||
@@ -2,6 +2,9 @@ | |||
2 | #include "plugger.h" | 2 | #include "plugger.h" |
3 | #include "rule.h" | 3 | #include "rule.h" |
4 | #include "build.h" | 4 | #include "build.h" |
5 | #include "perform.h" | ||
6 | #include "function.h" | ||
7 | #include "viewer.h" | ||
5 | 8 | ||
6 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); | 9 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); |
7 | 10 | ||
@@ -15,26 +18,43 @@ TargetFile::~TargetFile() | |||
15 | 18 | ||
16 | void TargetFile::check( Build &bld ) | 19 | void TargetFile::check( Build &bld ) |
17 | { | 20 | { |
18 | printf("Target file checking: %s\n", getName().c_str() ); | ||
19 | |||
20 | Rule *pRule = bld.getRule( getRule() ); | 21 | Rule *pRule = bld.getRule( getRule() ); |
21 | PerformList lPerf; | 22 | PerformList lPerf; |
23 | pRule->setTarget( getName() ); | ||
22 | StringList lFinal = pRule->execute( bld, getInput(), lPerf ); | 24 | StringList lFinal = pRule->execute( bld, getInput(), lPerf ); |
23 | 25 | ||
24 | printf("Input: "); | 26 | for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ ) |
25 | for( StringList::iterator i = getInput().begin(); | ||
26 | i != getInput().end(); i++ ) | ||
27 | { | ||
28 | if( i != getInput().begin() ) printf(", "); | ||
29 | printf("%s", (*i).c_str() ); | ||
30 | } | ||
31 | printf("\nFinal: "); | ||
32 | for( StringList::iterator i = lFinal.begin(); i != lFinal.end(); i++ ) | ||
33 | { | 27 | { |
34 | if( i != lFinal.begin() ) printf(", "); | 28 | time_t tTarget = getTime( bld, (*i)->getTarget() ); |
35 | printf("%s", (*i).c_str() ); | 29 | StringList &reqs = bld.getRequires( (*i)->getTarget() ); |
30 | FunctionList::iterator f = (*i)->getReqFuncs().begin(); | ||
31 | bool bBuilt = false; | ||
32 | aastrt: for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ ) | ||
33 | { | ||
34 | if( getTime( bld, *j ) > tTarget ) | ||
35 | { | ||
36 | bld.getView()->beginPerform( *i ); | ||
37 | (*i)->execute( bld ); | ||
38 | bld.getView()->endPerform(); | ||
39 | updateTime( (*i)->getTarget() ); | ||
40 | bBuilt = true; | ||
41 | break; | ||
42 | } | ||
43 | } | ||
44 | if( bBuilt == true ) | ||
45 | continue; | ||
46 | |||
47 | if( f != (*i)->getReqFuncs().end() ) | ||
48 | { | ||
49 | StringList lTmpIn; | ||
50 | lTmpIn.push_back( (*i)->getTarget() ); | ||
51 | bld.getView()->beginRequiresCheck( false, (*i)->getTarget() ); | ||
52 | (*f)->execute( &bld, lTmpIn, reqs ); | ||
53 | bld.getView()->endRequiresCheck(); | ||
54 | f++; | ||
55 | goto aastrt; | ||
56 | } | ||
36 | } | 57 | } |
37 | printf("\n"); | ||
38 | } | 58 | } |
39 | 59 | ||
40 | void TargetFile::clean( Build &bld ) | 60 | void TargetFile::clean( Build &bld ) |
@@ -42,3 +62,35 @@ void TargetFile::clean( Build &bld ) | |||
42 | printf("Target file cleaning: %s\n", getName().c_str() ); | 62 | printf("Target file cleaning: %s\n", getName().c_str() ); |
43 | } | 63 | } |
44 | 64 | ||
65 | time_t TargetFile::getTime( Build &bld, std::string str ) | ||
66 | { | ||
67 | std::map<std::string, time_t>::iterator i = mTimes.find( str ); | ||
68 | if( i != mTimes.end() ) | ||
69 | { | ||
70 | //nCache++; | ||
71 | //bld.view().beginRequiresCheck( true, str.c_str() ); | ||
72 | //bld.view().endRequiresCheck(); | ||
73 | return (*i).second; | ||
74 | } | ||
75 | |||
76 | //bld.view().beginRequiresCheck( false, str.c_str() ); | ||
77 | struct stat st; | ||
78 | stat( str.c_str(), &st ); | ||
79 | |||
80 | mTimes[str] = st.st_mtime; | ||
81 | |||
82 | //nNew++; | ||
83 | |||
84 | //bld.view().endRequiresCheck(); | ||
85 | |||
86 | return st.st_mtime; | ||
87 | } | ||
88 | |||
89 | void TargetFile::updateTime( std::string str ) | ||
90 | { | ||
91 | struct stat st; | ||
92 | stat( str.c_str(), &st ); | ||
93 | |||
94 | mTimes[str] = st.st_mtime; | ||
95 | } | ||
96 | |||
diff --git a/src/targetfile.h b/src/targetfile.h index 37e6770..368e252 100644 --- a/src/targetfile.h +++ b/src/targetfile.h | |||
@@ -2,6 +2,10 @@ | |||
2 | #define TARGET_FILE_H | 2 | #define TARGET_FILE_H |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <map> | ||
6 | #include <sys/types.h> | ||
7 | #include <sys/stat.h> | ||
8 | #include <unistd.h> | ||
5 | 9 | ||
6 | #include "target.h" | 10 | #include "target.h" |
7 | 11 | ||
@@ -14,8 +18,11 @@ public: | |||
14 | virtual void check( Build &bld ); | 18 | virtual void check( Build &bld ); |
15 | virtual void clean( Build &bld ); | 19 | virtual void clean( Build &bld ); |
16 | 20 | ||
17 | private: | 21 | time_t getTime( class Build &bld, std::string str ); |
22 | void updateTime( std::string str ); | ||
18 | 23 | ||
24 | private: | ||
25 | std::map<std::string, time_t> mTimes; | ||
19 | }; | 26 | }; |
20 | 27 | ||
21 | #endif | 28 | #endif |
diff --git a/src/viewer.cpp b/src/viewer.cpp index 93b2ac1..51acc3b 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp | |||
@@ -7,3 +7,48 @@ Viewer::Viewer() | |||
7 | Viewer::~Viewer() | 7 | Viewer::~Viewer() |
8 | { | 8 | { |
9 | } | 9 | } |
10 | |||
11 | void Viewer::beginAction( const std::string &sName, int nCommands ) | ||
12 | { | ||
13 | } | ||
14 | |||
15 | void Viewer::endAction() | ||
16 | { | ||
17 | } | ||
18 | |||
19 | void Viewer::beginCommand( Action::eAction nAct, const std::string &sTarget, int nPerforms ) | ||
20 | { | ||
21 | } | ||
22 | |||
23 | void Viewer::endCommand() | ||
24 | { | ||
25 | } | ||
26 | |||
27 | void Viewer::beginRequiresCheck( bool bCached, const std::string &sName ) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | void Viewer::endRequiresCheck() | ||
32 | { | ||
33 | } | ||
34 | |||
35 | void Viewer::beginPerform( Perform *pPerform ) | ||
36 | { | ||
37 | } | ||
38 | |||
39 | void Viewer::endPerform() | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void Viewer::beginExecute() | ||
44 | { | ||
45 | } | ||
46 | |||
47 | void Viewer::endExecute() | ||
48 | { | ||
49 | } | ||
50 | |||
51 | void Viewer::executeCmd( const std::string &sCmd ) | ||
52 | { | ||
53 | } | ||
54 | |||
diff --git a/src/viewer.h b/src/viewer.h index 04f4ea7..93cebb7 100644 --- a/src/viewer.h +++ b/src/viewer.h | |||
@@ -2,7 +2,10 @@ | |||
2 | #define VIEWER_H | 2 | #define VIEWER_H |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <string> | ||
6 | #include "action.h" | ||
5 | 7 | ||
8 | class Perform; | ||
6 | 9 | ||
7 | class Viewer | 10 | class Viewer |
8 | { | 11 | { |
@@ -10,6 +13,20 @@ public: | |||
10 | Viewer(); | 13 | Viewer(); |
11 | virtual ~Viewer(); | 14 | virtual ~Viewer(); |
12 | 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, int nPerforms ); | ||
20 | virtual void endCommand(); | ||
21 | |||
22 | virtual void beginRequiresCheck( bool bCached, const std::string &sName ); | ||
23 | virtual void endRequiresCheck(); | ||
24 | virtual void beginPerform( Perform *pPerform ); | ||
25 | virtual void endPerform(); | ||
26 | virtual void beginExecute(); | ||
27 | virtual void endExecute(); | ||
28 | virtual void executeCmd( const std::string &sCmd ); | ||
29 | |||
13 | private: | 30 | private: |
14 | 31 | ||
15 | }; | 32 | }; |
diff --git a/src/viewerfactory.cpp b/src/viewerfactory.cpp new file mode 100644 index 0000000..3778c37 --- /dev/null +++ b/src/viewerfactory.cpp | |||
@@ -0,0 +1,12 @@ | |||
1 | #include "viewerfactory.h" | ||
2 | |||
3 | extern struct PluginInfo plain; | ||
4 | |||
5 | ViewerFactory::ViewerFactory() | ||
6 | { | ||
7 | registerBuiltinPlugin( &plain ); | ||
8 | } | ||
9 | |||
10 | ViewerFactory::~ViewerFactory() | ||
11 | { | ||
12 | } | ||
diff --git a/src/viewerfactory.h b/src/viewerfactory.h new file mode 100644 index 0000000..8704e03 --- /dev/null +++ b/src/viewerfactory.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef VIEWER_FACTORY_H | ||
2 | #define VIEWER_FACTORY_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | #include "viewer.h" | ||
7 | #include "plugger.h" | ||
8 | #include "singleton.h" | ||
9 | |||
10 | class ViewerFactory : public Plugger<Viewer>, public Singleton<ViewerFactory> | ||
11 | { | ||
12 | public: | ||
13 | ViewerFactory(); | ||
14 | virtual ~ViewerFactory(); | ||
15 | |||
16 | private: | ||
17 | |||
18 | }; | ||
19 | |||
20 | #endif | ||
diff --git a/src/viewerplain.cpp b/src/viewerplain.cpp new file mode 100644 index 0000000..f2123b0 --- /dev/null +++ b/src/viewerplain.cpp | |||
@@ -0,0 +1,42 @@ | |||
1 | #include "viewerplain.h" | ||
2 | #include "perform.h" | ||
3 | #include "plugger.h" | ||
4 | |||
5 | PluginInterface2( plain, ViewerPlain, Viewer, "Mike Buland", 0, 1 ); | ||
6 | |||
7 | ViewerPlain::ViewerPlain() | ||
8 | { | ||
9 | } | ||
10 | |||
11 | ViewerPlain::~ViewerPlain() | ||
12 | { | ||
13 | } | ||
14 | |||
15 | void ViewerPlain::beginCommand( Action::eAction nAct, const std::string &sTarget, int nPerforms ) | ||
16 | { | ||
17 | printf("--- check %s ---\n", sTarget.c_str() ); | ||
18 | } | ||
19 | |||
20 | void ViewerPlain::endCommand() | ||
21 | { | ||
22 | printf("---\n"); | ||
23 | } | ||
24 | |||
25 | void ViewerPlain::beginRequiresCheck( bool bCached, const std::string &sName ) | ||
26 | { | ||
27 | printf(" deps: %s\n", sName.c_str() ); | ||
28 | } | ||
29 | |||
30 | void ViewerPlain::endRequiresCheck() | ||
31 | { | ||
32 | } | ||
33 | |||
34 | void ViewerPlain::beginPerform( Perform *pPerform ) | ||
35 | { | ||
36 | printf(" %8s: %s\n", pPerform->getRule().c_str(), pPerform->getTarget().c_str() ); | ||
37 | } | ||
38 | |||
39 | void ViewerPlain::endPerform() | ||
40 | { | ||
41 | } | ||
42 | |||
diff --git a/src/viewerplain.h b/src/viewerplain.h new file mode 100644 index 0000000..6e37c28 --- /dev/null +++ b/src/viewerplain.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef VIEWER_PLAIN_H | ||
2 | #define VIEWER_PLAIN_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | #include "viewer.h" | ||
7 | |||
8 | class ViewerPlain : public Viewer | ||
9 | { | ||
10 | public: | ||
11 | ViewerPlain(); | ||
12 | virtual ~ViewerPlain(); | ||
13 | |||
14 | virtual void beginCommand( Action::eAction nAct, const std::string &sTarget, int nPerforms ); | ||
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 | private: | ||
23 | |||
24 | }; | ||
25 | |||
26 | #endif | ||