Alt-Acme-Math-XS-CPP
view release on metacpan or search on metacpan
inc/Inline/C.pm view on Meta::CPAN
use strict; use warnings;
package Inline::C;
our $VERSION = '0.67';
use Inline 0.56;
use Config;
use Data::Dumper;
use Carp;
use Cwd qw(cwd abs_path);
use File::Spec;
use Fcntl ':flock';
our @ISA = qw(Inline);
#==============================================================================
# Register this module as an Inline language support module
#==============================================================================
sub register {
return {
language => 'C',
# XXX Breaking this on purpose; let's see who screams
# aliases => ['c'],
type => 'compiled',
suffix => $Config{dlext},
};
}
#==============================================================================
# Validate the C config options
#==============================================================================
sub usage_validate {
my $key = shift;
return <<END;
The value of config option '$key' must be a string or an array ref
END
}
sub validate {
my $o = shift;
print STDERR "validate Stage\n" if $o->{CONFIG}{BUILD_NOISY};
$o->{ILSM} ||= {};
$o->{ILSM}{XS} ||= {};
$o->{ILSM}{MAKEFILE} ||= {};
if (not $o->UNTAINT) {
require FindBin;
$o->{ILSM}{MAKEFILE}{INC} = "-I\"$FindBin::Bin\""
if not defined $o->{ILSM}{MAKEFILE}{INC};
}
$o->{ILSM}{AUTOWRAP} = 0 if not defined $o->{ILSM}{AUTOWRAP};
$o->{ILSM}{XSMODE} = 0 if not defined $o->{ILSM}{XSMODE};
$o->{ILSM}{AUTO_INCLUDE} ||= <<END;
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"
END
$o->{ILSM}{FILTERS} ||= [];
$o->{STRUCT} ||= {
'.macros' => '',
'.xs' => '',
'.any' => 0,
'.all' => 0,
};
while (@_) {
inc/Inline/C.pm view on Meta::CPAN
open HEADER, "> ".File::Spec->catfile($o->{API}{build_dir},"INLINE.h")
or croak;
print HEADER <<'END';
#define Inline_Stack_Vars dXSARGS
#define Inline_Stack_Items items
#define Inline_Stack_Item(x) ST(x)
#define Inline_Stack_Reset sp = mark
#define Inline_Stack_Push(x) XPUSHs(x)
#define Inline_Stack_Done PUTBACK
#define Inline_Stack_Return(x) XSRETURN(x)
#define Inline_Stack_Void XSRETURN(0)
#define INLINE_STACK_VARS Inline_Stack_Vars
#define INLINE_STACK_ITEMS Inline_Stack_Items
#define INLINE_STACK_ITEM(x) Inline_Stack_Item(x)
#define INLINE_STACK_RESET Inline_Stack_Reset
#define INLINE_STACK_PUSH(x) Inline_Stack_Push(x)
#define INLINE_STACK_DONE Inline_Stack_Done
#define INLINE_STACK_RETURN(x) Inline_Stack_Return(x)
#define INLINE_STACK_VOID Inline_Stack_Void
#define inline_stack_vars Inline_Stack_Vars
#define inline_stack_items Inline_Stack_Items
#define inline_stack_item(x) Inline_Stack_Item(x)
#define inline_stack_reset Inline_Stack_Reset
#define inline_stack_push(x) Inline_Stack_Push(x)
#define inline_stack_done Inline_Stack_Done
#define inline_stack_return(x) Inline_Stack_Return(x)
#define inline_stack_void Inline_Stack_Void
END
close HEADER;
}
#==============================================================================
# Generate the Makefile.PL
#==============================================================================
sub write_Makefile_PL {
my $o = shift;
$o->{ILSM}{xsubppargs} = '';
my $i = 0;
for (@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}) {
$o->{ILSM}{xsubppargs} .= "-typemap \"$_\" ";
}
my %options = (
VERSION => $o->{API}{version} || '0.00',
%{$o->{ILSM}{MAKEFILE}},
NAME => $o->{API}{module},
);
open MF, "> ".File::Spec->catfile($o->{API}{build_dir},"Makefile.PL")
or croak;
print MF <<END;
use ExtUtils::MakeMaker;
my %options = %\{
END
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 1;
print MF Data::Dumper::Dumper(\ %options);
print MF <<END;
\};
WriteMakefile(\%options);
# Remove the Makefile dependency. Causes problems on a few systems.
sub MY::makefile { '' }
END
close MF;
}
#==============================================================================
# Run the build process.
#==============================================================================
sub compile {
my $o = shift;
my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
chdir $build_dir;
# Run these in an eval block, so that we get to chdir back to
# $cwd if there's a failure. (Ticket #81375.)
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
die if $@; #Die now that we've done the chdir back to $cwd. (#81375)
$o->call('cleanup', 'Cleaning Up', 2);
}
sub makefile_pl {
my ($o) = @_;
my $perl;
-f ($perl = $Config::Config{perlpath})
or ($perl = $^X)
or croak "Can't locate your perl binary";
$perl = qq{"$perl"} if $perl =~ m/\s/;
$o->system_call("$perl Makefile.PL", 'out.Makefile_PL');
$o->fix_make;
}
sub make {
my ($o) = @_;
my $make = $o->{ILSM}{MAKE} || $Config::Config{make}
or croak "Can't locate your make binary";
local $ENV{MAKEFLAGS} = $ENV{MAKEFLAGS} =~ s/(--jobserver-fds=[\d,]+)//
if $ENV{MAKEFLAGS};
$o->system_call("$make", 'out.make');
}
sub make_install {
my ($o) = @_;
my $make = $o->{ILSM}{MAKE} || $Config::Config{make}
or croak "Can't locate your make binary";
if ($ENV{MAKEFLAGS}) { # Avoid uninitialized warnings
local $ENV{MAKEFLAGS} = $ENV{MAKEFLAGS} =~
s/(--jobserver-fds=[\d,]+)//;
}
( run in 0.320 second using v1.01-cache-2.11-cpan-1dc43b0fbd2 )