| 1 | package Alien::Build::Plugin::Gather::IsolateDynamic; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use 5.008004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Alien::Build::Plugin; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Path::Tiny (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Alien::Build::Util qw( _destdir_prefix ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use File::Copy (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # ABSTRACT: Plugin to gather dynamic libraries into a separate directory | ||||||||||||||||||||||||||||
| 12 | 4 | our $VERSION = '2.88'; # VERSION | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub init | ||||||||||||||||||||||||||||
| 16 | 11 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 11 | my($self, $meta) = @_; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # plugin was introduced in 0.42, but had a bug which was fixed in 0.48 | ||||||||||||||||||||||||||||
| 20 | 11 | $meta->add_requires('share' => 'Alien::Build::Plugin::Gather::IsolateDynamic' => '0.48' ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $meta->after_hook( | ||||||||||||||||||||||||||||
| 23 | 4 | ▶ | gather_share => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 24 | 4 | my($build) = @_; | |||||||||||||||||||||||||||
| 25 | 4 | $build->log("Isolating dynamic libraries ..."); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 4 | my $install_root; | |||||||||||||||||||||||||||
| 28 | 4 | ▶ | if($build->meta_prop->{destdir}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||
| 30 | 3 | my $destdir = $ENV{DESTDIR}; | |||||||||||||||||||||||||||
| 31 | 3 | $install_root = Path::Tiny->new(_destdir_prefix($ENV{DESTDIR}, $build->install_prop->{prefix})); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | else | ||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | 1 | $install_root = Path::Tiny->new($build->install_prop->{stage}); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | foreach my $dir (map { $install_root->child($_) } qw( bin lib )) | |||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||
| 40 | 8 | ▶ | next unless -d $dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 8 | foreach my $from ($dir->children) | |||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||
| 43 | 22 | ▶ | next unless $from->basename =~ /\.so/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$from->basename =~ /\.so/ or $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
MC/DC100%2/2
$from->basename =~ /\.so/ or $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
$from->basename =~ /\.so/
$from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
Truth table100%3/3
A or B
A= $from->basename =~ /\.so/B= $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/
| |||||||||||||||||||||||||||||
| 44 | || $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/; | ||||||||||||||||||||||||||||
| 45 | 12 | my $to = $install_root->child('dynamic', $from->basename); | |||||||||||||||||||||||||||
| 46 | 12 | $to->parent->mkpath; | |||||||||||||||||||||||||||
| 47 | 12 | ▶ | unlink "$to" if -e $to; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 12 | $build->log("move @{[ $from->parent->basename ]}/@{[ $from->basename ]} => dynamic/@{[ $to->basename ]}"); | |||||||||||||||||||||||||||
| 49 | 12 | ▶ | File::Copy::move("$from", "$to") || die "unable to move $from => $to $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 4 | $build->log(" Done!"); | |||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||
| 55 | 11 | ); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 4 | 1; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||