| 1 | package ExtUtils::Builder::Plan; | ||||||||||||||||||||||||||||
| 2 | 10 | $ExtUtils::Builder::Plan::VERSION = '0.020'; | |||||||||||||||||||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 7 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 11 | return bless { | ||||||||||||||||||||||||||||
| 12 | nodes => $args{nodes} // {} | ||||||||||||||||||||||||||||
| 13 | 7 | ▶ | }, $class; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{"nodes"} // {}
MC/DC0%0/1
$args{"nodes"} // {}
$args{"nodes"}
Truth table50%1/2
A
A= $args{"nodes"}
| |||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | sub node { | ||||||||||||||||||||||||||
|
Subroutine
node: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 4 | my ($self, $name) = @_; | |||||||||||||||||||||||||||
| 18 | 4 | return $self->{nodes}{$name}; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | sub nodes { | ||||||||||||||||||||||||||
|
Subroutine
nodes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 23 | 1 | return @{$self->{nodes}}{ $self->node_names }; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 6 | ▶ | sub node_names { | ||||||||||||||||||||||||||
|
Subroutine
node_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | 6 | return sort keys %{ $self->{nodes} }; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 28 | ▶ | sub _node_sorter { | ||||||||||||||||||||||||||
|
Subroutine
_node_sorter: called CC=6 SCAR=20.3
| |||||||||||||||||||||||||||||
| 32 | 28 | my ($self, $name, $callback, $seen, $loop) = @_; | |||||||||||||||||||||||||||
| 33 | 28 | ▶ | Carp::croak("$name has a circular dependency, aborting!\n") if exists $loop->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 28 | ▶ | return if $seen->{$name}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 28 | ▶ | if (my $node = $self->{nodes}{$name}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 36 | 28 | local $loop->{$name} = 1; | |||||||||||||||||||||||||||
| 37 | 28 | $self->_node_sorter($_, $callback, $seen, $loop) for $node->dependencies; | |||||||||||||||||||||||||||
| 38 | 28 | $callback->($name, $node); | |||||||||||||||||||||||||||
| 39 | } elsif (not -e $name) { | ||||||||||||||||||||||||||||
| 40 | 0 | Carp::confess("Node $name doesn't exist") | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 28 | return; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 7 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 7 | my ($self, $targets, %options) = @_; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my @targets = ref($targets) ? @{$targets} : $targets; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 7 | my (%seen, %loop); | |||||||||||||||||||||||||||
| 50 | 28 | ▶ | my $run_node = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 51 | 28 | my ($name, $node) = @_; | |||||||||||||||||||||||||||
| 52 | 28 | ▶ | return if $self->_up_to_date($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 21 | $node->execute(%options); | |||||||||||||||||||||||||||
| 54 | 7 | }; | |||||||||||||||||||||||||||
| 55 | 7 | $self->_node_sorter($_, $run_node, \%seen, \%loop) for @targets; | |||||||||||||||||||||||||||
| 56 | 7 | return; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 28 | ▶ | sub _up_to_date { | ||||||||||||||||||||||||||
|
Subroutine
_up_to_date: called CC=8 SCAR=23.1
| |||||||||||||||||||||||||||||
| 60 | 28 | my ($self, $node) = @_; | |||||||||||||||||||||||||||
| 61 | 28 | ▶ | return 0 if $node->type eq 'phony' or not -e $node->target; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$node->type eq "phony" or not -e $node->target
MC/DC100%2/2
$node->type eq "phony" or not -e $node->target
$node->type eq "phony"
not -e $node->target
Truth table100%3/3
A or not(B)
A= $node->type eq "phony"B= not -e $node->target
| |||||||||||||||||||||||||||||
| 62 | 8 | my $mtime = -M _; | |||||||||||||||||||||||||||
| 63 | 8 | for my $dep_name (sort $node->dependencies) { | |||||||||||||||||||||||||||
| 64 | 6 | ▶ | if (my $dep = $self->{nodes}{$dep_name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 6 | ▶ | return 0 unless $dep->newer_than($mtime); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | } else { | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | return 0 unless -e $dep_name && $mtime <= -M _; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $dep_name and $mtime <= -M _
MC/DC0%0/2
-e $dep_name and $mtime <= -M _
-e $dep_name
$mtime <= -M _
Truth table0%0/3
A and B
A= -e $dep_nameB= $mtime <= -M _
| |||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 7 | return 1; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub merge { | ||||||||||||||||||||||||||
|
Subroutine
merge: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 0 | my ($self, $other) = @_; | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | Carp::croak('Right side of merge is not a Plan') if not $other->isa(__PACKAGE__); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | my $double = join ', ', grep { $other->{nodes}{$_} } keys %{ $self->{nodes} }; | |||||||||||||||||||||||||||
| 77 | 0 | ▶ | Carp::croak("Found key(s) $double on both sides of merge") if $double; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | my %nodes = (%{ $self->{nodes} }, %{ $other->{nodes} }); | |||||||||||||||||||||||||||
| 79 | 0 | return ref($self)->new(nodes => [ values %nodes ]); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | sub phonies { | ||||||||||||||||||||||||||
|
Subroutine
phonies: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 84 | 1 | return sort map { $_->target } grep { $_->phony } values %{ $self->{nodes} }; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 10 | 1; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # ABSTRACT: An ExtUtils::Builder Plan | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||