diff options
Diffstat (limited to 'src/targetfile.cpp')
-rw-r--r-- | src/targetfile.cpp | 158 |
1 files changed, 0 insertions, 158 deletions
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 | |||
11 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); | ||
12 | |||
13 | TargetFile::TargetFile() | ||
14 | { | ||
15 | } | ||
16 | |||
17 | TargetFile::~TargetFile() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | void 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 | { | ||
32 | isuck: 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 | |||
104 | void 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 | |||
127 | time_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 | |||
151 | void 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 | |||