line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Makefile::Update; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Update make files. |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
144793
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
152
|
|
6
|
4
|
|
|
4
|
|
14
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
91
|
|
7
|
4
|
|
|
4
|
|
18
|
use autodie; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
14889
|
use Exporter qw(import); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1807
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw(read_files_list upmake); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.2'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub read_files_list |
18
|
|
|
|
|
|
|
{ |
19
|
1
|
|
|
1
|
1
|
8
|
my ($fh) = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
1
|
my ($var, %vars); |
22
|
1
|
|
|
|
|
5
|
while (<$fh>) { |
23
|
10
|
|
|
|
|
8
|
chomp; |
24
|
10
|
|
|
|
|
19
|
s/#.*$//; |
25
|
10
|
|
|
|
|
10
|
s/^\s+//; |
26
|
10
|
|
|
|
|
11
|
s/\s+$//; |
27
|
10
|
100
|
|
|
|
23
|
next if !$_; |
28
|
|
|
|
|
|
|
|
29
|
6
|
100
|
|
|
|
14
|
if (/^(\w+)\s*=$/) { |
30
|
2
|
|
|
|
|
5
|
$var = $1; |
31
|
|
|
|
|
|
|
} else { |
32
|
4
|
50
|
|
|
|
7
|
die "Unexpected contents outside variable definition at line $.\n" |
33
|
|
|
|
|
|
|
unless defined $var; |
34
|
4
|
|
|
|
|
1
|
push @{$vars{$var}}, $_; |
|
4
|
|
|
|
|
13
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
4
|
return \%vars; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub upmake |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
0
|
1
|
|
my ($fname, $updater, @args) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $fname_new = "$fname.upmake.new"; # TODO make it more unique |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
open my $in, '<', $fname; |
49
|
0
|
|
|
|
|
|
open my $out, '>', $fname_new; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $changed = $updater->($in, $out, @args); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
close $in; |
54
|
0
|
|
|
|
|
|
close $out; |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
if ($changed) { |
57
|
0
|
|
|
|
|
|
rename $fname_new, $fname; |
58
|
|
|
|
|
|
|
} else { |
59
|
0
|
|
|
|
|
|
unlink $fname_new; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$changed |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |