| 1 | package FFI::Build::Platform; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use 5.008004; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use Text::ParseWords (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use FFI::Temp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Capture::Tiny (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use FFI::Platypus::ShareConfig; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | # ABSTRACT: Platform specific configuration. | ||||||||||||||||||||||||||||||||
| 14 | 16 | our $VERSION = '2.12'; # VERSION | |||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | sub new | ||||||||||||||||||||||||||||||||
| 18 | 45 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 19 | 45 | my($class, $config) = @_; | |||||||||||||||||||||||||||||||
| 20 | 45 | ▶ | $config ||= do { | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$config ||= do {
require Config;
\%Config::Config
}
MC/DC0%0/2
$config ||= do {
require Config;
\%Config::Config
}
$config
do {
require Config;
\%Config::Config
}
Truth table66%2/3
A ||= B
A= $configB= do {
require Config;
\%Config::Config
}
| |||||||||||||||||||||||||||||||||
| 21 | 43 | require Config; | |||||||||||||||||||||||||||||||
| 22 | 43 | \%Config::Config; | |||||||||||||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||||||||||||||
| 24 | 45 | my $self = bless { | |||||||||||||||||||||||||||||||
| 25 | config => $config, | ||||||||||||||||||||||||||||||||
| 26 | }, $class; | ||||||||||||||||||||||||||||||||
| 27 | 45 | $self; | |||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 16 | my $default; | |||||||||||||||||||||||||||||||
| 32 | sub default | ||||||||||||||||||||||||||||||||
| 33 | 46 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 34 | 46 | ▶ | $default ||= FFI::Build::Platform->new; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$default ||= "FFI::Build::Platform"->new
MC/DC0%0/2
$default ||= "FFI::Build::Platform"->new
$default
"FFI::Build::Platform"->new
Truth table66%2/3
A ||= B
A= $defaultB= "FFI::Build::Platform"->new
| |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | sub _self | ||||||||||||||||||||||||||||||||
| 38 | 1909 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_self: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 39 | 1909 | my($self) = @_; | |||||||||||||||||||||||||||||||
| 40 | 1909 | ▶ | ref $self ? $self : $self->default; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | sub osname | ||||||||||||||||||||||||||||||||
| 45 | 1036 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
osname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 46 | 1036 | _self(shift)->{config}->{osname}; | |||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | sub object_suffix | ||||||||||||||||||||||||||||||||
| 51 | 68 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
object_suffix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 52 | 68 | _self(shift)->{config}->{obj_ext}; | |||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | sub library_suffix | ||||||||||||||||||||||||||||||||
| 57 | 45 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
library_suffix: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 58 | 45 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 59 | 45 | my $osname = $self->osname; | |||||||||||||||||||||||||||||||
| 60 | 45 | my @suffix; | |||||||||||||||||||||||||||||||
| 61 | 45 | ▶ | if($osname eq 'darwin') | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||
| 63 | 0 | push @suffix, '.dylib', '.bundle'; | |||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||
| 65 | elsif($osname =~ /^(MSWin32|msys|cygwin)$/) | ||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||
| 67 | 0 | push @suffix, '.dll'; | |||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||
| 69 | else | ||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||
| 71 | 45 | push @suffix, '.' . $self->{config}->{dlext}; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | 45 | ▶ | wantarray ? @suffix : $suffix[0]; ## no critic (Community::Wantarray) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | sub library_prefix | ||||||||||||||||||||||||||||||||
| 78 | 43 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
library_prefix: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 79 | 43 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | # this almost certainly requires refinement. | ||||||||||||||||||||||||||||||||
| 82 | 43 | ▶ | if($self->osname eq 'cygwin') | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||
| 84 | 0 | return 'cyg'; | |||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | elsif($self->osname eq 'msys') | ||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||
| 88 | 0 | return 'msys-'; | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | elsif($self->osname eq 'MSWin32') | ||||||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||||||
| 92 | 0 | return ''; | |||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | else | ||||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||
| 96 | 43 | return 'lib'; | |||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | sub cc | ||||||||||||||||||||||||||||||||
| 102 | 89 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
cc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 103 | 89 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 104 | 89 | my $cc = $self->{config}->{cc}; | |||||||||||||||||||||||||||||||
| 105 | 89 | [$self->shellwords($cc)]; | |||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | sub cpp | ||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
cpp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 111 | 0 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 112 | 0 | my $cpp = $self->{config}->{cpprun}; | |||||||||||||||||||||||||||||||
| 113 | 0 | [$self->shellwords($cpp)]; | |||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | sub cxx | ||||||||||||||||||||||||||||||||
| 118 | 13 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
cxx: called CC=10 SCAR=34.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 119 | 13 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 13 | my @cc = @{ $self->cc }; | |||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 13 | ▶ | if($self->{config}->{ccname} eq 'gcc') | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||
| 125 | 13 | ▶ | if($cc[0] =~ /gcc$/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||
| 127 | 0 | my @maybe = @cc; | |||||||||||||||||||||||||||||||
| 128 | 0 | $maybe[0] =~ s/gcc$/g++/; | |||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return \@maybe if $self->which($maybe[0]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||
| 131 | 13 | ▶ | if($cc[0] =~ /clang/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||
| 133 | 0 | my @maybe = @cc; | |||||||||||||||||||||||||||||||
| 134 | 0 | $maybe[0] =~ s/clang/clang++/; | |||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return \@maybe if $self->which($maybe[0]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | # TODO: there are probably situations, eg solaris | ||||||||||||||||||||||||||||||||
| 139 | # where we don't want to try c++ in the case of | ||||||||||||||||||||||||||||||||
| 140 | # a ccname = gcc ? | ||||||||||||||||||||||||||||||||
| 141 | 13 | my @maybe = qw( c++ g++ clang++ ); | |||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | 13 | foreach my $maybe (@maybe) | |||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||
| 145 | 13 | ▶ | return [$maybe] if $self->which($maybe); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | ▶ | elsif($self->osname eq 'MSWin32' && $self->{config}->{ccname} eq 'cl') | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
MC/DC0%0/2
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
$self->osname eq "MSWin32"
$self->{"config"}{"ccname"} eq "cl"
Truth table0%0/3
A and B
A= $self->osname eq "MSWin32"B= $self->{"config"}{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||
| 150 | # TODO: see https://github.com/PerlFFI/FFI-Platypus/issues/203 | ||||||||||||||||||||||||||||||||
| 151 | #return \@cc; | ||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 0 | Carp::croak("unable to detect corresponding C++ compiler"); | |||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | sub cxxld | ||||||||||||||||||||||||||||||||
| 159 | 6 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
cxxld: called CC=3 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 160 | 6 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 6 | $DB::single = 1; | |||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | # This is definitely not exhaustive or complete or even | ||||||||||||||||||||||||||||||||
| 165 | # particularlly good. Patches welcome. | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 6 | ▶ | if($self->osname eq 'darwin') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||
| 169 | 0 | my @cxx = @{ $self->cxx }; | |||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | return [map { /^(cc|clang|gcc)$/ ? @cxx : $_ } @{ $self->ld }]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||
| 172 | else | ||||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||||
| 174 | 6 | return $self->cxx; | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | sub for | ||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
for: called CC=6 SCAR=22.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 181 | 2 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 2 | my @cc = @{ $self->cc }; | |||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | if($self->{config}->{ccname} eq 'gcc') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | if($cc[0] =~ /gcc$/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||
| 189 | 0 | my @maybe = @cc; | |||||||||||||||||||||||||||||||
| 190 | 0 | $maybe[0] =~ s/gcc$/gfortran/; | |||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | return \@maybe if $self->which($maybe[0]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | 2 | foreach my $maybe (qw( gfortran )) | |||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||
| 196 | 2 | ▶ | return [$maybe] if $self->which($maybe); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||
| 199 | else | ||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||
| 201 | 0 | Carp::croak("unable to detect correspnding Fortran Compiler"); | |||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | sub ld | ||||||||||||||||||||||||||||||||
| 207 | 23 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
ld: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 208 | 23 | my($self) = @_; | |||||||||||||||||||||||||||||||
| 209 | 23 | my $ld = $self->{config}->{ld}; | |||||||||||||||||||||||||||||||
| 210 | 23 | [$self->shellwords($ld)]; | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||
| 214 | sub shellwords | ||||||||||||||||||||||||||||||||
| 215 | 383 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
shellwords: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 216 | 383 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | 383 | my $win = !!($self->osname eq 'MSWin32'); | |||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | 1121 | grep { defined $_ } map { | |||||||||||||||||||||||||||||||
| 221 | 383 | ref $_ | |||||||||||||||||||||||||||||||
| 222 | # if we have an array ref then it has already been shellworded | ||||||||||||||||||||||||||||||||
| 223 | ? @$_ | ||||||||||||||||||||||||||||||||
| 224 | 383 | ▶ | : do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 225 | # remove leading whitespace, confuses some older versions of shellwords | ||||||||||||||||||||||||||||||||
| 226 | 235 | ▶ | my $str = /^\s*(.*)$/ && $1; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
/^\s*(.*)$/ && $1
MC/DC0%0/2
/^\s*(.*)$/ && $1
/^\s*(.*)$/
$1
Truth table33%1/3
A && B
A= /^\s*(.*)$/B= $1
| |||||||||||||||||||||||||||||||||
| 227 | # escape things on windows | ||||||||||||||||||||||||||||||||
| 228 | 235 | ▶ | $str =~ s,\\,\\\\,g if $win; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 229 | 235 | Text::ParseWords::shellwords($str); | |||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | } @_; | ||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | sub ccflags | ||||||||||||||||||||||||||||||||
| 237 | 77 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
ccflags: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 238 | 77 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 239 | 77 | my @ccflags; | |||||||||||||||||||||||||||||||
| 240 | 77 | push @ccflags, $self->shellwords($self->{config}->{cccdlflags}); | |||||||||||||||||||||||||||||||
| 241 | 77 | push @ccflags, $self->shellwords($self->{config}->{ccflags}); | |||||||||||||||||||||||||||||||
| 242 | 77 | push @ccflags, $self->shellwords($self->{config}->{optimize}); | |||||||||||||||||||||||||||||||
| 243 | 77 | my $dist_include = eval { File::Spec->catdir(FFI::Platypus::ShareConfig::dist_dir('FFI-Platypus'), 'include') }; | |||||||||||||||||||||||||||||||
| 244 | 77 | ▶ | push @ccflags, "-I$dist_include" unless $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 245 | 77 | \@ccflags; | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | sub ldflags | ||||||||||||||||||||||||||||||||
| 250 | 23 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
ldflags: called CC=7 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 251 | 23 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 252 | 23 | my @ldflags = $self->shellwords($self->{config}->{lddlflags}); | |||||||||||||||||||||||||||||||
| 253 | 23 | ▶ | if($self->osname eq 'cygwin') | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||
| 255 | 16 | ▶ | no warnings 'qw'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 256 | # doesn't appear to be necessary, Perl has this in lddlflags already on cygwin | ||||||||||||||||||||||||||||||||
| 257 | #push @ldflags, qw( -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base ); | ||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||
| 259 | ▶ | elsif($self->osname eq 'MSWin32' && $self->{config}->{ccname} eq 'cl') | |||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
MC/DC0%0/2
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
$self->osname eq "MSWin32"
$self->{"config"}{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $self->osname eq "MSWin32"B= $self->{"config"}{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||
| 261 | 0 | push @ldflags, qw( -dll ); | |||||||||||||||||||||||||||||||
| 262 | 0 | @ldflags = grep !/^-nodefaultlib$/, @ldflags; | |||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||
| 264 | elsif($self->osname eq 'MSWin32') | ||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||
| 266 | 16 | ▶ | no warnings 'qw'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 267 | 0 | push @ldflags, qw( -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base ); | |||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||
| 269 | elsif($self->osname eq 'darwin') | ||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||
| 271 | # we want to build a .dylib instead of a .bundle | ||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | @ldflags = map { $_ eq '-bundle' ? '-dynamiclib' : $_ } @ldflags; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | 23 | \@ldflags; | |||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | sub cc_mm_works | ||||||||||||||||||||||||||||||||
| 279 | 8 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
cc_mm_works: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 280 | 8 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 281 | 8 | my $verbose = shift; | |||||||||||||||||||||||||||||||
| 282 | 8 | ▶ | $verbose ||= 0; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$verbose ||= 0
MC/DC100%1/1
$verbose ||= 0
$verbose
Truth table100%2/2
A
A= $verbose
| |||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||
| 284 | 8 | ▶ | unless(defined $self->{cc_mm_works}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||||||
| 286 | 6 | require FFI::Build::File::C; | |||||||||||||||||||||||||||||||
| 287 | 6 | my $c = FFI::Build::File::C->new(\"#include \"foo.h\"\n"); | |||||||||||||||||||||||||||||||
| 288 | 6 | my $dir = FFI::Temp->newdir; | |||||||||||||||||||||||||||||||
| 289 | { | ||||||||||||||||||||||||||||||||
| 290 | 6 | open my $fh, '>', "$dir/foo.h"; | |||||||||||||||||||||||||||||||
| 291 | 6 | print $fh "\n"; | |||||||||||||||||||||||||||||||
| 292 | 6 | close $fh; | |||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 6 | my @cmd = ( | |||||||||||||||||||||||||||||||
| 296 | $self->cc, | ||||||||||||||||||||||||||||||||
| 297 | $self->ccflags, | ||||||||||||||||||||||||||||||||
| 298 | "-I$dir", | ||||||||||||||||||||||||||||||||
| 299 | '-MM', | ||||||||||||||||||||||||||||||||
| 300 | $c->path, | ||||||||||||||||||||||||||||||||
| 301 | ); | ||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||
| 303 | 6 | ▶ | my($out, $exit) = Capture::Tiny::capture_merged(sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 304 | 6 | $self->run(@cmd); | |||||||||||||||||||||||||||||||
| 305 | 6 | }); | |||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | 6 | ▶ | if($verbose >= 2) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 308 | { | ||||||||||||||||||||||||||||||||
| 309 | 0 | print $out; | |||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||
| 311 | elsif($verbose >= 1) | ||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||
| 313 | 1 | print "CC (checkfor -MM)\n"; | |||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||
| 317 | 6 | ▶ | if(!$exit && $out =~ /foo\.h/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $exit and $out =~ /foo\.h/
MC/DC0%0/2
not $exit and $out =~ /foo\.h/
not $exit
$out =~ /foo\.h/
Truth table33%1/3
not(A) and B
A= not $exitB= $out =~ /foo\.h/
| |||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||
| 319 | 6 | $self->{cc_mm_works} = '-MM'; | |||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||
| 321 | else | ||||||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||||||
| 323 | 0 | $self->{cc_mm_works} = 0; | |||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | 8 | $self->{cc_mm_works}; | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||
| 331 | sub flag_object_output | ||||||||||||||||||||||||||||||||
| 332 | 65 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
flag_object_output: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 333 | 65 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 334 | 65 | my $file = shift; | |||||||||||||||||||||||||||||||
| 335 | 65 | ▶ | if($self->osname eq 'MSWin32' && $self->{config}->{ccname} eq 'cl') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
MC/DC0%0/2
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
$self->osname eq "MSWin32"
$self->{"config"}{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $self->osname eq "MSWin32"B= $self->{"config"}{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||||||
| 337 | 0 | return ("-Fo$file"); | |||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||
| 339 | else | ||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||
| 341 | 65 | return ('-o' => $file); | |||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | sub flag_library_output | ||||||||||||||||||||||||||||||||
| 347 | 21 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
flag_library_output: called CC=4 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 348 | 21 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 349 | 21 | my $file = shift; | |||||||||||||||||||||||||||||||
| 350 | 21 | ▶ | if($self->osname eq 'MSWin32' && $self->{config}->{ccname} eq 'cl') | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
MC/DC0%0/2
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
$self->osname eq "MSWin32"
$self->{"config"}{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $self->osname eq "MSWin32"B= $self->{"config"}{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||
| 352 | 0 | return ("-OUT:$file"); | |||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||
| 354 | elsif($self->osname eq 'darwin') | ||||||||||||||||||||||||||||||||
| 355 | { | ||||||||||||||||||||||||||||||||
| 356 | 0 | return ('-install_name' => "\@rpath/$file", -o => $file); | |||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||
| 358 | else | ||||||||||||||||||||||||||||||||
| 359 | { | ||||||||||||||||||||||||||||||||
| 360 | 21 | return ('-o' => $file); | |||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||
| 365 | sub flag_exe_output | ||||||||||||||||||||||||||||||||
| 366 | 7 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
flag_exe_output: called CC=3 SCAR=13.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 367 | 7 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 368 | 7 | my $file = shift; | |||||||||||||||||||||||||||||||
| 369 | 7 | ▶ | if($self->osname eq 'MSWin32' && $self->{config}->{ccname} eq 'cl') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
MC/DC0%0/2
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
$self->osname eq "MSWin32"
$self->{"config"}{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $self->osname eq "MSWin32"B= $self->{"config"}{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||||||
| 370 | { | ||||||||||||||||||||||||||||||||
| 371 | 0 | my $file = File::Spec->rel2abs($file); | |||||||||||||||||||||||||||||||
| 372 | 0 | return ("/Fe:$file"); | |||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||
| 374 | else | ||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||
| 376 | 7 | return ('-o' => $file); | |||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||
| 381 | sub flag_export | ||||||||||||||||||||||||||||||||
| 382 | 21 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
flag_export: called CC=3 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 383 | 21 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 384 | 21 | ▶ | return () unless $self->osname eq 'MSWin32' && $self->{config}->{ccname} eq 'cl'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
MC/DC0%0/2
$self->osname eq "MSWin32" and $self->{"config"}{"ccname"} eq "cl"
$self->osname eq "MSWin32"
$self->{"config"}{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $self->osname eq "MSWin32"B= $self->{"config"}{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||||||
| 385 | 0 | return map { "/EXPORT:$_" } @_; | |||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||
| 389 | sub which | ||||||||||||||||||||||||||||||||
| 390 | 17 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
which: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 391 | 17 | my(undef, $command) = @_; | |||||||||||||||||||||||||||||||
| 392 | 17 | require IPC::Cmd; | |||||||||||||||||||||||||||||||
| 393 | 17 | ▶ | my @command = ref $command ? @$command : ($command); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 394 | 17 | IPC::Cmd::can_run($command[0]); | |||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||
| 398 | sub run | ||||||||||||||||||||||||||||||||
| 399 | 99 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 400 | 99 | my $self = shift; | |||||||||||||||||||||||||||||||
| 401 | 99 | ▶ | my @command = map { ref $_ ? @$_ : $_ } grep { defined $_ } @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 402 | 99 | print "+@command\n"; | |||||||||||||||||||||||||||||||
| 403 | 99 | system @command; | |||||||||||||||||||||||||||||||
| 404 | 99 | $?; | |||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||
| 408 | 8 | ▶ | sub _c { join ',', @_ } | ||||||||||||||||||||||||||||||
|
Subroutine
_c: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 409 | 14 | ▶ | sub _l { join ' ', map { ref $_ ? @$_ : $_ } @_ } | ||||||||||||||||||||||||||||||
|
Subroutine
_l: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | sub diag | ||||||||||||||||||||||||||||||||
| 412 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
diag: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 413 | 2 | my $self = _self(shift); | |||||||||||||||||||||||||||||||
| 414 | 2 | my @diag; | |||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | 2 | push @diag, "osname : ". _c($self->osname); | |||||||||||||||||||||||||||||||
| 417 | 2 | push @diag, "cc : ". _l($self->cc); | |||||||||||||||||||||||||||||||
| 418 | 2 | ▶ | push @diag, "cxx : ". (eval { _l($self->cxx) } || '---' ); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
_l($self->cxx)
}
} || '---'
MC/DC0%0/1
eval {
do {
_l($self->cxx)
}
} || '---'
eval {
do {
_l($self->cxx)
}
}
Truth table50%1/2
A
A= eval {
do {
_l($self->cxx)
}
}
| |||||||||||||||||||||||||||||||||
| 419 | 2 | ▶ | push @diag, "cxxld : ". (eval { _l($self->cxxld) } || '---' ); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
_l($self->cxxld)
}
} || '---'
MC/DC0%0/1
eval {
do {
_l($self->cxxld)
}
} || '---'
eval {
do {
_l($self->cxxld)
}
}
Truth table50%1/2
A
A= eval {
do {
_l($self->cxxld)
}
}
| |||||||||||||||||||||||||||||||||
| 420 | 2 | ▶ | push @diag, "for : ". (eval { _l($self->for) } || '---' ); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
_l($self->for)
}
} || '---'
MC/DC0%0/1
eval {
do {
_l($self->for)
}
} || '---'
eval {
do {
_l($self->for)
}
}
Truth table50%1/2
A
A= eval {
do {
_l($self->for)
}
}
| |||||||||||||||||||||||||||||||||
| 421 | 2 | push @diag, "ld : ". _l($self->ld); | |||||||||||||||||||||||||||||||
| 422 | 2 | push @diag, "ccflags : ". _l($self->ccflags); | |||||||||||||||||||||||||||||||
| 423 | 2 | push @diag, "ldflags : ". _l($self->ldflags); | |||||||||||||||||||||||||||||||
| 424 | 2 | push @diag, "object suffix : ". _c($self->object_suffix); | |||||||||||||||||||||||||||||||
| 425 | 2 | push @diag, "library prefix : ". _c($self->library_prefix); | |||||||||||||||||||||||||||||||
| 426 | 2 | push @diag, "library suffix : ". _c($self->library_suffix); | |||||||||||||||||||||||||||||||
| 427 | 2 | push @diag, "cc mm works : ". $self->cc_mm_works; | |||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||
| 429 | 2 | join "\n", @diag; | |||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||
| 432 | 16 | 1; | |||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | __END__ | ||||||||||||||||||||||||||||||||