| 1 | #line 1 | ||||||||||||||||||||||||||||
| 2 | package Module::Install::Can; | ||||||||||||||||||||||||||||
| 3 | 2 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Config (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use ExtUtils::MakeMaker (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | use Module::Install::Base (); | ||||||||||||||||||||||||||||
| 8 | 2 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use vars qw{$VERSION @ISA $ISCORE}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | BEGIN { | |||||||||||||||||||||||||||
| 11 | 2 | $VERSION = '1.19'; | |||||||||||||||||||||||||||
| 12 | 2 | @ISA = 'Module::Install::Base'; | |||||||||||||||||||||||||||
| 13 | $ISCORE = 1; | ||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # check if we can load some module | ||||||||||||||||||||||||||||
| 17 | 0 | ▶ | ### Upgrade this to not have to load the module if possible | ||||||||||||||||||||||||||
|
Subroutine
can_use: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 0 | sub can_use { | |||||||||||||||||||||||||||
| 19 | 0 | my ($self, $mod, $ver) = @_; | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | $mod =~ s{::|\\}{/}g; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | $mod .= '.pm' unless $mod =~ /\.pm$/i; | ||||||||||||||||||||||||||||
| 22 | 0 | ||||||||||||||||||||||||||||
| 23 | 0 | my $pkg = $mod; | |||||||||||||||||||||||||||
| 24 | 0 | $pkg =~ s{/}{::}g; | |||||||||||||||||||||||||||
| 25 | $pkg =~ s{\.pm$}{}i; | ||||||||||||||||||||||||||||
| 26 | 0 | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | local $@; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ver || 0
MC/DC0%0/1
$ver || 0
$ver
Truth table0%0/2
A
A= $ver
| |||||||||||||||||||||||||||||
| 28 | eval { require $mod; $pkg->VERSION($ver || 0); 1 }; | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | # Check if we can run some command | ||||||||||||||||||||||||||
|
Subroutine
can_run: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 0 | sub can_run { | |||||||||||||||||||||||||||
| 33 | my ($self, $cmd) = @_; | ||||||||||||||||||||||||||||
| 34 | 0 | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $_cmd = $cmd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-x $_cmd or $_cmd = "MM"->maybe_command($_cmd)
MC/DC0%0/2
-x $_cmd or $_cmd = "MM"->maybe_command($_cmd)
-x $_cmd
$_cmd = "MM"->maybe_command($_cmd)
Truth table0%0/3
A or B
A= -x $_cmdB= $_cmd = "MM"->maybe_command($_cmd)
| |||||||||||||||||||||||||||||
| 36 | return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); | ||||||||||||||||||||||||||||
| 37 | 0 | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | next if $dir eq ''; | |||||||||||||||||||||||||||
| 40 | 0 | require File::Spec; | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $abs = File::Spec->catfile($dir, $cmd); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-x $abs or $abs = "MM"->maybe_command($abs)
MC/DC0%0/2
-x $abs or $abs = "MM"->maybe_command($abs)
-x $abs
$abs = "MM"->maybe_command($abs)
Truth table0%0/3
A or B
A= -x $absB= $abs = "MM"->maybe_command($abs)
| |||||||||||||||||||||||||||||
| 42 | return $abs if (-x $abs or $abs = MM->maybe_command($abs)); | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | ||||||||||||||||||||||||||||
| 45 | return; | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | # Can our C compiler environment build XS files | ||||||||||||||||||||||||||
|
Subroutine
can_xs: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 0 | sub can_xs { | |||||||||||||||||||||||||||
| 50 | my $self = shift; | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | # Ensure we have the CBuilder module | |||||||||||||||||||||||||||
| 53 | $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | # Do we have the configure_requires checker? | |||||||||||||||||||||||||||
| 56 | 0 | local $@; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | eval "require ExtUtils::CBuilder;"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | if ( $@ ) { | ||||||||||||||||||||||||||||
| 59 | # They don't obey configure_requires, so it is | ||||||||||||||||||||||||||||
| 60 | # someone old and delicate. Try to avoid hurting | ||||||||||||||||||||||||||||
| 61 | 0 | # them by falling back to an older simpler test. | |||||||||||||||||||||||||||
| 62 | return $self->can_cc(); | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | # Do we have a working C compiler | |||||||||||||||||||||||||||
| 66 | my $builder = ExtUtils::CBuilder->new( | ||||||||||||||||||||||||||||
| 67 | quiet => 1, | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | unless ( $builder->have_compiler ) { | ||||||||||||||||||||||||||||
| 70 | 0 | # No working C compiler | |||||||||||||||||||||||||||
| 71 | return 0; | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | # Write a C file representative of what XS becomes | |||||||||||||||||||||||||||
| 75 | 0 | require File::Temp; | |||||||||||||||||||||||||||
| 76 | my ( $FH, $tmpfile ) = File::Temp::tempfile( | ||||||||||||||||||||||||||||
| 77 | "compilexs-XXXXX", | ||||||||||||||||||||||||||||
| 78 | SUFFIX => '.c', | ||||||||||||||||||||||||||||
| 79 | 0 | ); | |||||||||||||||||||||||||||
| 80 | 0 | binmode $FH; | |||||||||||||||||||||||||||
| 81 | print $FH <<'END_C'; | ||||||||||||||||||||||||||||
| 82 | #include "EXTERN.h" | ||||||||||||||||||||||||||||
| 83 | #include "perl.h" | ||||||||||||||||||||||||||||
| 84 | #include "XSUB.h" | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | int main(int argc, char **argv) { | ||||||||||||||||||||||||||||
| 87 | return 0; | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | int boot_sanexs() { | ||||||||||||||||||||||||||||
| 91 | return 1; | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | END_C | |||||||||||||||||||||||||||
| 95 | close $FH; | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | # Can the C compiler access the same headers XS does | |||||||||||||||||||||||||||
| 98 | 0 | my @libs = (); | |||||||||||||||||||||||||||
| 99 | 0 | my $object = undef; | |||||||||||||||||||||||||||
| 100 | 0 | eval { | |||||||||||||||||||||||||||
| 101 | 0 | local $^W = 0; | |||||||||||||||||||||||||||
| 102 | $object = $builder->compile( | ||||||||||||||||||||||||||||
| 103 | source => $tmpfile, | ||||||||||||||||||||||||||||
| 104 | 0 | ); | |||||||||||||||||||||||||||
| 105 | @libs = $builder->link( | ||||||||||||||||||||||||||||
| 106 | objects => $object, | ||||||||||||||||||||||||||||
| 107 | module_name => 'sanexs', | ||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | my $result = $@ ? 0 : 1; | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | # Clean up all the build files | |||||||||||||||||||||||||||
| 113 | 0 | ▶ | foreach ( $tmpfile, $object, @libs ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | next unless defined $_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 1 while unlink; | ||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | 0 | ||||||||||||||||||||||||||||
| 118 | return $result; | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | # Can we locate a (the) C compiler | ||||||||||||||||||||||||||
|
Subroutine
can_cc: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 0 | sub can_cc { | |||||||||||||||||||||||||||
| 123 | my $self = shift; | ||||||||||||||||||||||||||||
| 124 | 0 | ▶ | |||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 0 | if ($^O eq 'VMS') { | |||||||||||||||||||||||||||
| 126 | 0 | require ExtUtils::CBuilder; | |||||||||||||||||||||||||||
| 127 | my $builder = ExtUtils::CBuilder->new( | ||||||||||||||||||||||||||||
| 128 | quiet => 1, | ||||||||||||||||||||||||||||
| 129 | 0 | ); | |||||||||||||||||||||||||||
| 130 | return $builder->have_compiler; | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 0 | ▶ | |||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | my @chunks = split(/ /, $Config::Config{cc}) or return; | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | # $Config{cc} may contain args; try to find out the program part | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | while (@chunks) { | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->can_run(join($", @chunks)) || (pop @chunks, next)
MC/DC0%0/2
$self->can_run(join($", @chunks)) || (pop @chunks, next)
$self->can_run(join($", @chunks))
(pop @chunks, next)
Truth table0%0/3
A || B
A= $self->can_run(join($", @chunks))B= (pop @chunks, next)
| |||||||||||||||||||||||||||||
| 137 | return $self->can_run("@chunks") || (pop(@chunks), next); | ||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | 0 | ||||||||||||||||||||||||||||
| 140 | return; | ||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 2 | ▶ | # Fix Cygwin bug on maybe_command(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 0 | if ( $^O eq 'cygwin' ) { | |||||||||||||||||||||||||||
| 145 | 0 | require ExtUtils::MM_Cygwin; | |||||||||||||||||||||||||||
| 146 | 0 | ▶ | require ExtUtils::MM_Win32; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 148 | 0 | *ExtUtils::MM_Cygwin::maybe_command = sub { | |||||||||||||||||||||||||||
| 149 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$file =~ m[^/cygdrive/]i and "ExtUtils::MM_Win32"->can("maybe_command")
MC/DC0%0/2
$file =~ m[^/cygdrive/]i and "ExtUtils::MM_Win32"->can("maybe_command")
$file =~ m[^/cygdrive/]i
"ExtUtils::MM_Win32"->can("maybe_command")
Truth table0%0/3
A and B
A= $file =~ m[^/cygdrive/]iB= "ExtUtils::MM_Win32"->can("maybe_command")
| |||||||||||||||||||||||||||||
| 150 | 0 | if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { | |||||||||||||||||||||||||||
| 151 | ExtUtils::MM_Win32->maybe_command($file); | ||||||||||||||||||||||||||||
| 152 | 0 | } else { | |||||||||||||||||||||||||||
| 153 | ExtUtils::MM_Unix->maybe_command($file); | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 0 | } | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | 2 | ||||||||||||||||||||||||||||
| 159 | 1; | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | __END__ | ||||||||||||||||||||||||||||