| 1 | package ExtUtils::XSpp::Cmd; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | ExtUtils::XSpp::Cmd - implementation of xspp | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | perl -MExtUtils::XSpp::Cmd -e xspp -- <xspp options/arguments> | ||
| 12 | |||
| 13 | In Foo.xs | ||
| 14 | |||
| 15 | INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- <xspp options/arguments> | ||
| 16 | |||
| 17 | Using C<ExtUtils::XSpp::Cmd> is equivalent to using the C<xspp> | ||
| 18 | command line script, except that there is no guarantee for C<xspp> to | ||
| 19 | be installed in the system PATH. | ||
| 20 | |||
| 21 | =head1 DOCUMENTATION | ||
| 22 | |||
| 23 | See L<ExtUtils::XSpp>, L<xspp>. | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | use Exporter 'import'; | ||
| 28 | use Getopt::Long; | ||
| 29 | |||
| 30 | use ExtUtils::XSpp::Driver; | ||
| 31 | |||
| 32 | our @EXPORT = qw(xspp); | ||
| 33 | |||
| 34 | sub xspp { | ||
| 35 | my( @typemap_files, $xsubpp, $xsubpp_args ); | ||
| 36 | GetOptions( 'typemap=s' => \@typemap_files, | ||
| 37 | 'xsubpp:s' => \$xsubpp, | ||
| 38 | 'xsubpp-args=s' => \$xsubpp_args, | ||
| 39 | ); | ||
| 40 | $xsubpp = 'xsubpp' if defined $xsubpp && !length $xsubpp; | ||
| 41 | |||
| 42 | my $driver = ExtUtils::XSpp::Driver->new | ||
| 43 | ( typemaps => \@typemap_files, | ||
| 44 | file => shift @ARGV, | ||
| 45 | xsubpp => $xsubpp, | ||
| 46 | xsubpp_args => $xsubpp_args, | ||
| 47 | ); | ||
| 48 | my $success = $driver->process ? 0 : 1; | ||
| 49 | |||
| 50 | exit $success unless defined wantarray; | ||
| 51 | return $success; | ||
| 52 | } | ||
| 53 | |||
| 54 | 1; |