ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/mkbundle
(Generate patch)

Comparing App-Staticperl/mkbundle (file contents):
Revision 1.34 by root, Mon Mar 12 21:45:10 2012 UTC vs.
Revision 1.40 by root, Thu Aug 3 03:06:47 2023 UTC

12our $STATIC = 0; 12our $STATIC = 0;
13our $PACKLIST = 0; 13our $PACKLIST = 0;
14our $IGNORE_ENV = 0; 14our $IGNORE_ENV = 0;
15our $ALLOW_DYNAMIC = 0; 15our $ALLOW_DYNAMIC = 0;
16our $HAVE_DYNAMIC; # maybe useful? 16our $HAVE_DYNAMIC; # maybe useful?
17our $EXTRA_CFLAGS = "";
18our $EXTRA_LDFLAGS = "";
19our $EXTRA_LIBS = "";
17 20
18our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? 21our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression?
19 22
20our $CACHE; 23our $CACHE;
21our $CACHEVER = 1; # do not change unless you know what you are doing 24our $CACHEVER = 2; # do not change unless you know what you are doing
22 25
23my $PREFIX = "bundle"; 26my $PREFIX = "bundle";
24my $PACKAGE = "static"; 27my $PACKAGE = "static";
25 28
26my %pm; 29my %pm;
353 356
354use Getopt::Long; 357use Getopt::Long;
355 358
356sub parse_argv { 359sub parse_argv {
357 GetOptions 360 GetOptions
358 "perl" => \$PERL, 361 "perl" => \$PERL,
359 "app=s" => \$APP, 362 "app=s" => \$APP,
360 363
361 "verbose|v" => sub { ++$VERBOSE }, 364 "verbose|v" => sub { ++$VERBOSE },
362 "quiet|q" => sub { --$VERBOSE }, 365 "quiet|q" => sub { --$VERBOSE },
363 366
364 "strip=s" => \$STRIP, 367 "strip=s" => \$STRIP,
365 "cache=s" => \$CACHE, # internal option 368 "cache=s" => \$CACHE, # internal option
366 "eval|e=s" => sub { trace_eval $_[1] }, 369 "eval|e=s" => sub { trace_eval $_[1] },
367 "use|M=s" => sub { trace_module $_[1] }, 370 "use|M=s" => sub { trace_module $_[1] },
368 "boot=s" => sub { cmd_boot $_[1] }, 371 "boot=s" => sub { cmd_boot $_[1] },
369 "add=s" => sub { cmd_add $_[1], 0 }, 372 "add=s" => sub { cmd_add $_[1], 0 },
370 "addbin=s" => sub { cmd_add $_[1], 1 }, 373 "addbin=s" => sub { cmd_add $_[1], 1 },
371 "incglob=s" => sub { cmd_incglob $_[1] }, 374 "incglob=s" => sub { cmd_incglob $_[1] },
372 "include|i=s" => sub { cmd_include $_[1], 1 }, 375 "include|i=s" => sub { cmd_include $_[1], 1 },
373 "exclude|x=s" => sub { cmd_include $_[1], 0 }, 376 "exclude|x=s" => sub { cmd_include $_[1], 0 },
374 "usepacklists!" => \$PACKLIST, 377 "usepacklists!" => \$PACKLIST,
375 378
376 "static!" => \$STATIC, 379 "static!" => \$STATIC,
377 "staticlib=s" => sub { cmd_staticlib $_[1] }, 380 "staticlib=s" => sub { cmd_staticlib $_[1] },
378 "allow-dynamic!"=> \$ALLOW_DYNAMIC, 381 "allow-dynamic!" => \$ALLOW_DYNAMIC,
379 "ignore-env" => \$IGNORE_ENV, 382 "ignore-env" => \$IGNORE_ENV,
380 383
384 "extra-cflags=s" => \$EXTRA_CFLAGS,
385 "extra-ldflags=s" => \$EXTRA_LDFLAGS,
386 "extra-libs=s" => \$EXTRA_LIBS,
387
381 "<>" => sub { cmd_file $_[0] }, 388 "<>" => sub { cmd_file $_[0] },
382 or exit 1; 389 or exit 1;
383} 390}
384 391
385Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case"); 392Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case");
386 393
648 my $next = $ws->next_token; 655 my $next = $ws->next_token;
649 656
650 if (!$prev || !$next) { 657 if (!$prev || !$next) {
651 $ws->delete; 658 $ws->delete;
652 } else { 659 } else {
660 if ($next->isa (PPI::Token::Whitespace::)) {
661 $ws->delete;
653 if ( 662 } elsif (
654 $next->isa (PPI::Token::Operator::) && $next->{content} =~ /^(?:,|=|!|!=|==|=>)$/ # no ., because of digits. == float 663 $next->isa (PPI::Token::Operator::) && $next->{content} =~ /^(?:,|=|!|!=|==|=>)$/ # no ., because of digits. == float
655 or $prev->isa (PPI::Token::Operator::) && $prev->{content} =~ /^(?:,|=|\.|!|!=|==|=>)$/ 664 or $prev->isa (PPI::Token::Operator::) && $prev->{content} =~ /^(?:,|=|\.|!|!=|==|=>)$/
656 or $prev->isa (PPI::Token::Structure::) 665 or $prev->isa (PPI::Token::Structure::)
657 or ($OPTIMISE_SIZE && 666 or ($OPTIMISE_SIZE &&
658 ($prev->isa (PPI::Token::Word::) 667 ($prev->isa (PPI::Token::Word::)
660 || $next->isa (PPI::Structure::Block::) 669 || $next->isa (PPI::Structure::Block::)
661 || $next->isa (PPI::Structure::List::) 670 || $next->isa (PPI::Structure::List::)
662 || $next->isa (PPI::Structure::Condition::))) 671 || $next->isa (PPI::Structure::Condition::)))
663 ) 672 )
664 ) { 673 ) {
674 # perl has some idiotic warnigns about nonexisting operators
675 if ($prev->isa (PPI::Token::Operator::) && $prev->{content} eq "="
676 && $next->isa (PPI::Token::Operator::) && $next->{content} =~ /[+\-]/
677 ) {
678 # avoid "Reverse %s operator" diagnostic
679 } else {
665 $ws->delete; 680 $ws->delete;
666 } elsif ($prev->isa (PPI::Token::Whitespace::)) {
667 $ws->{content} = ' ';
668 $prev->delete; 681 }
669 } else { 682 } else {
670 $ws->{content} = ' '; 683 $ws->{content} = ' ';
671 } 684 }
672 } 685 }
673 } 686 }
977 } 990 }
978 991
979 XSRETURN ($varpfx\_count); 992 XSRETURN ($varpfx\_count);
980} 993}
981 994
995#ifdef STATICPERL_BUNDLE_INCLUDE
996#include STATICPERL_BUNDLE_INCLUDE
997#endif
998
982EOF 999EOF
983 1000
984############################################################################# 1001#############################################################################
985# xs_init 1002# xs_init
986 1003
1003 char *file = __FILE__; 1020 char *file = __FILE__;
1004 dXSUB_SYS; 1021 dXSUB_SYS;
1005 1022
1006 newXSproto ("$PACKAGE\::find", find, file, "\$"); 1023 newXSproto ("$PACKAGE\::find", find, file, "\$");
1007 newXSproto ("$PACKAGE\::list", list, file, ""); 1024 newXSproto ("$PACKAGE\::list", list, file, "");
1025
1026 #ifdef STATICPERL_BUNDLE_XS_INIT
1027 STATICPERL_BUNDLE_XS_INIT;
1028 #endif
1008EOF 1029EOF
1009 1030
1010# calls 1031# calls
1011for (@static_ext) { 1032for (@static_ext) {
1012 s/\.pm$//; 1033 s/\.pm$//;
1018 1039
1019 print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n"; 1040 print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n";
1020} 1041}
1021 1042
1022print $fh <<EOF; 1043print $fh <<EOF;
1044 Safefree (PL_origfilename);
1045 PL_origfilename = savepv (PL_origargv [0]);
1046 sv_setpv (GvSV (gv_fetchpvs ("0", GV_ADD|GV_NOTQUAL, SVt_PV)), PL_origfilename);
1047
1023 #ifdef _WIN32 1048 #ifdef _WIN32
1024 /* windows perls usually trail behind unix perls 8-10 years in exporting symbols */ 1049 /* windows perls usually trail behind unix perls 8-10 years in exporting symbols */
1025 1050
1026 if (!PL_preambleav) 1051 if (!PL_preambleav)
1027 PL_preambleav = newAV (); 1052 PL_preambleav = newAV ();
1080 perl_construct (staticperl); 1105 perl_construct (staticperl);
1081 1106
1082 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 1107 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
1083 1108
1084 exitstatus = perl_parse (staticperl, staticperl_xs_init, argc + 3, args, environ); 1109 exitstatus = perl_parse (staticperl, staticperl_xs_init, argc + 3, args, environ);
1085 free (args);
1086 if (!exitstatus) 1110 if (!exitstatus)
1087 perl_run (staticperl); 1111 perl_run (staticperl);
1088 1112
1089 exitstatus = perl_destruct (staticperl); 1113 exitstatus = perl_destruct (staticperl);
1090 perl_free (staticperl); 1114 perl_free (staticperl);
1091 PERL_SYS_TERM (); 1115 PERL_SYS_TERM ();
1116 /*free (args); no point doing it this late */
1092 1117
1093 return exitstatus; 1118 return exitstatus;
1094} 1119}
1095EOF 1120EOF
1096} elsif ($PERL) { 1121} elsif ($PERL) {
1171 1196
1172{ 1197{
1173 print "generating $PREFIX.ccopts... " 1198 print "generating $PREFIX.ccopts... "
1174 if $VERBOSE >= 1; 1199 if $VERBOSE >= 1;
1175 1200
1176 $ccopts = "$Config{ccflags} $Config{optimize} $Config{cppflags} -I$Config{archlibexp}/CORE"; 1201 $ccopts = "$Config{ccflags} $Config{optimize} $Config{cppflags} -I$Config{archlibexp}/CORE $EXTRA_CFLAGS";
1177 $ccopts =~ s/([\(\)])/\\$1/g; 1202 $ccopts =~ s/([\(\)])/\\$1/g;
1178 1203
1179 open my $fh, ">$PREFIX.ccopts" 1204 open my $fh, ">$PREFIX.ccopts"
1180 or die "$PREFIX.ccopts: $!"; 1205 or die "$PREFIX.ccopts: $!";
1181 print $fh $ccopts; 1206 print $fh $ccopts;
1189{ 1214{
1190 print "generating $PREFIX.ldopts... "; 1215 print "generating $PREFIX.ldopts... ";
1191 1216
1192 $ldopts = $STATIC ? "-static " : ""; 1217 $ldopts = $STATIC ? "-static " : "";
1193 1218
1194 $ldopts .= "$Config{ccdlflags} $Config{ldflags} @libs $Config{archlibexp}/CORE/$Config{libperl} $Config{perllibs}"; 1219 $ldopts .= "$Config{ccdlflags} $Config{ldflags} $EXTRA_LDFLAGS @libs $Config{archlibexp}/CORE/$Config{libperl} $Config{perllibs} $EXTRA_LIBS";
1195 1220
1196 my %seen; 1221 my %seen;
1197 $ldopts .= " $_" for reverse grep !$seen{$_}++, reverse +($extralibs =~ /(\S+)/g); 1222 $ldopts .= " $_" for reverse grep !$seen{$_}++, reverse +($extralibs =~ /(\S+)/g);
1198 1223
1199 for (@staticlibs) { 1224 for (@staticlibs) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines