| 1 | package Makefile::AST::Rule::Implicit; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | #use Smart::Comments; | ||||||||||||||||||||||||||||
| 7 | #use Smart::Comments '####'; | ||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use base 'Makefile::AST::Rule::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use List::Util qw( first ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | __PACKAGE__->mk_ro_accessors(qw{ | |||||||||||||||||||||||||||
| 12 | targets | ||||||||||||||||||||||||||||
| 13 | }); | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub as_str ($) { | ||||||||||||||||||||||||||||
| 16 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
as_str: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 0 | my $order_part = ''; | |||||||||||||||||||||||||||
| 18 | ## as_str: order_prereqs: $self->order_prereqs | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if (@{ $self->order_prereqs }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | $order_part = " | " . join(" ",@{ $self->order_prereqs }); | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | ### colon: $self->colon | ||||||||||||||||||||||||||||
| 23 | 0 | my $str = join(" ", @{ $self->targets }) . " " . | |||||||||||||||||||||||||||
| 24 | $self->colon . " " . | ||||||||||||||||||||||||||||
| 25 | 0 | join(" ", @{ $self->normal_prereqs }) . "$order_part ; " . | |||||||||||||||||||||||||||
| 26 | 0 | join("", map { "[$_]" } @{ $self->commands }); | |||||||||||||||||||||||||||
| 27 | 0 | $str =~ s/\n+//g; | |||||||||||||||||||||||||||
| 28 | 0 | $str =~ s/ +/ /g; | |||||||||||||||||||||||||||
| 29 | 0 | $str; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # judge if $self is a match anything rule | ||||||||||||||||||||||||||||
| 33 | sub match_anything ($) { | ||||||||||||||||||||||||||||
| 34 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
match_anything: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 8 | ▶ | first { $_ eq '%' } $self->targets; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub is_terminal ($) { | ||||||||||||||||||||||||||||
| 39 | 3 | ▶ | $_[0]->colon eq '::'; | ||||||||||||||||||||||||||
|
Subroutine
is_terminal: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub match_target ($$) { | ||||||||||||||||||||||||||||
| 43 | 14 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||
|
Subroutine
match_target: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 14 | for my $pat (@{ $self->targets }) { | |||||||||||||||||||||||||||
| 45 | ### match_target: pattern: $pat | ||||||||||||||||||||||||||||
| 46 | ### match_target: target: $target | ||||||||||||||||||||||||||||
| 47 | 17 | my $match = Makefile::AST::StemMatch->new( | |||||||||||||||||||||||||||
| 48 | { target => $target, pattern => $pat } | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | 17 | ▶ | return $match if $match; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 3 | return undef; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # apply the current rule to the given target | ||||||||||||||||||||||||||||
| 56 | sub apply ($$$@) { | ||||||||||||||||||||||||||||
| 57 | 7 | ▶ | my ($self, $ast, $target, $opts) = @_; | ||||||||||||||||||||||||||
|
Subroutine
apply: called CC=12 SCAR=25.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | #### applying implicit rule to target: $target | ||||||||||||||||||||||||||||
| 59 | 7 | my $recursive; | |||||||||||||||||||||||||||
| 60 | 7 | ▶ | $recursive = $opts->{recursive} if $opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | #### $recursive | ||||||||||||||||||||||||||||
| 62 | 7 | my $match = $self->match_target($target); | |||||||||||||||||||||||||||
| 63 | ## $match | ||||||||||||||||||||||||||||
| 64 | 7 | ▶ | return undef if !$match; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 7 | my (@other_targets, @normal_prereqs, @order_prereqs); | |||||||||||||||||||||||||||
| 66 | 7 | for (@{ $self->targets }) { | |||||||||||||||||||||||||||
| 67 | 14 | ▶ | next if $_ eq $match->pattern; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 7 | push @other_targets, $match->subs_stem($_); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 7 | for (@{ $self->normal_prereqs }) { | |||||||||||||||||||||||||||
| 71 | 21 | push @normal_prereqs, $match->subs_stem($_); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | 7 | for (@{ $self->order_prereqs }) { | |||||||||||||||||||||||||||
| 74 | 14 | push @order_prereqs, $match->subs_stem($_); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | 7 | 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 | ▶ | next if $ast->target_exists($prereq) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ast->target_exists($prereq) or $ast->target_ought_to_exist($prereq)
MC/DC50%1/2
$ast->target_exists($prereq) or $ast->target_ought_to_exist($prereq)
$ast->target_exists($prereq)
$ast->target_ought_to_exist($prereq)
Truth table66%2/3
A or B
A= $ast->target_exists($prereq)B= $ast->target_ought_to_exist($prereq)
| |||||||||||||||||||||||||||||
| 82 | $ast->target_ought_to_exist($prereq); | ||||||||||||||||||||||||||||
| 83 | #### Failed to pass... | ||||||||||||||||||||||||||||
| 84 | # XXX mark intermedia files here | ||||||||||||||||||||||||||||
| 85 | 6 | ▶ | next if $recursive and | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$recursive and $ast->apply_implicit_rules($prereq)
MC/DC0%0/2
$recursive and $ast->apply_implicit_rules($prereq)
$recursive
$ast->apply_implicit_rules($prereq)
Truth table66%2/3
A and B
A= $recursiveB= $ast->apply_implicit_rules($prereq)
| |||||||||||||||||||||||||||||
| 86 | $ast->apply_implicit_rules($prereq); | ||||||||||||||||||||||||||||
| 87 | 6 | return undef; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | 1 | 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 | 2 | 1; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||