--- App-Staticperl/mkbundle 2011/02/10 22:44:29 1.24 +++ App-Staticperl/mkbundle 2011/02/24 07:01:46 1.25 @@ -3,14 +3,15 @@ ############################################################################# # cannot load modules till after the tracer BEGIN block -our $VERBOSE = 1; -our $STRIP = "pod"; # none, pod or ppi -our $UNISTRIP = 1; # always on, try to strip unicore swash data -our $PERL = 0; +our $VERBOSE = 1; +our $STRIP = "pod"; # none, pod or ppi +our $UNISTRIP = 1; # always on, try to strip unicore swash data +our $PERL = 0; our $APP; -our $VERIFY = 0; -our $STATIC = 0; -our $PACKLIST = 0; +our $VERIFY = 0; +our $STATIC = 0; +our $PACKLIST = 0; +our $IGNORE_ENV = 0; our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? @@ -84,10 +85,17 @@ while (<$R_TRACER>) { if (/use (.*)$/) { my $mod = $1; - my $pkg = ++$pkg; - my $eval = $mod =~ /[^A-Za-z0-9_:]/ - ? "require $mod" - : "{ package $pkg; use $mod; }"; + my $eval; + + if ($mod =~ /^'.*'$/ or $mod =~ /^".*"$/) { + $eval = "require $mod"; + } elsif ($mod =~ y%/.%%) { + $eval = "require q\x00$mod\x00"; + } else { + my $pkg = ++$pkg; + $eval = "{ package $pkg; use $mod; }"; + } + eval $eval; warn "ERROR: $@ (while loading '$mod')\n" if $@; @@ -331,12 +339,14 @@ sub parse_argv { GetOptions - "strip=s" => \$STRIP, - "cache=s" => \$CACHE, # internal option - "verbose|v" => sub { ++$VERBOSE }, - "quiet|q" => sub { --$VERBOSE }, "perl" => \$PERL, "app=s" => \$APP, + + "verbose|v" => sub { ++$VERBOSE }, + "quiet|q" => sub { --$VERBOSE }, + + "strip=s" => \$STRIP, + "cache=s" => \$CACHE, # internal option "eval|e=s" => sub { trace_eval $_[1] }, "use|M=s" => sub { trace_module $_[1] }, "boot=s" => sub { cmd_boot $_[1] }, @@ -345,9 +355,12 @@ "incglob=s" => sub { cmd_incglob $_[1] }, "include|i=s" => sub { cmd_include $_[1], 1 }, "exclude|x=s" => sub { cmd_include $_[1], 0 }, - "static!" => \$STATIC, "usepacklists!" => \$PACKLIST, + + "static!" => \$STATIC, "staticlib=s" => sub { cmd_staticlib $_[1] }, + "ignore-env" => \$IGNORE_ENV, + "<>" => sub { cmd_file $_[0] }, or exit 1; } @@ -950,6 +963,22 @@ ############################################################################# # optional perl_init/perl_destroy +if ($IGNORE_ENV) { + $IGNORE_ENV = <