line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::PkgConfig::LibPkgConf; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
2227
|
use strict; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
232
|
|
4
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
188
|
|
5
|
7
|
|
|
7
|
|
149
|
use 5.008004; |
|
7
|
|
|
|
|
27
|
|
6
|
7
|
|
|
7
|
|
465
|
use Alien::Build::Plugin; |
|
7
|
|
|
|
|
23
|
|
|
7
|
|
|
|
|
50
|
|
7
|
7
|
|
|
7
|
|
46
|
use Carp (); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
878
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Probe system and determine library or tool properties using PkgConfig::LibPkgConf |
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
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has atleast_version => undef; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has exact_version => undef; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has max_version => undef; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has minimum_version => undef; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# private for now, used by negotiator |
30
|
|
|
|
|
|
|
has register_prereqs => 1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
7
|
|
|
7
|
|
51
|
use constant _min_version => '0.04'; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
7169
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub available |
36
|
|
|
|
|
|
|
{ |
37
|
14
|
|
|
14
|
1
|
30
|
!!eval { require PkgConfig::LibPkgConf; PkgConfig::LibPkgConf->VERSION(_min_version) }; |
|
14
|
|
|
|
|
1530
|
|
|
2
|
|
|
|
|
65
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub init |
41
|
|
|
|
|
|
|
{ |
42
|
3
|
|
|
3
|
1
|
17
|
my($self, $meta) = @_; |
43
|
|
|
|
|
|
|
|
44
|
3
|
50
|
|
|
|
10
|
unless(defined $meta->prop->{env}->{PKG_CONFIG}) |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
# TODO: this doesn't yet find pkgconf in the bin dir of a share |
47
|
|
|
|
|
|
|
# install. |
48
|
3
|
50
|
|
|
|
12
|
my $command_line = |
|
|
50
|
|
|
|
|
|
49
|
|
|
|
|
|
|
File::Which::which('pkgconf') |
50
|
|
|
|
|
|
|
? 'pkgconf' |
51
|
|
|
|
|
|
|
: File::Which::which('pkg-config') |
52
|
|
|
|
|
|
|
? 'pkg-config' |
53
|
|
|
|
|
|
|
: undef; |
54
|
3
|
50
|
|
|
|
1158
|
$meta->prop->{env}->{PKG_CONFIG} = $command_line |
55
|
|
|
|
|
|
|
if defined $command_line; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
3
|
100
|
|
|
|
20
|
if($self->register_prereqs) |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
# Also update in Neotiate.pm |
61
|
1
|
|
|
|
|
6
|
$meta->add_requires('configure' => 'PkgConfig::LibPkgConf::Client' => _min_version); |
62
|
|
|
|
|
|
|
|
63
|
1
|
0
|
33
|
|
|
4
|
if(defined $self->minimum_version || defined $self->atleast_version || defined $self->exact_version || defined $self->max_version) |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
64
|
|
|
|
|
|
|
{ |
65
|
1
|
|
|
|
|
4
|
$meta->add_requires('configure' => 'PkgConfig::LibPkgConf::Util' => _min_version); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
3
|
50
|
|
|
|
14
|
my($pkg_name, @alt_names) = (ref $self->pkg_name) ? (@{ $self->pkg_name }) : ($self->pkg_name); |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$meta->register_hook( |
72
|
|
|
|
|
|
|
probe => sub { |
73
|
0
|
|
|
0
|
|
0
|
my($build) = @_; |
74
|
0
|
|
0
|
|
|
0
|
$build->runtime_prop->{legacy}->{name} ||= $pkg_name; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
$build->hook_prop->{probe_class} = __PACKAGE__; |
77
|
0
|
|
|
|
|
0
|
$build->hook_prop->{probe_instance_id} = $self->instance_id; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
require PkgConfig::LibPkgConf::Client; |
80
|
0
|
|
|
|
|
0
|
my $client = PkgConfig::LibPkgConf::Client->new; |
81
|
0
|
|
|
|
|
0
|
my $pkg = $client->find($pkg_name); |
82
|
0
|
0
|
|
|
|
0
|
die "package $pkg_name not found" unless $pkg; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
$build->hook_prop->{version} = $pkg->version; |
85
|
0
|
|
|
|
|
0
|
my $atleast_version = $self->atleast_version; |
86
|
0
|
0
|
|
|
|
0
|
$atleast_version = $self->minimum_version unless defined $self->atleast_version; |
87
|
0
|
0
|
|
|
|
0
|
if($atleast_version) |
88
|
|
|
|
|
|
|
{ |
89
|
0
|
|
|
|
|
0
|
require PkgConfig::LibPkgConf::Util; |
90
|
0
|
0
|
|
|
|
0
|
if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $atleast_version) < 0) |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
|
|
0
|
die "package $pkg_name is version @{[ $pkg->version ]}, but at least $atleast_version is required."; |
|
0
|
|
|
|
|
0
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
0
|
if($self->exact_version) |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
|
|
0
|
require PkgConfig::LibPkgConf::Util; |
99
|
0
|
0
|
|
|
|
0
|
if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->exact_version) != 0) |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
|
|
0
|
die "package $pkg_name is version @{[ $pkg->version ]}, but exactly @{[ $self->exact_version ]} is required."; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
0
|
if($self->max_version) |
106
|
|
|
|
|
|
|
{ |
107
|
0
|
|
|
|
|
0
|
require PkgConfig::LibPkgConf::Util; |
108
|
0
|
0
|
|
|
|
0
|
if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->max_version) > 0) |
109
|
|
|
|
|
|
|
{ |
110
|
0
|
|
|
|
|
0
|
die "package $pkg_name is version @{[ $pkg->version ]}, but max @{[ $self->max_version ]} is required."; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
0
|
foreach my $alt (@alt_names) |
115
|
|
|
|
|
|
|
{ |
116
|
0
|
|
|
|
|
0
|
my $pkg = $client->find($alt); |
117
|
0
|
0
|
|
|
|
0
|
die "package $alt not found" unless $pkg; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
0
|
'system'; |
121
|
|
|
|
|
|
|
}, |
122
|
3
|
|
|
|
|
50
|
); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$meta->register_hook( |
125
|
|
|
|
|
|
|
$_ => sub { |
126
|
0
|
|
|
0
|
|
0
|
my($build) = @_; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
return if $build->hook_prop->{name} eq 'gather_system' |
129
|
0
|
0
|
0
|
|
|
0
|
&& ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id; |
|
|
|
0
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
0
|
require PkgConfig::LibPkgConf::Client; |
132
|
0
|
|
|
|
|
0
|
my $client = PkgConfig::LibPkgConf::Client->new; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
0
|
foreach my $name ($pkg_name, @alt_names) |
135
|
|
|
|
|
|
|
{ |
136
|
0
|
|
|
|
|
0
|
my $pkg = $client->find($name); |
137
|
0
|
0
|
|
|
|
0
|
die "reload of package $name failed" unless defined $pkg; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
0
|
my %prop; |
140
|
0
|
|
|
|
|
0
|
$prop{version} = $pkg->version; |
141
|
0
|
|
|
|
|
0
|
$prop{cflags} = $pkg->cflags; |
142
|
0
|
|
|
|
|
0
|
$prop{libs} = $pkg->libs; |
143
|
0
|
|
|
|
|
0
|
$prop{cflags_static} = $pkg->cflags_static; |
144
|
0
|
|
|
|
|
0
|
$prop{libs_static} = $pkg->libs_static; |
145
|
0
|
|
|
|
|
0
|
$build->runtime_prop->{alt}->{$name} = \%prop; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
0
|
foreach my $key (keys %{ $build->runtime_prop->{alt}->{$pkg_name} }) |
|
0
|
|
|
|
|
0
|
|
149
|
|
|
|
|
|
|
{ |
150
|
0
|
|
|
|
|
0
|
$build->runtime_prop->{$key} = $build->runtime_prop->{alt}->{$pkg_name}->{$key}; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
0
|
if(keys %{ $build->runtime_prop->{alt} } == 1) |
|
0
|
|
|
|
|
0
|
|
154
|
|
|
|
|
|
|
{ |
155
|
0
|
|
|
|
|
0
|
delete $build->runtime_prop->{alt}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
}, |
158
|
3
|
|
|
|
|
32
|
) for qw( gather_system gather_share ); |
159
|
|
|
|
|
|
|
|
160
|
3
|
|
|
|
|
12
|
$self; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__END__ |