File Coverage

inc/mm-build.pl
Criterion Covered Total %
statement 57 58 98.2
branch 3 8 37.5
condition n/a
subroutine 11 11 100.0
pod n/a
total 71 77 92.2


line stmt bran cond sub pod time code
1 1     1   5498 use strict;
  1         3  
  1         42  
2 1     1   6 use warnings;
  1         1  
  1         63  
3 1     1   8 use File::Basename qw( basename );
  1         1  
  1         151  
4 1     1   8 use File::Path qw( mkpath );
  1         2  
  1         84  
5 1     1   691 use File::Copy qw( copy );
  1         9070  
  1         61  
6 1     1   510 use lib 'inc';
  1         644  
  1         5  
7 1     1   603 use My::Config;
  1         5  
  1         51  
8 1     1   10 use lib 'lib';
  1         2  
  1         9  
9 1     1   204 use FFI::Build;
  1         2  
  1         11  
10 1     1   7 use Config ();
  1         3  
  1         112565  
11              
12 1         189107 my $config = My::Config->new;
13              
14 1         3 my $include = "blib/lib/auto/share/dist/FFI-Platypus/include";
15 1         88 mkpath $include, 0, 0755;
16 1         4 foreach my $h (qw( ffi_platypus_config.h ffi_platypus_bundle.h ))
17             {
18 2         5 my $from = "include/$h";
19 2         4 my $to = "$include/$h";
20              
21 2 50       37 if(-f $to)
22             {
23 2 50       7 next if slurp($from) eq slurp($to);
24             }
25              
26 0 0       0 copy($from => $to) || die "unable to copy $from => $to $!";
27             }
28              
29 1         9 my $lib = FFI::Build->new(
30             'plfill',
31             source => ['ffi/*.c'],
32             verbose => 1,
33             dir => 'blib/lib/auto/share/dist/FFI-Platypus/lib',
34             platform => $config->platform,
35             alien => [$config->alien],
36             cflags => '-Iblib/lib/auto/share/dist/FFI-Platypus/include -Iinclude',
37             )->build;
38              
39 1         55 my $name = basename($lib->basename);
40              
41 1         11 foreach my $dir ( 'FFI/Platypus/Memory','FFI/Platypus/Record/Meta', 'FFI/Platypus/Constant' )
42             {
43 3         48 my($file) = $dir =~ m{/([^/]+)$};
44 3         210 mkpath("blib/arch/auto/$dir", 0, 0755);
45 3         19 my $txtfile = "blib/arch/auto/$dir/$file.txt";
46 3         4 my $fh;
47 3 50       404 open($fh, '>', $txtfile) || die "unable to write to $txtfile $!";
48 3         24 print $fh "FFI::Build\@auto/share/dist/FFI-Platypus/lib/$name\n";
49 3         616 close $fh;
50             }
51              
52             sub slurp
53             {
54 4     4   10 my($filename) = @_;
55 4         6 my $fh;
56 4         173 open $fh, '<', $filename;
57 4         11 binmode $fh;
58 4         5 my $content = do { local $/; <$fh> };
  4         19  
  4         198  
59 4         35 close $fh;
60 4         33 $content;
61             }