| 1 | package ExtUtils::Builder::BuildTools::FromPerl; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $ExtUtils::Builder::BuildTools::FromPerl::VERSION = '0.038'; | |||||||||||||||||||||||||||||||||||||||||||||
| 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 | 2 | ▶ | use parent 'ExtUtils::Builder::BuildTools::Base'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use ExtUtils::Config 0.007; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use ExtUtils::Builder::Util 0.018 qw/require_module split_like_shell/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Perl::OSType 'is_os_type'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub _is_gcc { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_gcc: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | my ($config, $cc, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | return $config->get('gccversion') || $cc =~ / ^ (?: gcc | g[+]{2} | clang (?: [+]{2} ) ) /ix; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$config->get('gccversion') || $cc =~ / ^ (?: gcc | g[+]{2} | clang (?: [+]{2} ) ) /xi
MC/DC0%0/2
$config->get('gccversion') || $cc =~ / ^ (?: gcc | g[+]{2} | clang (?: [+]{2} ) ) /xi
$config->get('gccversion')
$cc =~ / ^ (?: gcc | g[+]{2} | clang (?: [+]{2} ) ) /xi
Truth table33%1/3
A || B
A= $config->get('gccversion')B= $cc =~ / ^ (?: gcc | g[+]{2} | clang (?: [+]{2} ) ) /xi
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | my %gpp_map = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | 'cc' => 'c++', | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 'gcc' => 'g++', | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 'clang' => 'clang++', | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my %is_gpp = reverse %gpp_map; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | sub make_compiler { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_compiler: called CC=14 SCAR=39.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | my ($self, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $os = $opts->{config}->get('osname'); | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my $raw_cc = $opts->{config}->get('cc'); | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my ($cc, @cc_extra) = ref $raw_cc ? @{$raw_cc} : split_like_shell($raw_cc); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | my ($module, %command) = is_os_type('Unix', $os) || _is_gcc($opts->{config}, $cc) ? 'Unixy' : is_os_type('Windows', $os) ? ('MSVC', language => 'C') : croak 'Your platform is not supported yet'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
is_os_type("Unix", $os) or _is_gcc($opts->{"config"}, $cc)
MC/DC0%0/2
is_os_type("Unix", $os) or _is_gcc($opts->{"config"}, $cc)
is_os_type("Unix", $os)
_is_gcc($opts->{"config"}, $cc)
Truth table33%1/3
A or B
A= is_os_type("Unix", $os)B= _is_gcc($opts->{"config"}, $cc)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | $command{$_} = $opts->{$_} for grep { exists $opts->{$_} } qw/language type/; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | $command{cccdlflags} = [ split_like_shell($opts->{config}->get('cccdlflags')) ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | my $module_name = "ExtUtils::Builder::Compiler::$module"; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | my $language = $opts->{language} // 'C'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{"language"} // "C"
MC/DC0%0/1
$opts->{"language"} // "C"
$opts->{"language"}
Truth table50%1/2
A
A= $opts->{"language"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | require_module($module_name); | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | if (uc $language eq 'C++') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($module_name->isa('ExtUtils::Builder::Compiler::Unixy')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | push @{ $command{extra_flags} }, qw/-xc++/ if _is_gcc($opts->{config}, $cc); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $cc = $gpp_map{$cc} // croak "Don't know C++ compiler for $cc" unless $is_gpp{$cc}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$gpp_map{$cc} // croak("Don't know C++ compiler for $cc")
MC/DC0%0/1
$gpp_map{$cc} // croak("Don't know C++ compiler for $cc")
$gpp_map{$cc}
Truth table0%0/2
A
A= $gpp_map{$cc}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } elsif (!$module_name->isa('ExtUtils::Builder::Compiler::MSVC')) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | croak "Can't find C++ compiler for your platform"; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } elsif (uc $language ne 'C') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | croak "Unknown language $language"; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | return $module_name->new(cc => [$cc, @cc_extra], %command); | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub _unix_flags { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unix_flags: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my ($self, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | return $opts->{lddlflags} if defined $opts->{lddlflags}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $lddlflags = $opts->{config}->get('lddlflags'); | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $optimize = $opts->{config}->get('optimize'); | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $lddlflags =~ s/ ?\Q$optimize// if not $opts->{auto_optimize}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my %ldflags = map { ($_ => 1) } split_like_shell($opts->{config}->get('ldflags')); | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my @lddlflags = grep { not $ldflags{$_} } split_like_shell($lddlflags); | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return (lddlflags => \@lddlflags ) | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | sub make_linker { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_linker: called CC=22 SCAR=48.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | my ($self, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | my $os = $opts->{config}->get('osname'); | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | my $raw_cc = $opts->{config}->get('cc'); | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my ($cc, @cc_extra) = ref $raw_cc ? @{$raw_cc} : split_like_shell($raw_cc); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | my $raw_ld = $opts->{config}->get('ld'); | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my ($ld, @ld_extra) = ref $raw_ld ? @{$raw_ld} : split_like_shell($raw_ld); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | my ($eff_ld, @eff_extra) = ($opts->{type} eq 'executable') ? ($cc, @cc_extra) : ($ld, @ld_extra); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | my ($module, $link, $extra, %command) = | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | $opts->{type} eq 'static-library' ? ('Ar', $opts->{config}->get('ar')) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $os eq 'darwin' ? ('Mach::GCC', $eff_ld, \@eff_extra) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | _is_gcc($opts->{config}, $ld) ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | $os eq 'MSWin32' ? ('PE::GCC', $cc, \@cc_extra) : ('ELF::GCC', $eff_ld, \@eff_extra) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $os eq 'aix' ? ('XCOFF', $cc, \@cc_extra) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | is_os_type('Unix', $os) ? ('ELF::Any', $eff_ld, \@eff_extra, $self->_unix_flags($opts)) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | $os eq 'MSWin32' ? ('PE::MSVC', $ld, \@ld_extra) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | croak 'Linking is not supported yet on your platform'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | $command{$_} = $opts->{$_} for grep { exists $opts->{$_} } qw/exports language type/; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | my $module_name = "ExtUtils::Builder::Linker::$module"; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | my $language = $opts->{language} // 'C'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{"language"} // "C"
MC/DC0%0/1
$opts->{"language"} // "C"
$opts->{"language"}
Truth table50%1/2
A
A= $opts->{"language"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | require_module($module_name); | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | if (uc $language eq 'C++') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $prefix = 'ExtUtils::Builder::Linker:'; | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ($module_name->isa("$prefix:ELF::GCC") || $module_name->isa("$prefix:Mach::GCC") || $module_name->isa("$prefix:PE::GCC")) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$module_name->isa("${prefix}:ELF::GCC") or $module_name->isa("${prefix}:Mach::GCC") or $module_name->isa("${prefix}:PE::GCC")
$module_name->isa("${prefix}:ELF::GCC") or $module_name->isa("${prefix}:Mach::GCC")
MC/DC0%0/3
$module_name->isa("${prefix}:ELF::GCC") or $module_name->isa("${prefix}:Mach::GCC") or $module_name->isa("${prefix}:PE::GCC")
$module_name->isa("${prefix}:ELF::GCC")
$module_name->isa("${prefix}:Mach::GCC")
$module_name->isa("${prefix}:PE::GCC")
Truth table0%0/4
A or B or C
A= $module_name->isa("${prefix}:ELF::GCC")B= $module_name->isa("${prefix}:Mach::GCC")C= $module_name->isa("${prefix}:PE::GCC")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $link = $gpp_map{$link} // croak "Don't know C++ compiler for $link" unless $is_gpp{$link}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$gpp_map{$link} // croak("Don't know C++ compiler for $link")
MC/DC0%0/1
$gpp_map{$link} // croak("Don't know C++ compiler for $link")
$gpp_map{$link}
Truth table0%0/2
A
A= $gpp_map{$link}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ▶ | } elsif (!$module->isa("$prefix:PE::MSVC") && !$module->isa("$prefix:Ar")) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$module->isa("${prefix}:PE::MSVC") || $module->isa("${prefix}:Ar")
MC/DC0%0/2
$module->isa("${prefix}:PE::MSVC") || $module->isa("${prefix}:Ar")
$module->isa("${prefix}:PE::MSVC")
$module->isa("${prefix}:Ar")
Truth table0%0/3
A || B
A= $module->isa("${prefix}:PE::MSVC")B= $module->isa("${prefix}:Ar")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | croak "Can't find C++ linker for your platform"; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } elsif (uc $language ne 'C') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | croak "Unknown language $language"; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | return $module_name->new(ld => [ $link, @{$extra} ], %command); | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | sub add_methods { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_methods: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | my ($class, $planner, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | $opts{config} //= $planner->can('config') ? $planner->config : ExtUtils::Config->new; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts{"config"} //= $planner->can("config") ? $planner->config : "ExtUtils::Config"->new
MC/DC0%0/2
$opts{"config"} //= $planner->can("config") ? $planner->config : "ExtUtils::Config"->new
$opts{"config"}
$planner->can("config") ? $planner->config : "ExtUtils::Config"->new
Truth table33%1/3
A //= B
A= $opts{"config"}B= $planner->can("config") ? $planner->config : "ExtUtils::Config"->new
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | my $os = $opts{config}->get('osname'); | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | my $lib_prefix = is_os_type('Unix', $os) ? 'lib' : ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $class->SUPER::add_methods($planner, | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | object_file => '%s' . $opts{config}->get('_o'), | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | library_file => "$lib_prefix%s." . $opts{config}->get('so'), | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | static_library_file => "$lib_prefix%s" . $opts{config}->get('_a'), | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | loadable_file => '%s.' . $opts{config}->get('dlext'), | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | executable_file => '%s' . $opts{config}->get('_exe'), | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | %opts, | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # backwards compatability | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | $planner->add_delegate('obj_file', sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
obj_file: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my ($this, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return $this->object_file(@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | #ABSTRACT: compiler configuration, derived from perl's configuration | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||