diff options
Diffstat (limited to 'src/rule.cpp')
-rw-r--r-- | src/rule.cpp | 159 |
1 files changed, 0 insertions, 159 deletions
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 | |||
8 | Rule::Rule() : | ||
9 | pAggregate( NULL ) | ||
10 | { | ||
11 | } | ||
12 | |||
13 | Rule::~Rule() | ||
14 | { | ||
15 | } | ||
16 | |||
17 | StringList 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 | { | ||
55 | isuck: 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 | |||