line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Make::Target; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
5
|
|
|
|
|
|
|
## no critic (ValuesAndExpressions::ProhibitConstantPragma) |
6
|
1
|
|
|
1
|
|
6
|
use constant DEBUG => $ENV{MAKE_DEBUG}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
821
|
|
7
|
|
|
|
|
|
|
## use critic |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2.009'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Intermediate 'target' package |
12
|
|
|
|
|
|
|
# There is an instance of this for each 'target' that apears on |
13
|
|
|
|
|
|
|
# the left hand side of a rule i.e. for each thing that can be made. |
14
|
|
|
|
|
|
|
sub new { |
15
|
131
|
|
|
131
|
0
|
261
|
my ( $class, $name, $info ) = @_; |
16
|
131
|
|
|
|
|
1012
|
return bless { |
17
|
|
|
|
|
|
|
NAME => $name, # name of thing |
18
|
|
|
|
|
|
|
MAKEFILE => $info, # Makefile context |
19
|
|
|
|
|
|
|
RULES => [], |
20
|
|
|
|
|
|
|
RULE_TYPE => undef, # undef, :, :: |
21
|
|
|
|
|
|
|
HAS_RECIPE => undef, # undef, boolean |
22
|
|
|
|
|
|
|
Pass => 0, # Used to determine if 'done' this sweep |
23
|
|
|
|
|
|
|
}, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub date { |
27
|
12
|
|
|
12
|
0
|
20
|
my $self = shift; |
28
|
12
|
|
|
|
|
21
|
my $info = $self->Info; |
29
|
12
|
|
|
|
|
24
|
return $info->date( $self->Name ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub phony { |
33
|
162
|
|
|
162
|
0
|
233
|
my $self = shift; |
34
|
162
|
|
|
|
|
290
|
return $self->Info->phony( $self->Name ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub has_recipe { |
38
|
156
|
|
|
156
|
0
|
306
|
my ($self) = @_; |
39
|
156
|
100
|
|
|
|
374
|
return $self->{HAS_RECIPE} if defined $self->{HAS_RECIPE}; |
40
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::RequireBlockGrep) |
41
|
106
|
|
|
|
|
140
|
return $self->{HAS_RECIPE} = grep @{ $_->recipe }, @{ $self->{RULES} }; |
|
91
|
|
|
|
|
227
|
|
|
106
|
|
|
|
|
241
|
|
42
|
|
|
|
|
|
|
## use critic |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub rules { |
46
|
161
|
|
|
161
|
0
|
268
|
my ($self) = @_; |
47
|
161
|
100
|
100
|
|
|
312
|
if ( !$self->phony && !$self->has_recipe ) { |
48
|
49
|
|
100
|
|
|
99
|
my $rule = $self->Info->patrule( $self->Name, $self->{RULE_TYPE} || ':' ); |
49
|
49
|
|
|
|
|
77
|
DEBUG and print STDERR "Implicit rule (", $self->Name, "): @{ $rule ? $rule->prereqs : ['none'] }\n"; |
50
|
49
|
100
|
|
|
|
99
|
$self->add_rule($rule) if $rule; |
51
|
|
|
|
|
|
|
} |
52
|
161
|
|
|
|
|
472
|
return $self->{RULES}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub add_rule { |
56
|
125
|
|
|
125
|
0
|
229
|
my ( $self, $rule ) = @_; |
57
|
125
|
|
|
|
|
314
|
my $new_kind = $rule->kind; |
58
|
125
|
|
66
|
|
|
435
|
my $kind = $self->{RULE_TYPE} ||= $new_kind; |
59
|
125
|
50
|
|
|
|
254
|
die "Target '$self->{NAME}' had '$kind' but tried to add '$new_kind'" |
60
|
|
|
|
|
|
|
if $kind ne $new_kind; |
61
|
125
|
|
50
|
|
|
537
|
$self->{HAS_RECIPE} ||= undef; # reset if was no or unknown |
62
|
125
|
|
|
|
|
182
|
return push @{ shift->{RULES} }, $rule; |
|
125
|
|
|
|
|
562
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub Name { |
66
|
242
|
|
|
242
|
0
|
783
|
return shift->{NAME}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub Base { |
70
|
1
|
|
|
1
|
0
|
5
|
my $name = shift->{NAME}; |
71
|
1
|
|
|
|
|
15
|
$name =~ s/\.[^.]+$//; |
72
|
1
|
|
|
|
|
9
|
return $name; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub Info { |
76
|
297
|
|
|
297
|
0
|
587
|
return shift->{MAKEFILE}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub done { |
80
|
20
|
|
|
20
|
0
|
31
|
my $self = shift; |
81
|
20
|
|
|
|
|
34
|
my $pass = $self->Info->pass; |
82
|
20
|
50
|
|
|
|
58
|
return 1 if ( $self->{Pass} == $pass ); |
83
|
20
|
|
|
|
|
32
|
$self->{Pass} = $pass; |
84
|
20
|
|
|
|
|
45
|
return 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# as part of "out of date" processing, if any child is remade, I need too |
88
|
|
|
|
|
|
|
sub recurse { |
89
|
20
|
|
|
20
|
0
|
50
|
my ( $self, $method ) = @_; |
90
|
20
|
50
|
|
|
|
37
|
return if $self->done; |
91
|
20
|
|
|
|
|
41
|
my $info = $self->Info; |
92
|
20
|
|
|
|
|
32
|
my @results; |
93
|
20
|
|
|
|
|
28
|
DEBUG and print STDERR "Build " . $self->Name, "\n"; |
94
|
20
|
|
|
|
|
25
|
foreach my $rule ( @{ $self->rules } ) { |
|
20
|
|
|
|
|
35
|
|
95
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::RequireBlockMap) |
96
|
12
|
|
|
|
|
25
|
push @results, map $info->target($_)->recurse($method), @{ $rule->prereqs }; |
|
12
|
|
|
|
|
31
|
|
97
|
|
|
|
|
|
|
## use critic |
98
|
12
|
|
|
|
|
59
|
push @results, $rule->$method($self); |
99
|
|
|
|
|
|
|
} |
100
|
20
|
|
|
|
|
80
|
return @results; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |