line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::PkgConfig::PPWrapper; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6575
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
18
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
661
|
use Alien::Build; |
|
1
|
|
|
|
|
62624
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
537
|
use Alien::Build::Plugin; |
|
1
|
|
|
|
|
12272
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
112
|
use Path::Tiny qw /path/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
9
|
1
|
|
|
1
|
|
540
|
use File::Which (); |
|
1
|
|
|
|
|
1025
|
|
|
1
|
|
|
|
|
560
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init { |
15
|
0
|
|
|
0
|
1
|
|
my($self, $meta) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$meta->around_hook ( build => sub { |
18
|
0
|
|
|
0
|
|
|
my ($orig, $build, @args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
return if $build->install_type ne 'share'; |
21
|
0
|
0
|
|
|
|
|
return if $build->meta_prop->{out_of_source}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# wrapper is only needed on windows |
24
|
0
|
0
|
|
|
|
|
return $orig->($build, @args) |
25
|
|
|
|
|
|
|
if not $^O =~ /mswin/i; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $pk = File::Which::which ($ENV{PKG_CONFIG}) |
28
|
0
|
|
0
|
|
|
|
|| File::Which::which ('ppkg-config') |
29
|
|
|
|
|
|
|
|| File::Which::which ('pkg-config'); |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if (!defined $pk) { |
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
|
0
|
0
|
|
|
|
if (!(-e $pk && -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
|
0
|
|
|
|
|
open my $fh, '>', $fname |
64
|
|
|
|
|
|
|
or die "Unable to open pkg-config wrapper $fname, $!"; |
65
|
0
|
|
|
|
|
|
print {$fh} $wrapper; |
|
0
|
|
|
|
|
|
|
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; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |