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

Comparing App-Staticperl/staticperl.pod (file contents):
Revision 1.47 by root, Sat Jul 9 18:26:27 2011 UTC vs.
Revision 1.48 by root, Sun Jul 10 01:37:56 2011 UTC

549 549
550Just like C<--add>, except that it treats the file as binary and adds it 550Just like C<--add>, except that it treats the file as binary and adds it
551without any postprocessing (perl files might get stripped to reduce their 551without any postprocessing (perl files might get stripped to reduce their
552size). 552size).
553 553
554If you specify an alias you should probably add a C<&> prefix to avoid 554If you specify an alias you should probably add a C</> prefix to avoid
555clashing with embedded perl files (whose paths never start with C<&>), 555clashing with embedded perl files (whose paths never start with C</>),
556and/or use a special directory prefix, such as C<&res/name>. 556and/or use a special directory prefix, such as C</res/name>.
557 557
558You can later get a copy of these files by calling C<staticperl::find 558You can later get a copy of these files by calling C<staticperl::find
559"alias">. 559"alias">.
560 560
561An alternative way to embed binary files is to convert them to perl and 561An alternative way to embed binary files is to convert them to perl and
562use C<do> to get the contents - this method is a bit cumbersome, but works 562use C<do> to get the contents - this method is a bit cumbersome, but works
563both inside and outside of a staticperl bundle: 563both inside and outside of a staticperl bundle, without extra ado:
564 564
565 # a "binary" file, call it "bindata.pl" 565 # a "binary" file, call it "bindata.pl"
566 <<'SOME_MARKER' 566 <<'SOME_MARKER'
567 binary data NOT containing SOME_MARKER 567 binary data NOT containing SOME_MARKER
568 SOME_MARKER 568 SOME_MARKER
569 569
570 # load the binary 570 # load the binary
571 chomp (my $data = do "bindata.pl"); 571 chomp (my $data = do "bindata.pl");
572 572
573=item C<--allow-dlls> 573=item C<--allow-dynamic>
574 574
575By default, when F<mkbundle> hits a dynamic perl extension (e.g. a F<.so> 575By default, when F<mkbundle> hits a dynamic perl extension (e.g. a F<.so>
576or F<.dll> file), it will stop with a fatal error. 576or F<.dll> file), it will stop with a fatal error.
577 577
578This option instead packages the shared object into the bundle, with a 578When this option is enabled, F<mkbundle> packages the shared
579prefix of F<&fs/perl/> (e.g. F<&fs/perl/auto/List/Util/Util.so>). What you 579object into the bundle instead, with a prefix of F<!>
580do with that is up to you, F<staticperl> has no special support for this 580(e.g. F<!auto/List/Util/Util.so>). What you do with that is currently up
581at the moment, apart from working around the lack of availability of 581to you, F<staticperl> has no special support for this at the moment, apart
582F<PerlIO::scalar> while bootstrapping, at a speed cost. 582from working around the lack of availability of F<PerlIO::scalar> while
583bootstrapping, at a speed cost.
583 584
584One way to deal with this is to write all files starting with F<&fs/> into 585One way to deal with this is to write all files starting with F<!> into
585some directory and C<unshift>ing the path corresponding to F<&fs/perl/> 586some directory and then C<unshift> that path onto C<@INC>.
586onto C<@INC>.
587 587
588#TODO: example 588#TODO: example
589 589
590=back 590=back
591 591
1141 1141
1142=back 1142=back
1143 1143
1144=head1 RUNTIME FUNCTIONALITY 1144=head1 RUNTIME FUNCTIONALITY
1145 1145
1146Binaries created with C<mkbundle>/C<mkperl> contain extra functions, which 1146Binaries created with C<mkbundle>/C<mkperl> contain extra functionality,
1147are required to access the bundled perl sources, but might be useful for 1147mostly related to the extra files bundled in the binary (the virtual
1148other purposes. 1148filesystem). All of this data is statically compiled into the binary, and
1149accessing means copying it from a read-only section of your binary. Data
1150pages in this way is usually freed by the operating system, as it isn't
1151use more the onace.
1152
1153=head2 VIRTUAL FILESYSTEM
1154
1155Every bundle has a virtual filesystem. The only information stored in it
1156is the path and contents of each file that was bundled.
1157
1158=head3 LAYOUT
1159
1160Any path starting with an ampersand (F<&>) or exclamation mark (F<!>) are
1161reserved by F<staticperl>. They must only be used as described in this
1162section.
1163
1164=over 4
1165
1166=item !
1167
1168All files that typically cannot be loaded from memory (such as dynamic
1169objects or shared libraries), but have to reside in the filesystem, are
1170prefixed with F<!>. Typically these files get written out to some
1171(semi-)temporary directory shortly after program startup, or before being
1172used.
1173
1174=item !boot
1175
1176The bootstrap file, if specified during bundling.
1177
1178=item !auto/
1179
1180Shared objects or dlls corresponding to dynamically-linked perl extensions
1181are stored with an F<!auto/> prefix.
1182
1183=item !lib/
1184
1185External shared libraries are stored in this directory.
1186
1187=item any letter
1188
1189Any path starting with a letter is a perl library file. For example,
1190F<Coro/AIO.pm> corresponds to the file loaded by C<use Coro::AIO>, and
1191F<Coro/jit.pl> corresponds to C<require "Coro/jit.pl">.
1192
1193Obviously, module names shouldn't start with any other characters than
1194letters :)
1195
1196=back
1197
1198=head3 FUNCTIONS
1199
1200=over 4
1201
1202=item $file = staticperl::find $path
1203
1204Returns the data associated with the given C<$path>
1205(e.g. C<Digest/MD5.pm>, C<auto/POSIX/autosplit.ix>).
1206
1207Returns C<undef> if the file isn't embedded.
1208
1209=item @paths = staticperl::list
1210
1211Returns the list of all paths embedded in this binary.
1212
1213=back
1214
1215=head2 EXTRA FEATURES
1149 1216
1150In addition, for the embedded loading of perl files to work, F<staticperl> 1217In addition, for the embedded loading of perl files to work, F<staticperl>
1151overrides the C<@INC> array. 1218overrides the C<@INC> array.
1152
1153=over 4
1154
1155=item $file = staticperl::find $path
1156
1157Returns the data associated with the given C<$path>
1158(e.g. C<Digest/MD5.pm>, C<auto/POSIX/autosplit.ix>), which is basically
1159the UNIX path relative to the perl library directory.
1160
1161Returns C<undef> if the file isn't embedded.
1162
1163=item @paths = staticperl::list
1164
1165Returns the list of all paths embedded in this binary.
1166
1167=back
1168 1219
1169=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT 1220=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT
1170 1221
1171To make truly static (Linux-) libraries, you might want to have a look at 1222To make truly static (Linux-) libraries, you might want to have a look at
1172buildroot (L<http://buildroot.uclibc.org/>). 1223buildroot (L<http://buildroot.uclibc.org/>).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines