diff options
Diffstat (limited to '')
-rw-r--r-- | src/filetarget.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/filetarget.cpp b/src/filetarget.cpp index ca9a39f..e89cd5f 100644 --- a/src/filetarget.cpp +++ b/src/filetarget.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "rule.h" | 5 | #include "rule.h" |
6 | #include "filetarget.h" | 6 | #include "filetarget.h" |
7 | #include "builder.h" // for BuildException | 7 | #include "builder.h" // for BuildException |
8 | #include "viewer.h" | ||
8 | 9 | ||
9 | FileTarget::FileTarget( const char *sName ) : | 10 | FileTarget::FileTarget( const char *sName ) : |
10 | Target( sName ) | 11 | Target( sName ) |
@@ -67,25 +68,27 @@ void FileTarget::addInputDir( const char *sDir ) | |||
67 | closedir( dir ); | 68 | closedir( dir ); |
68 | } | 69 | } |
69 | 70 | ||
70 | int nNew, nCache; | 71 | //int nNew, nCache; |
71 | 72 | ||
72 | void FileTarget::check( Builder &bld ) | 73 | void FileTarget::check( Builder &bld ) |
73 | { | 74 | { |
74 | printf("--- %s ---\n", getName() ); | 75 | //nNew = nCache = 0; |
75 | nNew = nCache = 0; | ||
76 | Rule *pRule = bld.getRule( sRule ); | 76 | Rule *pRule = bld.getRule( sRule ); |
77 | 77 | ||
78 | std::list<Perform *> perf; | 78 | std::list<Perform *> perf; |
79 | std::list<std::string> tmp = pRule->execute( bld, lInput, perf, getName() ); | 79 | std::list<std::string> tmp = pRule->execute( bld, lInput, perf, getName() ); |
80 | lOutput.insert( lOutput.end(), tmp.begin(), tmp.end() ); | 80 | lOutput.insert( lOutput.end(), tmp.begin(), tmp.end() ); |
81 | |||
82 | bld.view().beginTarget( getName(), "file", "check", lOutput.size() ); | ||
81 | 83 | ||
82 | bld.processRequires( lOutput ); | 84 | bld.processRequires( lOutput ); |
83 | 85 | ||
84 | for( std::list<Perform *>::iterator i = perf.begin(); | 86 | for( std::list<Perform *>::iterator i = perf.begin(); |
85 | i != perf.end(); i++ ) | 87 | i != perf.end(); i++ ) |
86 | { | 88 | { |
89 | bld.view().beginPerform( *i ); | ||
87 | bool bExtraReqs = false; | 90 | bool bExtraReqs = false; |
88 | time_t target = getTime( std::string((*i)->getTarget()) ); | 91 | time_t target = getTime( bld, std::string((*i)->getTarget()) ); |
89 | std::list<std::string> *lReqs = bld.getRequires( (*i)->getTarget() ); | 92 | std::list<std::string> *lReqs = bld.getRequires( (*i)->getTarget() ); |
90 | if( lReqs == NULL ) | 93 | if( lReqs == NULL ) |
91 | { | 94 | { |
@@ -95,10 +98,12 @@ void FileTarget::check( Builder &bld ) | |||
95 | for( std::list<std::string>::iterator j = lReqs->begin(); | 98 | for( std::list<std::string>::iterator j = lReqs->begin(); |
96 | j != lReqs->end(); j++ ) | 99 | j != lReqs->end(); j++ ) |
97 | { | 100 | { |
98 | if( getTime( *j ) > target ) | 101 | if( getTime( bld, *j ) > target ) |
99 | { | 102 | { |
103 | bld.view().beginExecute(); | ||
100 | (*i)->execute( bld ); | 104 | (*i)->execute( bld ); |
101 | updateTime( (*i)->getTarget() ); | 105 | updateTime( (*i)->getTarget() ); |
106 | bld.view().endExecute(); | ||
102 | break; | 107 | break; |
103 | } | 108 | } |
104 | if( bExtraReqs == false ) | 109 | if( bExtraReqs == false ) |
@@ -112,9 +117,12 @@ void FileTarget::check( Builder &bld ) | |||
112 | } | 117 | } |
113 | } | 118 | } |
114 | } | 119 | } |
120 | bld.view().endPerform(); | ||
115 | } | 121 | } |
116 | 122 | ||
117 | printf("Cache hits %d, %d new (%f%%)\n", nCache, nNew, nCache/ (double)(nNew+nCache)*100.0 ); | 123 | //printf("Cache hits %d, %d new (%f%%)\n", nCache, nNew, nCache/ (double)(nNew+nCache)*100.0 ); |
124 | |||
125 | bld.view().endTarget(); | ||
118 | } | 126 | } |
119 | 127 | ||
120 | void FileTarget::clean( Builder &bld ) | 128 | void FileTarget::clean( Builder &bld ) |
@@ -132,21 +140,26 @@ void FileTarget::clean( Builder &bld ) | |||
132 | } | 140 | } |
133 | } | 141 | } |
134 | 142 | ||
135 | time_t FileTarget::getTime( std::string str ) | 143 | time_t FileTarget::getTime( Builder &bld, std::string str ) |
136 | { | 144 | { |
137 | std::map<std::string, time_t>::iterator i = mTimes.find( str ); | 145 | std::map<std::string, time_t>::iterator i = mTimes.find( str ); |
138 | if( i != mTimes.end() ) | 146 | if( i != mTimes.end() ) |
139 | { | 147 | { |
140 | nCache++; | 148 | //nCache++; |
149 | bld.view().beginRequiresCheck( true, str.c_str() ); | ||
150 | bld.view().endRequiresCheck(); | ||
141 | return (*i).second; | 151 | return (*i).second; |
142 | } | 152 | } |
143 | 153 | ||
154 | bld.view().beginRequiresCheck( false, str.c_str() ); | ||
144 | struct stat st; | 155 | struct stat st; |
145 | stat( str.c_str(), &st ); | 156 | stat( str.c_str(), &st ); |
146 | 157 | ||
147 | mTimes[str] = st.st_mtime; | 158 | mTimes[str] = st.st_mtime; |
148 | 159 | ||
149 | nNew++; | 160 | //nNew++; |
161 | |||
162 | bld.view().endRequiresCheck(); | ||
150 | 163 | ||
151 | return st.st_mtime; | 164 | return st.st_mtime; |
152 | } | 165 | } |