Alt-Acme-Math-XS-ModuleInstall
view release on metacpan or search on metacpan
inc/Inline/C.pm view on Meta::CPAN
}
my $file = File::Spec->catfile($o->{API}{directory},'.lock');
open my $lockfh, '>', $file or die "lockfile $file: $!";
flock($lockfh, LOCK_EX) or die "flock: $!\n" if $^O !~ /^VMS|riscos|VOS$/;
$o->mkpath($o->{API}{build_dir});
$o->call('preprocess', 'Build Preprocess');
$o->call('parse', 'Build Parse');
$o->call('write_XS', 'Build Glue 1');
$o->call('write_Inline_headers', 'Build Glue 2');
$o->call('write_Makefile_PL', 'Build Glue 3');
$o->call('compile', 'Build Compile');
flock($lockfh, LOCK_UN) if $^O !~ /^VMS|riscos|VOS$/;
if ($o->{CONFIG}{BUILD_TIMERS}) {
$total_build_time = Time::HiRes::time() - $total_build_time;
printf STDERR "Total Build Time: %5.4f secs\n", $total_build_time;
}
}
sub call {
my ($o, $method, $header, $indent) = (@_, 0);
my $time;
my $i = ' ' x $indent;
print STDERR "${i}Starting $header Stage\n" if $o->{CONFIG}{BUILD_NOISY};
$time = Time::HiRes::time()
if $o->{CONFIG}{BUILD_TIMERS};
$o->$method();
$time = Time::HiRes::time() - $time
if $o->{CONFIG}{BUILD_TIMERS};
print STDERR "${i}Finished $header Stage\n" if $o->{CONFIG}{BUILD_NOISY};
printf STDERR "${i}Time for $header Stage: %5.4f secs\n", $time
if $o->{CONFIG}{BUILD_TIMERS};
print STDERR "\n" if $o->{CONFIG}{BUILD_NOISY};
}
#==============================================================================
# Apply any
#==============================================================================
sub preprocess {
my $o = shift;
return if $o->{ILSM}{parser};
$o->get_maps;
$o->get_types;
$o->{ILSM}{code} = $o->filter(@{$o->{ILSM}{FILTERS}});
}
#==============================================================================
# Parse the function definition information out of the C code
#==============================================================================
sub parse {
my $o = shift;
return if $o->{ILSM}{parser};
return if $o->{ILSM}{XSMODE};
my $parser = $o->{ILSM}{parser} = $o->get_parser;
$parser->{data}{typeconv} = $o->{ILSM}{typeconv};
$parser->{data}{AUTOWRAP} = $o->{ILSM}{AUTOWRAP};
Inline::Struct::parse($o) if $o->{STRUCT}{'.any'};
$parser->code($o->{ILSM}{code})
or croak <<END;
Bad $o->{API}{language} code passed to Inline at @{[caller(2)]}
END
}
# Create and initialize a parser
sub get_parser {
my $o = shift;
Inline::C::_parser_test($o->{CONFIG}{DIRECTORY}, "Inline::C::get_parser called\n")
if $o->{CONFIG}{_TESTING};
require Inline::C::Parser::RecDescent;
Inline::C::Parser::RecDescent::get_parser($o);
}
#==============================================================================
# Gather the path names of all applicable typemap files.
#==============================================================================
sub get_maps {
my $o = shift;
print STDERR "get_maps Stage\n" if $o->{CONFIG}{BUILD_NOISY};
my $typemap = '';
my $file;
$file = File::Spec->catfile(
$Config::Config{installprivlib},
"ExtUtils",
"typemap",
);
$typemap = $file if -f $file;
$file = File::Spec->catfile(
$Config::Config{privlibexp}
,"ExtUtils","typemap"
);
$typemap = $file
if (not $typemap and -f $file);
warn "Can't find the default system typemap file"
if (not $typemap and $^W);
unshift(@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}, $typemap) if $typemap;
if (not $o->UNTAINT) {
require FindBin;
$file = File::Spec->catfile($FindBin::Bin,"typemap");
if ( -f $file ) {
push(@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}, $file);
}
}
}
#==============================================================================
# This routine parses XS typemap files to get a list of valid types to create
# bindings to. This code is mostly hacked out of Larry Wall's xsubpp program.
#==============================================================================
sub get_types {
my (%type_kind, %proto_letter, %input_expr, %output_expr);
my $o = shift;
local $_;
croak "No typemaps specified for Inline C code"
unless @{$o->{ILSM}{MAKEFILE}{TYPEMAPS}};
my $proto_re = "[" . quotemeta('\$%&*@;') . "]";
foreach my $typemap (@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}) {
( run in 0.894 second using v1.01-cache-2.11-cpan-39bf76dae61 )