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

Comparing App-Staticperl/mkbundle (file contents):
Revision 1.24 by root, Thu Feb 10 22:44:29 2011 UTC vs.
Revision 1.25 by root, Thu Feb 24 07:01:46 2011 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3############################################################################# 3#############################################################################
4# cannot load modules till after the tracer BEGIN block 4# cannot load modules till after the tracer BEGIN block
5 5
6our $VERBOSE = 1; 6our $VERBOSE = 1;
7our $STRIP = "pod"; # none, pod or ppi 7our $STRIP = "pod"; # none, pod or ppi
8our $UNISTRIP = 1; # always on, try to strip unicore swash data 8our $UNISTRIP = 1; # always on, try to strip unicore swash data
9our $PERL = 0; 9our $PERL = 0;
10our $APP; 10our $APP;
11our $VERIFY = 0; 11our $VERIFY = 0;
12our $STATIC = 0; 12our $STATIC = 0;
13our $PACKLIST = 0; 13our $PACKLIST = 0;
14our $IGNORE_ENV = 0;
14 15
15our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? 16our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression?
16 17
17our $CACHE; 18our $CACHE;
18our $CACHEVER = 1; # do not change unless you know what you are doing 19our $CACHEVER = 1; # do not change unless you know what you are doing
82 }; 83 };
83 84
84 while (<$R_TRACER>) { 85 while (<$R_TRACER>) {
85 if (/use (.*)$/) { 86 if (/use (.*)$/) {
86 my $mod = $1; 87 my $mod = $1;
88 my $eval;
89
90 if ($mod =~ /^'.*'$/ or $mod =~ /^".*"$/) {
91 $eval = "require $mod";
92 } elsif ($mod =~ y%/.%%) {
93 $eval = "require q\x00$mod\x00";
94 } else {
87 my $pkg = ++$pkg; 95 my $pkg = ++$pkg;
88 my $eval = $mod =~ /[^A-Za-z0-9_:]/
89 ? "require $mod"
90 : "{ package $pkg; use $mod; }"; 96 $eval = "{ package $pkg; use $mod; }";
97 }
98
91 eval $eval; 99 eval $eval;
92 warn "ERROR: $@ (while loading '$mod')\n" 100 warn "ERROR: $@ (while loading '$mod')\n"
93 if $@; 101 if $@;
94 } elsif (/eval (.*)$/) { 102 } elsif (/eval (.*)$/) {
95 my $eval = $1; 103 my $eval = $1;
329 337
330use Getopt::Long; 338use Getopt::Long;
331 339
332sub parse_argv { 340sub parse_argv {
333 GetOptions 341 GetOptions
342 "perl" => \$PERL,
343 "app=s" => \$APP,
344
345 "verbose|v" => sub { ++$VERBOSE },
346 "quiet|q" => sub { --$VERBOSE },
347
334 "strip=s" => \$STRIP, 348 "strip=s" => \$STRIP,
335 "cache=s" => \$CACHE, # internal option 349 "cache=s" => \$CACHE, # internal option
336 "verbose|v" => sub { ++$VERBOSE },
337 "quiet|q" => sub { --$VERBOSE },
338 "perl" => \$PERL,
339 "app=s" => \$APP,
340 "eval|e=s" => sub { trace_eval $_[1] }, 350 "eval|e=s" => sub { trace_eval $_[1] },
341 "use|M=s" => sub { trace_module $_[1] }, 351 "use|M=s" => sub { trace_module $_[1] },
342 "boot=s" => sub { cmd_boot $_[1] }, 352 "boot=s" => sub { cmd_boot $_[1] },
343 "add=s" => sub { cmd_add $_[1], 0 }, 353 "add=s" => sub { cmd_add $_[1], 0 },
344 "addbin=s" => sub { cmd_add $_[1], 1 }, 354 "addbin=s" => sub { cmd_add $_[1], 1 },
345 "incglob=s" => sub { cmd_incglob $_[1] }, 355 "incglob=s" => sub { cmd_incglob $_[1] },
346 "include|i=s" => sub { cmd_include $_[1], 1 }, 356 "include|i=s" => sub { cmd_include $_[1], 1 },
347 "exclude|x=s" => sub { cmd_include $_[1], 0 }, 357 "exclude|x=s" => sub { cmd_include $_[1], 0 },
358 "usepacklists!" => \$PACKLIST,
359
348 "static!" => \$STATIC, 360 "static!" => \$STATIC,
349 "usepacklists!" => \$PACKLIST,
350 "staticlib=s" => sub { cmd_staticlib $_[1] }, 361 "staticlib=s" => sub { cmd_staticlib $_[1] },
362 "ignore-env" => \$IGNORE_ENV,
363
351 "<>" => sub { cmd_file $_[0] }, 364 "<>" => sub { cmd_file $_[0] },
352 or exit 1; 365 or exit 1;
353} 366}
354 367
355Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case"); 368Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case");
948EOF 961EOF
949 962
950############################################################################# 963#############################################################################
951# optional perl_init/perl_destroy 964# optional perl_init/perl_destroy
952 965
966if ($IGNORE_ENV) {
967 $IGNORE_ENV = <<EOF;
968 unsetenv ("PERL_UNICODE");
969 unsetenv ("PERL_HASH_SEED_DEBUG");
970 unsetenv ("PERL_DESTRUCT_LEVEL");
971 unsetenv ("PERL_SIGNALS");
972 unsetenv ("PERL_DEBUG_MSTATS");
973 unsetenv ("PERL5OPT");
974 unsetenv ("PERLIO_DEBUG");
975 unsetenv ("PERLIO");
976 unsetenv ("PERL_HASH_SEED");
977EOF
978} else {
979 $IGNORE_ENV = "";
980}
981
953if ($APP) { 982if ($APP) {
954 print $fh <<EOF; 983 print $fh <<EOF;
955 984
956int 985int
957main (int argc, char *argv []) 986main (int argc, char *argv [])
966 args [3] = "--"; 995 args [3] = "--";
967 996
968 for (i = 1; i < argc; ++i) 997 for (i = 1; i < argc; ++i)
969 args [i + 3] = argv [i]; 998 args [i + 3] = argv [i];
970 999
1000$IGNORE_ENV
971 PERL_SYS_INIT3 (&argc, &argv, &environ); 1001 PERL_SYS_INIT3 (&argc, &argv, &environ);
972 staticperl = perl_alloc (); 1002 staticperl = perl_alloc ();
973 perl_construct (staticperl); 1003 perl_construct (staticperl);
974 1004
975 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 1005 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
993main (int argc, char *argv []) 1023main (int argc, char *argv [])
994{ 1024{
995 extern char **environ; 1025 extern char **environ;
996 int exitstatus; 1026 int exitstatus;
997 1027
1028$IGNORE_ENV
998 PERL_SYS_INIT3 (&argc, &argv, &environ); 1029 PERL_SYS_INIT3 (&argc, &argv, &environ);
999 staticperl = perl_alloc (); 1030 staticperl = perl_alloc ();
1000 perl_construct (staticperl); 1031 perl_construct (staticperl);
1001 1032
1002 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 1033 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
1026 1057
1027 extern char **environ; 1058 extern char **environ;
1028 int argc = sizeof (args) / sizeof (args [0]); 1059 int argc = sizeof (args) / sizeof (args [0]);
1029 char **argv = args; 1060 char **argv = args;
1030 1061
1062$IGNORE_ENV
1031 PERL_SYS_INIT3 (&argc, &argv, &environ); 1063 PERL_SYS_INIT3 (&argc, &argv, &environ);
1032 staticperl = perl_alloc (); 1064 staticperl = perl_alloc ();
1033 perl_construct (staticperl); 1065 perl_construct (staticperl);
1034 PL_origalen = 1; 1066 PL_origalen = 1;
1035 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 1067 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines