aboutsummaryrefslogtreecommitdiff
path: root/src/rule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rule.cpp')
-rw-r--r--src/rule.cpp112
1 files changed, 111 insertions, 1 deletions
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
3Rule::Rule() 6Rule::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