File: I2C.pm

package info (click to toggle)
libdevice-i2c-perl 0.06-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 384 kB
  • sloc: perl: 324; ansic: 238; makefile: 6
file content (53 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download
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
package inc::I2C;
use Moose;

extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';

override _build_WriteMakefile_args => sub {
    my ($self) = @_;
    my $template = super();
    our @DIR = qw(.);
    our @LIBS = qw();
    return +{
        %{ $template },
        LIBS          => [join(' ', map { "-l$_" } @LIBS) . ' '],
        DEFINE        => '',
        INC           => join(' ', map { "-I$_" } @DIR),
    };
};

override _build_MakeFile_PL_template => sub {
    my ($self) = @_;
    my $template = super();

    # Extra code append for Makefile.PL for XS binding
    $template .= <<'TEMPLATE';
if  (eval {require ExtUtils::Constant; 1}) {
  # If you edit these definitions to change the constants used by this module,
  # you will need to use the generated const-c.inc and const-xs.inc
  # files to replace their "fallback" counterparts before distributing your
  # changes.
  my @names = (qw());
  ExtUtils::Constant::WriteConstants(
                                     NAME         => 'Device::I2C',
                                     NAMES        => \@names,
                                     DEFAULT_TYPE => 'IV',
                                     C_FILE       => 'const-c.inc',
                                     XS_FILE      => 'const-xs.inc',
                                  );

}
else {
  use File::Copy;
  use File::Spec;
  foreach my $file ('const-c.inc', 'const-xs.inc') {
    my $fallback = File::Spec->catfile('fallback', $file);
    copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
  }
}
TEMPLATE
    return $template;
};

__PACKAGE__->meta->make_immutable;
1;