| 1 | package Alien::Build::Plugin::PkgConfig::PPWrapper; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Alien::Build; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Alien::Build::Plugin; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Path::Tiny qw /path/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use File::Which (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.03'; # VERSION | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 15 | 0 | my($self, $meta) = @_; | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | $meta->around_hook ( build => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||
| 18 | 0 | my ($orig, $build, @args) = @_; | |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | return if $build->install_type ne 'share'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return if $build->meta_prop->{out_of_source}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | # wrapper is only needed on windows | ||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return $orig->($build, @args) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 25 | if not $^O =~ /mswin/i; | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | my $pk = File::Which::which ($ENV{PKG_CONFIG}) | ||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | || File::Which::which ('ppkg-config') | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
File::Which::which($ENV{'PKG_CONFIG'}) || File::Which::which('ppkg-config') || File::Which::which('pkg-config')
File::Which::which($ENV{"PKG_CONFIG"}) or File::Which::which("ppkg-config")
MC/DC0%0/3
File::Which::which($ENV{'PKG_CONFIG'}) || File::Which::which('ppkg-config') || File::Which::which('pkg-config')
File::Which::which($ENV{"PKG_CONFIG"})
File::Which::which("ppkg-config")
File::Which::which('pkg-config')
Truth table0%0/4
A or B || C
A= File::Which::which($ENV{"PKG_CONFIG"})B= File::Which::which("ppkg-config")C= File::Which::which('pkg-config')
| |||||||||||||||||||||||||||||||||||
| 29 | || File::Which::which ('pkg-config'); | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if (!defined $pk) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 32 | 0 | $build->log ("Could not locate ppkg-config or pkg-config in your path\n"); | |||||||||||||||||||||||||||||||||
| 33 | 0 | return $orig->($build, @args); | |||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | 0 | $pk =~ s/\.bat$//i; | |||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if (!(-e $pk && -e "$pk.bat")) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $pk and -e "$pk.bat"
MC/DC0%0/2
-e $pk and -e "$pk.bat"
-e $pk
-e "$pk.bat"
Truth table0%0/3
A and B
A= -e $pkB= -e "$pk.bat"
| |||||||||||||||||||||||||||||||||||
| 38 | 0 | $build->log ("$pk unlikely to be pure perl"); | |||||||||||||||||||||||||||||||||
| 39 | 0 | return $orig->($build, @args); | |||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | 0 | my $perl = $^X; | |||||||||||||||||||||||||||||||||
| 43 | 0 | $perl =~ s/\.exe$//i; | |||||||||||||||||||||||||||||||||
| 44 | 0 | foreach my $path ($perl, $pk) { | |||||||||||||||||||||||||||||||||
| 45 | 0 | $path =~ s{\\}{/}g; | |||||||||||||||||||||||||||||||||
| 46 | 0 | $path =~ s{^([a-z]):/}{/$1/}i; | |||||||||||||||||||||||||||||||||
| 47 | 0 | $path =~ s{\s}{\\ }g; | |||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 0 | my $wrapper = <<'EOWRAPPER' | |||||||||||||||||||||||||||||||||
| 51 | #!perl | ||||||||||||||||||||||||||||||||||
| 52 | system ('##perl##', '##pk##', @ARGV); | ||||||||||||||||||||||||||||||||||
| 53 | exit $?; | ||||||||||||||||||||||||||||||||||
| 54 | EOWRAPPER | ||||||||||||||||||||||||||||||||||
| 55 | ; | ||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | 0 | $wrapper =~ s/##perl##/$perl/gsm; | |||||||||||||||||||||||||||||||||
| 58 | 0 | $wrapper =~ s/##pk##/$pk/; | |||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||
| 60 | 0 | $build->log ("Pure perl pkg-config detected on windows.\n"); | |||||||||||||||||||||||||||||||||
| 61 | 0 | $build->log ("Wrapping $pk in shell script to cope with MSYS perl and paths.\n"); | |||||||||||||||||||||||||||||||||
| 62 | 0 | my $fname = Path::Tiny->new(File::Temp::tempdir( CLEANUP => 1 ))->child('pkg-config'); | |||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | open my $fh, '>', $fname | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 64 | or die "Unable to open pkg-config wrapper $fname, $!"; | ||||||||||||||||||||||||||||||||||
| 65 | 0 | print {$fh} $wrapper; | |||||||||||||||||||||||||||||||||
| 66 | 0 | close ($fh); | |||||||||||||||||||||||||||||||||
| 67 | 0 | $build->log ("Setting \$ENV{PKG_CONFIG} to point to $fname\n"); | |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 0 | local $ENV{PKG_CONFIG} = $fname; | |||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | 0 | return $orig->($build, @args); | |||||||||||||||||||||||||||||||||
| 72 | 0 | }); | |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||||||||