File: mm-build.pl

package info (click to toggle)
libffi-platypus-perl 2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,860 kB
  • sloc: perl: 7,388; ansic: 6,862; cpp: 53; sh: 19; makefile: 14
file content (61 lines) | stat: -rw-r--r-- 1,436 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use strict;
use warnings;
use File::Basename qw( basename );
use File::Path qw( mkpath );
use File::Copy qw( copy );
use lib 'inc';
use My::Config;
use lib 'lib';
use FFI::Build;
use Config ();

my $config = My::Config->new;

my $include = "blib/lib/auto/share/dist/FFI-Platypus/include";
mkpath $include, 0, 0755;
foreach my $h (qw( ffi_platypus_config.h ffi_platypus_bundle.h ))
{
  my $from = "include/$h";
  my $to   = "$include/$h";

  if(-f $to)
  {
    next if slurp($from) eq slurp($to);
  }

  copy($from => $to) || die "unable to copy $from => $to $!";
}

my $lib = FFI::Build->new(
  'plfill',
  source   => ['ffi/*.c'],
  verbose  => 1,
  dir      => 'blib/lib/auto/share/dist/FFI-Platypus/lib',
  platform => $config->platform,
  alien    => [$config->alien],
  cflags   => '-Iblib/lib/auto/share/dist/FFI-Platypus/include -Iinclude',
)->build;

my $name = basename($lib->basename);

foreach my $dir ( 'FFI/Platypus/Memory','FFI/Platypus/Record/Meta', 'FFI/Platypus/Constant' )
{
  my($file) = $dir =~ m{/([^/]+)$};
  mkpath("blib/arch/auto/$dir", 0, 0755);
  my $txtfile = "blib/arch/auto/$dir/$file.txt";
  my $fh;
  open($fh, '>', $txtfile) || die "unable to write to $txtfile $!";
  print $fh "FFI::Build\@auto/share/dist/FFI-Platypus/lib/$name\n";
  close $fh;
}

sub slurp
{
  my($filename) = @_;
  my $fh;
  open $fh, '<', $filename;
  binmode $fh;
  my $content = do { local $/; <$fh> };
  close $fh;
  $content;
}