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

Comparing cvsroot/App-Staticperl/mkbundle (file contents):
Revision 1.27 by root, Thu Feb 24 14:35:38 2011 UTC vs.
Revision 1.28 by root, Sat Jul 9 18:26:27 2011 UTC

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; 14our $IGNORE_ENV = 0;
15our $ALLOW_DLLS = 0;
16our $HAVE_DLLS; # maybe useful?
15 17
16our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? 18our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression?
17 19
18our $CACHE; 20our $CACHE;
19our $CACHEVER = 1; # do not change unless you know what you are doing 21our $CACHEVER = 1; # do not change unless you know what you are doing
357 "exclude|x=s" => sub { cmd_include $_[1], 0 }, 359 "exclude|x=s" => sub { cmd_include $_[1], 0 },
358 "usepacklists!" => \$PACKLIST, 360 "usepacklists!" => \$PACKLIST,
359 361
360 "static!" => \$STATIC, 362 "static!" => \$STATIC,
361 "staticlib=s" => sub { cmd_staticlib $_[1] }, 363 "staticlib=s" => sub { cmd_staticlib $_[1] },
364 "allow-dlls" => \$ALLOW_DLLS,
362 "ignore-env" => \$IGNORE_ENV, 365 "ignore-env" => \$IGNORE_ENV,
363 366
364 "<>" => sub { cmd_file $_[0] }, 367 "<>" => sub { cmd_file $_[0] },
365 or exit 1; 368 or exit 1;
366} 369}
475 push @libs, "$autodir/$base$Config{_a}"; 478 push @libs, "$autodir/$base$Config{_a}";
476 push @static_ext, $pm; 479 push @static_ext, $pm;
477 } 480 }
478 481
479 # dynamic object 482 # dynamic object
480 die "ERROR: found shared object - can't link statically ($_)\n"
481 if -f "$autodir/$base.$Config{dlext}"; 483 if (-f "$autodir/$base.$Config{dlext}") {
484 if ($ALLOW_DLLS) {
485 my $as = "&fs/perl/$auto/$base.$Config{dlext}";
486 $pm{$as} = "$autodir/$base.$Config{dlext}";
487 $pmbin{$as} = 1;
488
489 $HAVE_DLLS = 1;
490
491 print "+ added dynamic object $auto/$base.$Config{dlext}\n"
492 if $VERBOSE >= 3;
493 } else {
494 die "ERROR: found shared object '$_' but --allow-dlls not given, aborting.\n"
495 }
496 }
482 497
483 if ($PACKLIST && open my $fh, "<:perlio", "$autodir/.packlist") { 498 if ($PACKLIST && open my $fh, "<:perlio", "$autodir/.packlist") {
484 print "found .packlist for $pm\n" 499 print "found .packlist for $pm\n"
485 if $VERBOSE >= 3; 500 if $VERBOSE >= 3;
486 501
803# bootstrap 818# bootstrap
804 819
805# boot file for staticperl 820# boot file for staticperl
806# this file will be eval'ed at initialisation time 821# this file will be eval'ed at initialisation time
807 822
823# lines marked with "^D" are only used when $HAVE_DLLS
808my $bootstrap = ' 824my $bootstrap = '
809BEGIN { 825BEGIN {
810 package ' . $PACKAGE . '; 826 package ' . $PACKAGE . ';
811 827
812 PerlIO::scalar->bootstrap; 828 # the path prefix to use when putting files into %INC
829 our $inc_prefix;
813 830
814 @INC = sub { 831 # the @INC hook to use when we have PerlIO::scalar available
832 my $perlio_inc = sub {
815 my $data = find "$_[1]" 833 my $data = find "$_[1]"
816 or return; 834 or return;
817 835
818 $INC{$_[1]} = $_[1]; 836 $INC{$_[1]} = "$inc_prefix$_[1]";
819 837
820 open my $fh, "<", \$data; 838 open my $fh, "<", \$data;
821 $fh 839 $fh
822 }; 840 };
841
842D if (defined &PerlIO::scalar::bootstrap) {
843 # PerlIO::scalar statically compiled in
844 PerlIO::scalar->bootstrap;
845 @INC = $perlio_inc;
846D } else {
847D # PerlIO::scalar not available, use slower method
848D @INC = sub {
849D # always check if PerlIO::scalar might now be available
850D if (defined &PerlIO::scalar::bootstrap) {
851D # switch to the faster perlio_inc hook
852D @INC = map { $_ == $_[0] ? $perlio_inc : $_ } @INC;
853D goto &$perlio_inc;
854D }
855D
856D my $data = find "$_[1]"
857D or return;
858D
859D $INC{$_[1]} = "$inc_prefix$_[1]";
860D
861D sub {
862D $data =~ /\G([^\n]*\n?)/g
863D or return;
864D
865D $_ = $1;
866D 1
867D }
868D };
869D }
823} 870}
824'; 871';
825 872
826$bootstrap .= "require '&&boot';" 873$bootstrap .= "require '&&boot';"
827 if exists $pm{"&&boot"}; 874 if exists $pm{"&&boot"};
828 875
876if ($HAVE_DLLS) {
877 $bootstrap =~ s/^D/ /mg;
878} else {
879 $bootstrap =~ s/^D.*$//mg;
880}
881
882$bootstrap =~ s/#.*$//mg;
829$bootstrap =~ s/\s+/ /g; 883$bootstrap =~ s/\s+/ /g;
830$bootstrap =~ s/(\W) /$1/g; 884$bootstrap =~ s/(\W) /$1/g;
831$bootstrap =~ s/ (\W)/$1/g; 885$bootstrap =~ s/ (\W)/$1/g;
832 886
833print $fh "const char bootstrap [] = "; 887print $fh "const char bootstrap [] = ";
879 } 933 }
880 934
881 XSRETURN (0); 935 XSRETURN (0);
882 936
883 found: 937 found:
884 ST (0) = res; 938 ST (0) = sv_2mortal (res);
885 sv_2mortal (ST (0));
886 } 939 }
887 940
888 XSRETURN (1); 941 XSRETURN (1);
889} 942}
890 943
903 956
904 for (i = 0; i < $varpfx\_count; ++i) 957 for (i = 0; i < $varpfx\_count; ++i)
905 { 958 {
906 U32 idx = $varpfx\_index [i]; 959 U32 idx = $varpfx\_index [i];
907 960
908 PUSHs (newSVpvn ($varpfx\_data + (idx & 0x1FFFFFFU), idx >> 25)); 961 PUSHs (sv_2mortal (newSVpvn ($varpfx\_data + (idx & 0x1FFFFFFU), idx >> 25)));
909 } 962 }
910 } 963 }
911 964
912 XSRETURN ($varpfx\_count); 965 XSRETURN ($varpfx\_count);
913} 966}
921void 974void
922staticperl_xs_init (pTHX) 975staticperl_xs_init (pTHX)
923{ 976{
924EOF 977EOF
925 978
926@static_ext = ("DynaLoader", sort @static_ext); 979@static_ext = sort @static_ext;
927 980
928# prototypes 981# prototypes
929for (@static_ext) { 982for (@static_ext) {
930 s/\.pm$//; 983 s/\.pm$//;
931 (my $cname = $_) =~ s/\//__/g; 984 (my $cname = $_) =~ s/\//__/g;
945 s/\.pm$//; 998 s/\.pm$//;
946 999
947 (my $cname = $_) =~ s/\//__/g; 1000 (my $cname = $_) =~ s/\//__/g;
948 (my $pname = $_) =~ s/\//::/g; 1001 (my $pname = $_) =~ s/\//::/g;
949 1002
950 my $bootstrap = $pname eq "DynaLoader" ? "boot" : "bootstrap"; 1003 my $bootstrap = $pname eq "DynaLoader" ? "boot_DynaLoader" : "bootstrap";
951 1004
952 print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n"; 1005 print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n";
953} 1006}
954 1007
955print $fh <<EOF; 1008print $fh <<EOF;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines