| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::PkgConfig::CommandLine; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
2191
|
use strict; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
226
|
|
|
4
|
7
|
|
|
7
|
|
35
|
use warnings; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
174
|
|
|
5
|
7
|
|
|
7
|
|
120
|
use 5.008004; |
|
|
7
|
|
|
|
|
33
|
|
|
6
|
7
|
|
|
7
|
|
475
|
use Alien::Build::Plugin; |
|
|
7
|
|
|
|
|
27
|
|
|
|
7
|
|
|
|
|
64
|
|
|
7
|
7
|
|
|
7
|
|
58
|
use Carp (); |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
9380
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Probe system and determine library or tool properties using the pkg-config command line interface |
|
10
|
|
|
|
|
|
|
our $VERSION = '2.46'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has '+pkg_name' => sub { |
|
14
|
|
|
|
|
|
|
Carp::croak "pkg_name is a required property"; |
|
15
|
|
|
|
|
|
|
}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# NOT used, for compat with other PkgConfig plugins |
|
18
|
|
|
|
|
|
|
has register_prereqs => 1; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _bin_name { |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# We prefer pkgconf to pkg-config because it seems to be the future. |
|
23
|
|
|
|
|
|
|
|
|
24
|
23
|
|
|
23
|
|
601
|
require File::Which; |
|
25
|
|
|
|
|
|
|
File::Which::which($ENV{PKG_CONFIG}) |
|
26
|
|
|
|
|
|
|
? $ENV{PKG_CONFIG} |
|
27
|
23
|
100
|
|
|
|
1161
|
: File::Which::which('pkgconf') |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
? 'pkgconf' |
|
29
|
|
|
|
|
|
|
: File::Which::which('pkg-config') |
|
30
|
|
|
|
|
|
|
? 'pkg-config' |
|
31
|
|
|
|
|
|
|
: undef; |
|
32
|
|
|
|
|
|
|
}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has bin_name => \&_bin_name; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has atleast_version => undef; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has exact_version => undef; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has max_version => undef; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has minimum_version => undef; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _val |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
0
|
|
|
0
|
|
0
|
my($build, $args, $prop_name) = @_; |
|
51
|
0
|
|
|
|
|
0
|
my $string = $args->{out}; |
|
52
|
0
|
|
|
|
|
0
|
chomp $string; |
|
53
|
0
|
|
|
|
|
0
|
$string =~ s{^\s+}{}; |
|
54
|
0
|
0
|
|
|
|
0
|
if($prop_name =~ /version$/) |
|
55
|
0
|
|
|
|
|
0
|
{ $string =~ s{\s*$}{} } |
|
56
|
|
|
|
|
|
|
else |
|
57
|
0
|
|
|
|
|
0
|
{ $string =~ s{\s*$}{ } } |
|
58
|
0
|
0
|
|
|
|
0
|
if($prop_name =~ /^(.*?)\.(.*?)\.(.*?)$/) |
|
59
|
0
|
|
|
|
|
0
|
{ $build->runtime_prop->{$1}->{$2}->{$3} = $string } |
|
60
|
|
|
|
|
|
|
else |
|
61
|
0
|
|
|
|
|
0
|
{ $build->runtime_prop->{$prop_name} = $string } |
|
62
|
0
|
|
|
|
|
0
|
(); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub available |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
20
|
|
|
20
|
1
|
69
|
!!_bin_name(); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub init |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
2
|
|
|
2
|
1
|
10
|
my($self, $meta) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
5
|
my @probe; |
|
76
|
|
|
|
|
|
|
my @gather; |
|
77
|
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
8
|
my $pkgconf = $self->bin_name; |
|
79
|
|
|
|
|
|
|
|
|
80
|
2
|
50
|
|
|
|
8
|
unless(defined $meta->prop->{env}->{PKG_CONFIG}) |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
2
|
|
|
|
|
7
|
$meta->prop->{env}->{PKG_CONFIG} = $pkgconf; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
2
|
50
|
|
|
|
9
|
my($pkg_name, @alt_names) = (ref $self->pkg_name) ? (@{ $self->pkg_name }) : ($self->pkg_name); |
|
|
0
|
|
|
|
|
0
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
6
|
push @probe, map { [$pkgconf, '--exists', $_] } ($pkg_name, @alt_names); |
|
|
2
|
|
|
|
|
9
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
2
|
100
|
|
|
|
14
|
if(defined $self->minimum_version) |
|
|
|
50
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
{ |
|
91
|
1
|
|
|
|
|
5
|
push @probe, [ $pkgconf, '--atleast-version=' . $self->minimum_version, $pkg_name ]; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
elsif(defined $self->atleast_version) |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
0
|
|
|
|
|
0
|
push @probe, [ $pkgconf, '--atleast-version=' . $self->atleast_version, $pkg_name ]; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
2
|
50
|
|
|
|
7
|
if(defined $self->exact_version) |
|
99
|
|
|
|
|
|
|
{ |
|
100
|
0
|
|
|
|
|
0
|
push @probe, [ $pkgconf, '--exact-version=' . $self->exact_version, $pkg_name ]; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
2
|
50
|
|
|
|
9
|
if(defined $self->max_version) |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
0
|
|
|
|
|
0
|
push @probe, [ $pkgconf, '--max-version=' . $self->max_version, $pkg_name ]; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
push @probe, [ $pkgconf, '--modversion', $pkg_name, sub { |
|
109
|
0
|
|
|
0
|
|
0
|
my($build, $args) = @_; |
|
110
|
0
|
|
|
|
|
0
|
my $version = $args->{out}; |
|
111
|
0
|
|
|
|
|
0
|
$version =~ s{^\s+}{}; |
|
112
|
0
|
|
|
|
|
0
|
$version =~ s{\s*$}{}; |
|
113
|
0
|
|
|
|
|
0
|
$build->hook_prop->{version} = $version; |
|
114
|
2
|
|
|
|
|
21
|
}]; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
unshift @probe, sub { |
|
117
|
0
|
|
|
0
|
|
0
|
my($build) = @_; |
|
118
|
0
|
|
0
|
|
|
0
|
$build->runtime_prop->{legacy}->{name} ||= $pkg_name; |
|
119
|
0
|
|
|
|
|
0
|
$build->hook_prop->{probe_class} = __PACKAGE__; |
|
120
|
0
|
|
|
|
|
0
|
$build->hook_prop->{probe_instance_id} = $self->instance_id; |
|
121
|
2
|
|
|
|
|
21
|
}; |
|
122
|
|
|
|
|
|
|
|
|
123
|
2
|
|
|
|
|
11
|
$meta->register_hook( |
|
124
|
|
|
|
|
|
|
probe => \@probe |
|
125
|
|
|
|
|
|
|
); |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
push @gather, sub { |
|
128
|
0
|
|
|
0
|
|
0
|
my($build) = @_; |
|
129
|
|
|
|
|
|
|
die 'pkg-config command line probe does not match gather' if $build->hook_prop->{name} eq 'gather_system' |
|
130
|
0
|
0
|
0
|
|
|
0
|
&& ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id; |
|
|
|
|
0
|
|
|
|
|
|
131
|
2
|
|
|
|
|
18
|
}; |
|
132
|
2
|
|
|
|
|
8
|
push @gather, map { [ $pkgconf, '--exists', $_] } ($pkg_name, @alt_names); |
|
|
2
|
|
|
|
|
7
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
2
|
|
|
|
|
10
|
foreach my $prop_name (qw( cflags libs version )) |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
6
|
100
|
|
|
|
89
|
my $flag = $prop_name eq 'version' ? '--modversion' : "--$prop_name"; |
|
137
|
|
|
|
|
|
|
push @gather, |
|
138
|
6
|
|
|
0
|
|
43
|
[ $pkgconf, $flag, $pkg_name, sub { _val @_, $prop_name } ]; |
|
|
0
|
|
|
|
|
0
|
|
|
139
|
6
|
50
|
|
|
|
20
|
if(@alt_names) |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
0
|
|
|
|
|
0
|
foreach my $alt ($pkg_name, @alt_names) |
|
142
|
|
|
|
|
|
|
{ |
|
143
|
|
|
|
|
|
|
push @gather, |
|
144
|
0
|
|
|
0
|
|
0
|
[ $pkgconf, $flag, $alt, sub { _val @_, "alt.$alt.$prop_name" } ]; |
|
|
0
|
|
|
|
|
0
|
|
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
2
|
|
|
|
|
5
|
foreach my $prop_name (qw( cflags libs )) |
|
150
|
|
|
|
|
|
|
{ |
|
151
|
|
|
|
|
|
|
push @gather, |
|
152
|
4
|
|
|
0
|
|
24
|
[ $pkgconf, '--static', "--$prop_name", $pkg_name, sub { _val @_, "${prop_name}_static" } ]; |
|
|
0
|
|
|
|
|
0
|
|
|
153
|
4
|
50
|
|
|
|
12
|
if(@alt_names) |
|
154
|
|
|
|
|
|
|
{ |
|
155
|
0
|
|
|
|
|
0
|
foreach my $alt ($pkg_name, @alt_names) |
|
156
|
|
|
|
|
|
|
{ |
|
157
|
|
|
|
|
|
|
push @gather, |
|
158
|
0
|
|
|
0
|
|
0
|
[ $pkgconf, '--static', "--$prop_name", $alt, sub { _val @_, "alt.$alt.${prop_name}_static" } ]; |
|
|
0
|
|
|
|
|
0
|
|
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
2
|
|
|
|
|
13
|
$meta->register_hook(gather_system => [@gather]); |
|
164
|
|
|
|
|
|
|
|
|
165
|
2
|
50
|
|
|
|
7
|
if($meta->prop->{platform}->{system_type} eq 'windows-mingw') |
|
166
|
|
|
|
|
|
|
{ |
|
167
|
|
|
|
|
|
|
@gather = map { |
|
168
|
0
|
0
|
|
|
|
0
|
if(ref $_ eq 'ARRAY') { |
|
|
0
|
|
|
|
|
0
|
|
|
169
|
0
|
|
|
|
|
0
|
my($pkgconf, @rest) = @$_; |
|
170
|
0
|
|
|
|
|
0
|
[$pkgconf, '--dont-define-prefix', @rest], |
|
171
|
|
|
|
|
|
|
} else { |
|
172
|
0
|
|
|
|
|
0
|
$_ |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
} @gather; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
2
|
|
|
|
|
25
|
$meta->register_hook(gather_share => [@gather]); |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
$meta->after_hook( |
|
180
|
|
|
|
|
|
|
$_ => sub { |
|
181
|
0
|
|
|
0
|
|
0
|
my($build) = @_; |
|
182
|
0
|
0
|
|
|
|
0
|
if(keys %{ $build->runtime_prop->{alt} } < 2) |
|
|
0
|
|
|
|
|
0
|
|
|
183
|
|
|
|
|
|
|
{ |
|
184
|
0
|
|
|
|
|
0
|
delete $build->runtime_prop->{alt}; |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
}, |
|
187
|
2
|
|
|
|
|
22
|
) for qw( gather_system gather_share ); |
|
188
|
|
|
|
|
|
|
|
|
189
|
2
|
|
|
|
|
8
|
$self; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
__END__ |