1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#include "targetfile.h"
#include "plugger.h"
#include "rule.h"
#include "build.h"
#include "perform.h"
#include "function.h"
#include "viewer.h"
PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 );
TargetFile::TargetFile()
{
}
TargetFile::~TargetFile()
{
}
void TargetFile::check( Build &bld )
{
Rule *pRule = bld.getRule( getRule() );
PerformList lPerf;
pRule->setTarget( getName() );
StringList lFinal = pRule->execute( bld, getInput(), lPerf );
bld.getView()->beginPerforms( lPerf.size() );
for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ )
{
StringList &reqs = bld.getRequires( (*i)->getTarget() );
for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ )
{
bld.chainTarget( *j );
}
}
for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ )
{
time_t tTarget = getTime( bld, (*i)->getTarget() );
StringList &reqs = bld.getRequires( (*i)->getTarget() );
bool bExtras = false;
for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ )
{
//bld.chainTarget( *j );
if( getTime( bld, *j ) > tTarget )
{
bld.getView()->beginPerform( *i );
(*i)->execute( bld );
bld.getView()->endPerform();
updateTime( (*i)->getTarget() );
break;
}
if( bExtras == false )
{
StringList::iterator jj = j;
jj++;
if( jj == reqs.end() )
{
if( !bld.getCached( (*i)->getTarget(), tTarget, reqs ) )
{
bld.updateCache( (*i)->getTarget(), (*i)->getReqFuncs(), reqs );
}
bExtras = true;
}
}
}
}
bld.getView()->endPerforms();
}
void TargetFile::clean( Build &bld )
{
Rule *pRule = bld.getRule( getRule() );
PerformList lPerf;
pRule->setTarget( getName() );
StringList lFinal = pRule->execute( bld, getInput(), lPerf );
bld.getView()->beginPerforms( lPerf.size() );
for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ )
{
if( access( (*i)->getTarget().c_str(), W_OK ) == 0 )
{
(*i)->setRule("clean");
bld.getView()->beginPerform( *i );
unlink( (*i)->getTarget().c_str() );
bld.getView()->endPerform();
}
}
bld.getView()->endPerforms();
}
time_t TargetFile::getTime( Build &bld, std::string str )
{
std::map<std::string, time_t>::iterator i = mTimes.find( str );
if( i != mTimes.end() )
{
//nCache++;
//bld.view().beginRequiresCheck( true, str.c_str() );
//bld.view().endRequiresCheck();
return (*i).second;
}
//bld.view().beginRequiresCheck( false, str.c_str() );
struct stat st;
stat( str.c_str(), &st );
mTimes[str] = st.st_mtime;
//nNew++;
//bld.view().endRequiresCheck();
return st.st_mtime;
}
void TargetFile::updateTime( std::string str )
{
struct stat st;
stat( str.c_str(), &st );
mTimes[str] = st.st_mtime;
}
|