File: Cmd.pm

package info (click to toggle)
libextutils-xspp-perl 0.1800-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 996 kB
  • ctags: 1,861
  • sloc: perl: 8,324; cpp: 125; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (6)
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
package ExtUtils::XSpp::Cmd;

use strict;

=head1 NAME

ExtUtils::XSpp::Cmd - implementation of xspp

=head1 SYNOPSIS

  perl -MExtUtils::XSpp::Cmd -e xspp -- <xspp options/arguments>

In Foo.xs

  INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- <xspp options/arguments>

Using C<ExtUtils::XSpp::Cmd> is equivalent to using the C<xspp>
command line script, except that there is no guarantee for C<xspp> to
be installed in the system PATH.

=head1 DOCUMENTATION

See L<ExtUtils::XSpp>, L<xspp>.

=cut

use Exporter 'import';
use Getopt::Long;

use ExtUtils::XSpp::Driver;

our @EXPORT = qw(xspp);

sub xspp {
    my( @typemap_files, $xsubpp, $xsubpp_args );
    GetOptions( 'typemap=s'       => \@typemap_files,
                'xsubpp:s'        => \$xsubpp,
                'xsubpp-args=s'   => \$xsubpp_args,
                );
    $xsubpp = 'xsubpp' if defined $xsubpp && !length $xsubpp;

    my $driver = ExtUtils::XSpp::Driver->new
      ( typemaps    => \@typemap_files,
        file        => shift @ARGV,
        xsubpp      => $xsubpp,
        xsubpp_args => $xsubpp_args,
        );
    my $success = $driver->process ? 0 : 1;

    exit $success unless defined wantarray;
    return $success;
}

1;