File Coverage

blib/lib/Alien/Build/Plugin/Build/Copy.pm
Criterion Covered Total %
statement 18 23 78.2
branch 2 4 50.0
condition n/a
subroutine 6 7 85.7
pod 1 1 100.0
total 27 35 77.1


line stmt bran cond sub pod time code
1             package Alien::Build::Plugin::Build::Copy;
2              
3 2     2   1358 use strict;
  2         4  
  2         61  
4 2     2   11 use warnings;
  2         4  
  2         47  
5 2     2   31 use 5.008004;
  2         6  
6 2     2   438 use Alien::Build::Plugin;
  2         7  
  2         13  
7 2     2   15 use Path::Tiny ();
  2         3  
  2         423  
8              
9             # ABSTRACT: Copy plugin for Alien::Build
10             our $VERSION = '2.45'; # VERSION
11              
12              
13             sub init
14             {
15 1     1 1 4 my($self, $meta) = @_;
16              
17 1         5 $meta->add_requires( 'configure', __PACKAGE__, 0);
18              
19 1 50       8 if($^O eq 'MSWin32')
    50          
20             {
21             $meta->register_hook(build => sub {
22 0     0   0 my($build) = @_;
23 0         0 my $stage = Path::Tiny->new($build->install_prop->{stage})->canonpath;
24 0         0 $build->system("xcopy . $stage /E");
25 0         0 });
26             }
27             elsif($^O eq 'darwin')
28             {
29             # On recent macOS -pPR is the same as -aR
30             # on older Mac OS X (10.5 at least) -a is not supported but -pPR is.
31              
32             # Looks like -pPR should also work on coreutils if for some reason
33             # someone is using coreutils on macOS, although there are semantic
34             # differences between -pPR and -aR on coreutils, that may or may not be
35             # important enough to care about.
36              
37 0         0 $meta->register_hook(build => [
38             'cp -pPR * %{.install.stage}',
39             ]);
40             }
41             else
42             {
43             # TODO: some platforms might not support -a
44             # I think most platforms will support -r
45 1         4 $meta->register_hook(build => [
46             'cp -aR * %{.install.stage}',
47             ]);
48             }
49             }
50              
51             1;
52              
53             __END__