line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Core::Gather; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
1928
|
use strict; |
|
47
|
|
|
|
|
92
|
|
|
47
|
|
|
|
|
1213
|
|
4
|
47
|
|
|
47
|
|
239
|
use warnings; |
|
47
|
|
|
|
|
91
|
|
|
47
|
|
|
|
|
908
|
|
5
|
47
|
|
|
47
|
|
637
|
use 5.008004; |
|
47
|
|
|
|
|
149
|
|
6
|
47
|
|
|
47
|
|
614
|
use Alien::Build::Plugin; |
|
47
|
|
|
|
|
114
|
|
|
47
|
|
|
|
|
281
|
|
7
|
47
|
|
|
47
|
|
1046
|
use Env qw( @PATH @PKG_CONFIG_PATH ); |
|
47
|
|
|
|
|
2326
|
|
|
47
|
|
|
|
|
404
|
|
8
|
47
|
|
|
47
|
|
9477
|
use Path::Tiny (); |
|
47
|
|
|
|
|
102
|
|
|
47
|
|
|
|
|
667
|
|
9
|
47
|
|
|
47
|
|
596
|
use File::chdir; |
|
47
|
|
|
|
|
2738
|
|
|
47
|
|
|
|
|
4864
|
|
10
|
47
|
|
|
47
|
|
318
|
use Alien::Build::Util qw( _mirror _destdir_prefix ); |
|
47
|
|
|
|
|
102
|
|
|
47
|
|
|
|
|
2406
|
|
11
|
47
|
|
|
47
|
|
916
|
use JSON::PP (); |
|
47
|
|
|
|
|
11823
|
|
|
47
|
|
|
|
|
36623
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Core gather plugin |
14
|
|
|
|
|
|
|
our $VERSION = '2.47'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init |
18
|
|
|
|
|
|
|
{ |
19
|
322
|
|
|
322
|
1
|
827
|
my($self, $meta) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$meta->default_hook( |
22
|
|
|
|
23
|
|
|
$_ => sub {}, |
23
|
322
|
|
|
|
|
1970
|
) for qw( gather_system gather_share ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$meta->around_hook( |
26
|
|
|
|
|
|
|
gather_share => sub { |
27
|
30
|
|
|
30
|
|
97
|
my($orig, $build) = @_; |
28
|
|
|
|
|
|
|
|
29
|
30
|
|
|
|
|
208
|
local $ENV{PATH} = $ENV{PATH}; |
30
|
30
|
|
|
|
|
136
|
local $ENV{PKG_CONFIG_PATH} = $ENV{PKG_CONFIG_PATH}; |
31
|
30
|
100
|
|
|
|
591
|
unshift @PATH, Path::Tiny->new('bin')->absolute->stringify |
32
|
|
|
|
|
|
|
if -d 'bin'; |
33
|
|
|
|
|
|
|
|
34
|
30
|
|
|
|
|
1019
|
for my $dir (qw(share lib)) { |
35
|
60
|
100
|
|
|
|
967
|
unshift @PKG_CONFIG_PATH, Path::Tiny->new("$dir/pkgconfig")->absolute->stringify |
36
|
|
|
|
|
|
|
if -d "$dir/pkgconfig"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
30
|
|
|
|
|
839
|
$orig->($build) |
40
|
|
|
|
|
|
|
} |
41
|
322
|
|
|
|
|
1819
|
); |
42
|
|
|
|
|
|
|
|
43
|
322
|
|
|
|
|
853
|
foreach my $type (qw( share ffi )) |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
$meta->around_hook( |
46
|
|
|
|
|
|
|
"gather_$type" => sub { |
47
|
60
|
|
|
60
|
|
170
|
my($orig, $build) = @_; |
48
|
|
|
|
|
|
|
|
49
|
60
|
100
|
|
|
|
241
|
if($build->meta_prop->{destdir}) |
50
|
|
|
|
|
|
|
{ |
51
|
12
|
|
|
|
|
31
|
my $destdir = $ENV{DESTDIR}; |
52
|
12
|
100
|
|
|
|
199
|
if(-d $destdir) |
53
|
|
|
|
|
|
|
{ |
54
|
8
|
|
|
|
|
39
|
my $src = Path::Tiny->new(_destdir_prefix($ENV{DESTDIR}, $build->install_prop->{prefix})); |
55
|
8
|
|
|
|
|
618
|
my $dst = Path::Tiny->new($build->install_prop->{stage}); |
56
|
|
|
|
|
|
|
|
57
|
8
|
|
|
|
|
173
|
my $res = do { |
58
|
8
|
|
|
|
|
28
|
local $CWD = "$src"; |
59
|
8
|
|
|
|
|
362
|
$orig->($build); |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
8
|
|
|
|
|
252
|
$build->log("mirror $src => $dst"); |
63
|
|
|
|
|
|
|
|
64
|
8
|
|
|
|
|
145
|
$dst->mkpath; |
65
|
|
|
|
|
|
|
# Please note: _mirror and Alien::Build::Util are ONLY |
66
|
|
|
|
|
|
|
# allowed to be used by core plugins. If you are writing |
67
|
|
|
|
|
|
|
# a non-core plugin it may be removed. That is why it |
68
|
|
|
|
|
|
|
# is private. |
69
|
|
|
|
|
|
|
_mirror("$src", "$dst", { |
70
|
|
|
|
|
|
|
verbose => 1, |
71
|
8
|
100
|
|
|
|
415
|
filter => $build->meta_prop->{$type eq 'share' ? 'destdir_filter' : 'destdir_ffi_filter'}, |
72
|
|
|
|
|
|
|
}); |
73
|
|
|
|
|
|
|
|
74
|
8
|
|
|
|
|
55
|
return $res; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else |
77
|
|
|
|
|
|
|
{ |
78
|
4
|
50
|
|
|
|
31
|
die "nothing was installed into destdir" if $type eq 'share'; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else |
82
|
|
|
|
|
|
|
{ |
83
|
48
|
|
|
|
|
154
|
local $CWD = $build->install_prop->{stage}; |
84
|
48
|
|
|
|
|
2373
|
my $ret = $orig->($build); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# if we are not doing a double staged install we want to substitute the install |
87
|
|
|
|
|
|
|
# prefix with the runtime prefix. |
88
|
48
|
|
|
|
|
182
|
my $old = $build->install_prop->{prefix}; |
89
|
48
|
|
|
|
|
194
|
my $new = $build->runtime_prop->{prefix}; |
90
|
|
|
|
|
|
|
|
91
|
48
|
|
|
|
|
170
|
foreach my $flag (qw( cflags cflags_static libs libs_static )) |
92
|
|
|
|
|
|
|
{ |
93
|
192
|
100
|
|
|
|
353
|
next unless defined $build->runtime_prop->{$flag}; |
94
|
40
|
|
|
|
|
67
|
$build->runtime_prop->{$flag} =~ s{(-I|-L|-LIBPATH:)\Q$old\E}{$1 . $new}eg; |
|
0
|
|
|
|
|
0
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
48
|
|
|
|
|
216
|
return $ret; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
644
|
|
|
|
|
3954
|
); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$meta->after_hook( |
104
|
|
|
|
|
|
|
$_ => sub { |
105
|
42
|
|
|
42
|
|
178
|
my($build) = @_; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
die "stage is not defined. be sure to call set_stage on your Alien::Build instance" |
108
|
42
|
50
|
|
|
|
144
|
unless $build->install_prop->{stage}; |
109
|
|
|
|
|
|
|
|
110
|
42
|
|
|
|
|
154
|
my $stage = Path::Tiny->new($build->install_prop->{stage}); |
111
|
42
|
|
|
|
|
1447
|
$build->log("mkdir -p $stage/_alien"); |
112
|
42
|
|
|
|
|
266
|
$stage->child('_alien')->mkpath; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# drop a alien.json file for the runtime properties |
115
|
42
|
|
|
|
|
8807
|
$stage->child('_alien/alien.json')->spew( |
116
|
|
|
|
|
|
|
JSON::PP->new->pretty->canonical(1)->ascii->encode($build->runtime_prop) |
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# copy the alienfile, if we managed to keep it around. |
120
|
42
|
50
|
33
|
|
|
57105
|
if($build->meta->filename && |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
121
|
|
|
|
|
|
|
-r $build->meta->filename && |
122
|
|
|
|
|
|
|
$build->meta->filename !~ /\.(pm|pl)$/ && |
123
|
|
|
|
|
|
|
! -d $build->meta->filename) |
124
|
|
|
|
|
|
|
{ |
125
|
42
|
|
|
|
|
220
|
Path::Tiny->new($build->meta->filename) |
126
|
|
|
|
|
|
|
->copy($stage->child('_alien/alienfile')); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
42
|
100
|
66
|
|
|
49989
|
if($build->install_prop->{patch} && -d $build->install_prop->{patch}) |
130
|
|
|
|
|
|
|
{ |
131
|
|
|
|
|
|
|
# Please note: _mirror and Alien::Build::Util are ONLY |
132
|
|
|
|
|
|
|
# allowed to be used by core plugins. If you are writing |
133
|
|
|
|
|
|
|
# a non-core plugin it may be removed. That is why it |
134
|
|
|
|
|
|
|
# is private. |
135
|
|
|
|
|
|
|
_mirror($build->install_prop->{patch}, |
136
|
1
|
|
|
|
|
5
|
$stage->child('_alien/patch')->stringify); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
}, |
140
|
322
|
|
|
|
|
2188
|
) for qw( gather_share gather_system ); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |