line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Makefile::AST::Rule::Implicit; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
518
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
71
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#use Smart::Comments; |
7
|
|
|
|
|
|
|
#use Smart::Comments '####'; |
8
|
2
|
|
|
2
|
|
13
|
use base 'Makefile::AST::Rule::Base'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
843
|
|
9
|
2
|
|
|
2
|
|
13
|
use List::Util qw( first ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2187
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw{ |
12
|
|
|
|
|
|
|
targets |
13
|
|
|
|
|
|
|
}); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub as_str ($) { |
16
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
17
|
0
|
|
|
|
|
0
|
my $order_part = ''; |
18
|
|
|
|
|
|
|
## as_str: order_prereqs: $self->order_prereqs |
19
|
0
|
0
|
|
|
|
0
|
if (@{ $self->order_prereqs }) { |
|
0
|
|
|
|
|
0
|
|
20
|
0
|
|
|
|
|
0
|
$order_part = " | " . join(" ",@{ $self->order_prereqs }); |
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
### colon: $self->colon |
23
|
0
|
|
|
|
|
0
|
my $str = join(" ", @{ $self->targets }) . " " . |
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
$self->colon . " " . |
25
|
0
|
|
|
|
|
0
|
join(" ", @{ $self->normal_prereqs }) . "$order_part ; " . |
26
|
0
|
|
|
|
|
0
|
join("", map { "[$_]" } @{ $self->commands }); |
|
0
|
|
|
|
|
0
|
|
27
|
0
|
|
|
|
|
0
|
$str =~ s/\n+//g; |
28
|
0
|
|
|
|
|
0
|
$str =~ s/ +/ /g; |
29
|
0
|
|
|
|
|
0
|
$str; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# judge if $self is a match anything rule |
33
|
|
|
|
|
|
|
sub match_anything ($) { |
34
|
8
|
|
|
8
|
0
|
12
|
my $self = shift; |
35
|
8
|
|
|
8
|
|
30
|
first { $_ eq '%' } $self->targets; |
|
8
|
|
|
|
|
73
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub is_terminal ($) { |
39
|
3
|
|
|
3
|
0
|
14
|
$_[0]->colon eq '::'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub match_target ($$) { |
43
|
14
|
|
|
14
|
0
|
20
|
my ($self, $target) = @_; |
44
|
14
|
|
|
|
|
11
|
for my $pat (@{ $self->targets }) { |
|
14
|
|
|
|
|
35
|
|
45
|
|
|
|
|
|
|
### match_target: pattern: $pat |
46
|
|
|
|
|
|
|
### match_target: target: $target |
47
|
17
|
|
|
|
|
122
|
my $match = Makefile::AST::StemMatch->new( |
48
|
|
|
|
|
|
|
{ target => $target, pattern => $pat } |
49
|
|
|
|
|
|
|
); |
50
|
17
|
100
|
|
|
|
262
|
return $match if $match; |
51
|
|
|
|
|
|
|
} |
52
|
3
|
|
|
|
|
12
|
return undef; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# apply the current rule to the given target |
56
|
|
|
|
|
|
|
sub apply ($$$@) { |
57
|
7
|
|
|
7
|
0
|
11
|
my ($self, $ast, $target, $opts) = @_; |
58
|
|
|
|
|
|
|
#### applying implicit rule to target: $target |
59
|
7
|
|
|
|
|
8
|
my $recursive; |
60
|
7
|
100
|
|
|
|
15
|
$recursive = $opts->{recursive} if $opts; |
61
|
|
|
|
|
|
|
#### $recursive |
62
|
7
|
|
|
|
|
14
|
my $match = $self->match_target($target); |
63
|
|
|
|
|
|
|
## $match |
64
|
7
|
50
|
|
|
|
17
|
return undef if !$match; |
65
|
7
|
|
|
|
|
6
|
my (@other_targets, @normal_prereqs, @order_prereqs); |
66
|
7
|
|
|
|
|
9
|
for (@{ $self->targets }) { |
|
7
|
|
|
|
|
17
|
|
67
|
14
|
100
|
|
|
|
85
|
next if $_ eq $match->pattern; |
68
|
7
|
|
|
|
|
42
|
push @other_targets, $match->subs_stem($_); |
69
|
|
|
|
|
|
|
} |
70
|
7
|
|
|
|
|
9
|
for (@{ $self->normal_prereqs }) { |
|
7
|
|
|
|
|
23
|
|
71
|
21
|
|
|
|
|
67
|
push @normal_prereqs, $match->subs_stem($_); |
72
|
|
|
|
|
|
|
} |
73
|
7
|
|
|
|
|
8
|
for (@{ $self->order_prereqs }) { |
|
7
|
|
|
|
|
19
|
|
74
|
14
|
|
|
|
|
45
|
push @order_prereqs, $match->subs_stem($_); |
75
|
|
|
|
|
|
|
} |
76
|
7
|
|
|
|
|
85
|
for my $prereq (@order_prereqs, @normal_prereqs) { |
77
|
|
|
|
|
|
|
#### Test whether the prereq exists or ought to exist: $prereq |
78
|
|
|
|
|
|
|
#### target exists? : $ast->target_exists($prereq) |
79
|
|
|
|
|
|
|
## file test: -e 'bar.hpp' |
80
|
|
|
|
|
|
|
#### Target ought to exists? : $ast->target_ought_to_exist($prereq) |
81
|
17
|
100
|
66
|
|
|
44
|
next if $ast->target_exists($prereq) or |
82
|
|
|
|
|
|
|
$ast->target_ought_to_exist($prereq); |
83
|
|
|
|
|
|
|
#### Failed to pass... |
84
|
|
|
|
|
|
|
# XXX mark intermedia files here |
85
|
6
|
50
|
66
|
|
|
30
|
next if $recursive and |
86
|
|
|
|
|
|
|
$ast->apply_implicit_rules($prereq); |
87
|
6
|
|
|
|
|
27
|
return undef; |
88
|
|
|
|
|
|
|
} |
89
|
1
|
|
|
|
|
5
|
return Makefile::AST::Rule->new( |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
target => $target, |
92
|
|
|
|
|
|
|
colon => $self->colon, |
93
|
|
|
|
|
|
|
stem => $match->stem, |
94
|
|
|
|
|
|
|
normal_prereqs => \@normal_prereqs, |
95
|
|
|
|
|
|
|
order_prereqs => \@order_prereqs, |
96
|
|
|
|
|
|
|
other_targets => \@other_targets, |
97
|
|
|
|
|
|
|
commands => $self->commands, |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|