B-C
view release on metacpan or search on metacpan
script/perlcc.PL view on Meta::CPAN
if (/^[A-Z]/) {
$m .= $_."::";
} elsif (/^[a-z]/) {
$m = '';
}
}
$name = $m ? $m.$base : $base;
}
}
$Options->{m} = $name;
}
sub compile_module {
my $name = module_name();
if ($Backend eq 'Bytecode') {
compile_byte("-m$name");
} else {
compile_cstyle("-m$name");
}
}
sub compile_byte {
vprint 3, "Writing B on $Output";
my $opts = $] < 5.007 ? "" : "-H,-s,";
if ($] >= 5.007 and $Input =~ /^-e/) {
$opts = "-H,";
}
if (@_ == 1) {
$opts .= $_[0].",";
}
my $addoptions = opt('Wb');
if (opt('v') > 4) {
$opts .= '-v,';
$opts .= '-DM,-DG,-DA,-DComment,' if opt('v') > 5;
}
#if ($Options->{cross}) {
# $opts .= '-cross='.$Options->{cross}.',';
#}
$opts .= "$addoptions," if $addoptions;
my $command = "$BinPerl -MO=Bytecode,$opts-o$Output $Input";
$Input =~ s/^-e.*$/-e/;
vprint 5, "Compiling...";
vprint 0, "Calling $command";
my $t0 = [gettimeofday] if opt('time');
my ($output_r, $error_r, $errcode) = spawnit($command);
my $elapsed = tv_interval ( $t0 ) if opt('time');
vprint -1, "c time: $elapsed" if opt('time');
if (@$error_r && $errcode != 0) {
_die("$Input did not compile $errcode:\n@$error_r\n");
} else {
my @error = grep { !/^$Input syntax OK$/o } @$error_r;
@error = grep { !/^No package specified for compilation, assuming main::$/o } @error;
warn "$0: Unexpected compiler output\n@error" if @error and opt('v')<5;
warn "@error" if @error and opt('v')>4;
}
unless (opt('dryrun')) {
chmod 0777 & ~umask, $Output or _die("can't chmod $Output: $!\n");
}
}
sub compile_cstyle {
my $stash = opt('stash') ? grab_stash() : "";
$stash .= "," if $stash; #stash can be empty
$stash .= "-u$_," for @{$Options->{u}};
$stash .= "-U$_," for @{$Options->{U}};
#if ($ENV{PERL_CORE} and ($Config{ccflags} =~ /-m32/ or $Config{cc} =~ / -m32/)) {
# die "perlcc with -m32 cross compilation is not supported\n";
#}
my $taint = opt('T') ? ' -T' :
opt('t') ? ' -t' : '';
# What are we going to call our output C file?
my $lose = 0;
my ($cfh);
my $testsuite = '';
my $addoptions = '';
if (@_) {
$addoptions = join(",",@_);
}
$addoptions .= opt('Wb') ? opt('Wb')."," : "";
if( $addoptions ) {
$addoptions .= ',-Dfull' if opt('v') >= 6;
if (opt('v') == 5) {
$addoptions .= opt('O') ? ',-DstFl,-v' : ',-DspF,-v';
}
$addoptions .= ',';
} elsif (opt('v') > 4) {
$addoptions = opt('O') ? '-DstFl,-v,' : '-DspF,-v,';
$addoptions = '-Dfull,-v,' if opt('v') >= 6;
}
if (opt('f')) {
$addoptions .= "-f$_," for @{$Options->{f}};
}
if (opt('check')) {
$addoptions .= "-c,";
}
if (opt('cross')) {
$addoptions .= '-cross='.$Options->{cross}.',';
}
$addoptions =~ s/,,/,/g;
my $staticxs = opt('staticxs') ? "-staticxs," : '';
warn "Warning: --staticxs on darwin is very experimental\n"
if $staticxs and $^O eq 'darwin';
if (opt('testsuite')) {
my $bo = join '', @begin_output;
$bo =~ s/\\/\\\\\\\\/gs;
$bo =~ s/\n/\\n/gs;
$bo =~ s/,/\\054/gs;
# don't look at that: it hurts
$testsuite = q{-fuse-script-name,-fsave-data,-fsave-sig-hash,}.
qq[-e"print q{$bo}",] .
q{-e"open(Test::Builder::TESTOUT\054 '>&STDOUT') or die $!",} .
q{-e"open(Test::Builder::TESTERR\054 '>&STDERR') or die $!",};
}
script/perlcc.PL view on Meta::CPAN
=item --static
Link to static libperl.a
=item --staticxs
Link to static XS if available.
If the XS libs are only available as shared libs link to those ("prelink").
Systems without rpath (windows, cygwin) must be extend LD_LIBRARY_PATH/PATH at run-time.
Together with -static, purely static modules and no run-time eval or
require this will gain no external dependencies.
=item --shared
Link to shared libperl
=item --sharedxs
Link shared XSUBs if the linker supports it. No DynaLoader needed.
This will still require the shared XSUB libraries to be installed
at the client, modification of @INC in the source is probably required.
(Not yet implemented)
=item -m|--sharedlib [Modulename]
Create a module, resp. a shared library.
Currently only enabled for Bytecode and CC. I<(not yet tested)>
=item --testsuite
Tries be nice to Test:: modules, like preallocating the file
handles 4 and 5, and munge the output of BEGIN.
perlcc -r --testsuite t/harness
=item --time
Benchmark the different phases B<c> I<(B::* compilation)>,
B<cc> I<(cc compile + link)>, and B<r> (runtime).
=item --no-spawn
Do not spawn subprocesses for compilation, because broken
shells might not be able to kill its children.
=back
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
!NO!SUBS!
close OUT or die "Can't close $file: $!";
chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
chdir $origdir;
( run in 0.879 second using v1.01-cache-2.11-cpan-437f7b0c052 )