| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CIPP::Compile::Cache; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use vars qw ( $VERSION ); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
41
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
44
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use File::Basename; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
61
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use File::Path; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1715
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = "0.01"; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub get_cache_status { |
|
13
|
0
|
|
|
0
|
0
|
|
my $type = shift; |
|
14
|
0
|
|
|
|
|
|
my %par = @_; |
|
15
|
0
|
|
|
|
|
|
my ($dep_file, $if_file) = @par{'dep_file','if_file'}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $DEBUG = 0; |
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $dirty = 'dirty'; |
|
20
|
0
|
|
|
|
|
|
my $cached_err = 'cached err'; |
|
21
|
0
|
|
|
|
|
|
my $clean = 'clean'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "\ndep_file=$dep_file ",(-f$dep_file?"exist":"missing"),"\n"; |
|
|
|
0
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "if_file=$if_file ",(-f$if_file?"exist":"missing"),"\n"; |
|
|
|
0
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
0
|
0
|
|
|
|
if ( not -f $dep_file or ($if_file and not -f $if_file) ) { |
|
|
|
|
0
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "no dep_file or not if_file\n"; |
|
28
|
0
|
|
|
|
|
|
return $dirty; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "dep_file exists\n"; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
open (IN, $dep_file) or confess "can't read $dep_file"; |
|
34
|
0
|
|
|
|
|
|
my $line = ; |
|
35
|
0
|
|
|
|
|
|
chomp $line; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my ($src_file, $cache_file, $err_file); |
|
38
|
0
|
|
|
|
|
|
($src_file, $cache_file, $err_file) = split(/\t/, $line); |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $src_file_mtime = (stat($src_file))[9]; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# check for cached error |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "err_file=$err_file\n"; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $has_cached_err = 0; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $err_file_mtime; |
|
49
|
0
|
0
|
|
|
|
|
if ( -f $err_file ) { |
|
50
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "err-file $err_file OLDER $src_file : "; |
|
51
|
0
|
|
|
|
|
|
$err_file_mtime = (stat($err_file))[9]; |
|
52
|
0
|
0
|
|
|
|
|
if ( $err_file_mtime < $src_file_mtime ) { |
|
53
|
|
|
|
|
|
|
# cache is dirty, if err_file is older than src_file |
|
54
|
0
|
|
|
|
|
|
close IN; |
|
55
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "YES\n"; |
|
56
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "Status: $dirty\n"; |
|
57
|
0
|
|
|
|
|
|
return $dirty; |
|
58
|
|
|
|
|
|
|
} else { |
|
59
|
|
|
|
|
|
|
# ok has cached err. beyond we check if any |
|
60
|
|
|
|
|
|
|
# includes interface file is newer than our cached |
|
61
|
|
|
|
|
|
|
# error. in this case the cache is dirty, because |
|
62
|
|
|
|
|
|
|
# the cached error may consist of a wrong interface |
|
63
|
|
|
|
|
|
|
# which was then corrected due to the interface |
|
64
|
|
|
|
|
|
|
# change of that include. |
|
65
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "CACHED ERR\n"; |
|
66
|
0
|
|
|
|
|
|
$has_cached_err = 1; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} else { |
|
69
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "no err file\n"; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "cache_file=$cache_file ",(-f$cache_file?"exist":"missing"),"\n"; |
|
|
|
0
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
|
if ( not -f $cache_file and not $has_cached_err ) { |
|
75
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "no cache file present and no cached err\n"; |
|
76
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "Status: $dirty\n"; |
|
77
|
0
|
|
|
|
|
|
return $dirty; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "$cache_file OLDER $src_file : "; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $cache_file_mtime = (stat($cache_file))[9]; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
0
|
|
|
|
if ( -f $cache_file and $cache_file_mtime < $src_file_mtime ) { |
|
85
|
|
|
|
|
|
|
# cache is dirty, if cache_file is older than src_file |
|
86
|
0
|
|
|
|
|
|
close IN; |
|
87
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "YES\n"; |
|
88
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "Status: $dirty\n"; |
|
89
|
0
|
|
|
|
|
|
return $dirty; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "NO\n"; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# now check include dependencies |
|
95
|
0
|
|
|
|
|
|
my $status = $clean; |
|
96
|
0
|
|
|
|
|
|
while () { |
|
97
|
0
|
|
|
|
|
|
chomp; |
|
98
|
0
|
|
|
|
|
|
($src_file, $cache_file, $if_file) = split (/\t/, $_); |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
if ( not -f $cache_file ) { |
|
101
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "cache_file doesn't exist\n"; |
|
102
|
0
|
|
|
|
|
|
$status = $dirty; |
|
103
|
0
|
|
|
|
|
|
last; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if ( not -f $if_file ) { |
|
107
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "if_file doesn't exist\n"; |
|
108
|
0
|
|
|
|
|
|
$status = $dirty; |
|
109
|
0
|
|
|
|
|
|
last; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# $DEBUG && print STDERR "consistency check: $src_file OLDER $if_file : "; |
|
113
|
|
|
|
|
|
|
# |
|
114
|
|
|
|
|
|
|
# if ( (stat($src_file))[9] < (stat($if_file))[9] ) { |
|
115
|
|
|
|
|
|
|
# $DEBUG && print STDERR "YES!!!\n"; |
|
116
|
|
|
|
|
|
|
# $DEBUG && print STDERR "removing $if_file, must be regenerated\n"; |
|
117
|
|
|
|
|
|
|
# unlink $if_file; |
|
118
|
|
|
|
|
|
|
# $status = $dirty; |
|
119
|
|
|
|
|
|
|
# last; |
|
120
|
|
|
|
|
|
|
# } |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "$cache_file OLDER $src_file : "; |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if ( (stat($cache_file))[9] < (stat($src_file))[9] ) { |
|
125
|
|
|
|
|
|
|
# cache is dirty if one cache_file is older |
|
126
|
|
|
|
|
|
|
# than corresponding src_file |
|
127
|
0
|
|
|
|
|
|
$status = $dirty; |
|
128
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "YES\n"; |
|
129
|
0
|
|
|
|
|
|
last; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "NO\n"; |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if ( $has_cached_err ) { |
|
134
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "$err_file OLDER $if_file (incompat. interface?) : "; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
if ( $err_file_mtime < (stat($if_file))[9] ) { |
|
137
|
|
|
|
|
|
|
# cache is dirty if the cached error is older than |
|
138
|
|
|
|
|
|
|
# the if_file (which indicates incompatible |
|
139
|
|
|
|
|
|
|
# interface change) |
|
140
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "YES\n"; |
|
141
|
0
|
|
|
|
|
|
$status = $dirty; |
|
142
|
0
|
|
|
|
|
|
last; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "NO\n"; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "$cache_file OLDER $if_file : "; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
|
if ( $cache_file_mtime < (stat($if_file))[9] ) { |
|
151
|
|
|
|
|
|
|
# cache is dirty if the cache_file_mtime of |
|
152
|
|
|
|
|
|
|
# our object is older than one if_file |
|
153
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "YES\n"; |
|
154
|
0
|
0
|
|
|
|
|
$status = $dirty if not $has_cached_err; |
|
155
|
0
|
|
|
|
|
|
last; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "NO\n"; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
} |
|
161
|
0
|
|
|
|
|
|
close IN; |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "has cached err: $has_cached_err (status=$status)\n"; |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
0
|
0
|
|
|
|
$status = $cached_err if $has_cached_err and $status eq $clean; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
$DEBUG && print STDERR "Status: $status\n"; |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
return $status; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub write_dep_file { |
|
173
|
0
|
|
|
0
|
0
|
|
my $type = shift; |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my %par = @_; |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
my ($dep_file, $src_file, $cache_file, $err_file, $http_file, $entries_href) = |
|
178
|
|
|
|
|
|
|
@par{'dep_file','src_file','cache_file','err_file','http_file','entries_href'}; |
|
179
|
|
|
|
|
|
|
|
|
180
|
0
|
0
|
0
|
|
|
|
croak "dep_file, src_file, cache_file, err_file and entries_href must be set" |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
181
|
|
|
|
|
|
|
unless $dep_file and $src_file and $err_file and |
|
182
|
|
|
|
|
|
|
$cache_file and $entries_href; |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# -------------------------------------------------------------- |
|
185
|
|
|
|
|
|
|
# Format of the dep_file: |
|
186
|
|
|
|
|
|
|
# Line: Fields: |
|
187
|
|
|
|
|
|
|
# -------------------------------------------------------------- |
|
188
|
|
|
|
|
|
|
# 1 src_file \t cache_file \t err_file \t http_file |
|
189
|
|
|
|
|
|
|
# 2..n inc_src_file \t inc_cache_file \t inc_iface_file \t err_file \t http_file |
|
190
|
|
|
|
|
|
|
# -------------------------------------------------------------- |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
my $dir = dirname $dep_file; |
|
193
|
0
|
0
|
|
|
|
|
mkpath ($dir, 0, 0770) if not -d $dir; |
|
194
|
0
|
0
|
|
|
|
|
open (OUT, "> $dep_file") or confess "can't write $dep_file"; |
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
print OUT "$src_file\t$cache_file\t$err_file\t$http_file\n"; |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
foreach my $entry ( values %{$entries_href} ) { |
|
|
0
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
print OUT $entry,"\n"; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
0
|
|
|
|
|
|
close OUT; |
|
202
|
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
1; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub load_dep_file_into_entries_hash { |
|
207
|
0
|
|
|
0
|
0
|
|
my $type = shift; |
|
208
|
0
|
|
|
|
|
|
my %par = @_; |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
my $dep_file = $par{dep_file}; |
|
211
|
0
|
|
|
|
|
|
my $entries_href = $par{entries_href}; |
|
212
|
|
|
|
|
|
|
|
|
213
|
0
|
0
|
|
|
|
|
return if not -f $dep_file; |
|
214
|
|
|
|
|
|
|
|
|
215
|
0
|
0
|
|
|
|
|
open (IN, $dep_file) or confess "can't read $dep_file"; |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# skip first line. we only need to copy the include entries |
|
218
|
0
|
|
|
|
|
|
my $line = ; |
|
219
|
0
|
|
|
|
|
|
chomp $line; |
|
220
|
|
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
my $src_file; |
|
222
|
0
|
|
|
|
|
|
while () { |
|
223
|
0
|
|
|
|
|
|
chomp; |
|
224
|
0
|
|
|
|
|
|
($src_file) = split (/\t/, $_, 2); |
|
225
|
0
|
|
|
|
|
|
$entries_href->{$src_file} = $_; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
0
|
|
|
|
|
|
close IN; |
|
228
|
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
return; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub get_custom_http_header_files { |
|
233
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
234
|
0
|
|
|
|
|
|
my %par = @_; |
|
235
|
0
|
|
|
|
|
|
my ($dep_file) = @par{'dep_file'}; |
|
236
|
|
|
|
|
|
|
|
|
237
|
0
|
0
|
|
|
|
|
open (IN, $dep_file) or confess "can't read $dep_file"; |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
my @http_files; |
|
240
|
|
|
|
|
|
|
my $http_file; |
|
241
|
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
while () { |
|
243
|
0
|
|
|
|
|
|
chomp; |
|
244
|
0
|
|
|
|
|
|
$http_file = substr($_, rindex($_, "\t")+1); |
|
245
|
0
|
0
|
|
|
|
|
if ( -f $http_file ) { |
|
246
|
0
|
0
|
|
|
|
|
push @http_files, $http_file if -f $http_file; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
} |
|
249
|
0
|
|
|
|
|
|
close IN; |
|
250
|
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
|
return \@http_files; |
|
252
|
|
|
|
|
|
|
} |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
1; |