| 1 | package Alien::Build::Plugin::Probe::CommandLine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use 5.008004; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Alien::Build::Plugin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Capture::Tiny qw( capture ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use File::Which (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Alien::Util qw( version_cmp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # ABSTRACT: Probe for tools or commands already available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | our $VERSION = '2.88'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | has '+command' => sub { Carp::croak "@{[ __PACKAGE__ ]} requires command property" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | has 'args' => []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | has 'secondary' => 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | has 'match' => undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | has 'match_stderr' => undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | has 'version' => undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | has 'version_stderr' => undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | has 'atleast_version' => undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 22 | my($self, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 15 | ▶ | my $check = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=19 SCAR=29.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 15 | my($build) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 15 | ▶ | unless(File::Which::which($self->command)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | die 'Command not found ' . $self->command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 13 | ▶ | if(defined $self->match || defined $self->match_stderr || defined $self->version || defined $self->version_stderr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $self->match or defined $self->match_stderr or defined $self->version or defined $self->version_stderr
defined $self->match or defined $self->match_stderr or defined $self->version
defined $self->match or defined $self->match_stderr
MC/DC100%4/4
defined $self->match or defined $self->match_stderr or defined $self->version or defined $self->version_stderr
defined $self->match
defined $self->match_stderr
defined $self->version
defined $self->version_stderr
Truth table100%5/5
A or B or C or D
A= defined $self->matchB= defined $self->match_stderrC= defined $self->versionD= defined $self->version_stderr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | ▶ | my($out,$err,$ret) = capture { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | system( $self->command, @{ $self->args } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | ▶ | die 'Command did not return a true value' if $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 12 | ▶ | die 'Command output did not match' if defined $self->match && $out !~ $self->match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->match and not $out =~ $self->match
MC/DC100%2/2
defined $self->match and not $out =~ $self->match
defined $self->match
not $out =~ $self->match
Truth table100%3/3
A and not(B)
A= defined $self->matchB= not $out =~ $self->match
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 11 | ▶ | die 'Command standard error did not match' if defined $self->match_stderr && $err !~ $self->match_stderr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->match_stderr and not $err =~ $self->match_stderr
MC/DC100%2/2
defined $self->match_stderr and not $err =~ $self->match_stderr
defined $self->match_stderr
not $err =~ $self->match_stderr
Truth table100%3/3
A and not(B)
A= defined $self->match_stderrB= not $err =~ $self->match_stderr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 10 | ▶ | if (defined $self->version or defined $self->version_stderr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->version or defined $self->version_stderr
MC/DC100%2/2
defined $self->version or defined $self->version_stderr
defined $self->version
defined $self->version_stderr
Truth table100%3/3
A or B
A= defined $self->versionB= defined $self->version_stderr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | my $found_version = '0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 6 | ▶ | if(defined $self->version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | ▶ | if($out =~ $self->version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | $found_version = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | $build->runtime_prop->{version} = $found_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | ▶ | if(defined $self->version_stderr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | if($err =~ $self->version_stderr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | $found_version = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | $build->hook_prop->{version} = $found_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $build->runtime_prop->{version} = $found_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | ▶ | if (my $atleast_version = $self->atleast_version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | if(version_cmp ($found_version, $self->atleast_version) < 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # reset the versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | $build->runtime_prop->{version} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | $build->hook_prop->{version} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | die "CommandLine probe found version $found_version, but at least $atleast_version is required."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 10 | $build->runtime_prop->{command} = $self->command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 10 | 'system'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 22 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 22 | ▶ | if($self->secondary) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | $meta->around_hook( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 4 | ▶ | probe => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4 | my $build = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 4 | my $type = $orig->($build, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 4 | ▶ | return $type unless $type eq 'system'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $check->($build); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 15 | $meta->register_hook( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | probe => $check, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||