… | |
… | |
84 | With F<staticperl>, the burden is mostly with the developer - only direct |
84 | With F<staticperl>, the burden is mostly with the developer - only direct |
85 | compile-time dependencies and L<AutoLoader> are handled automatically. |
85 | compile-time dependencies and L<AutoLoader> are handled automatically. |
86 | This means the modules to include often need to be tweaked manually. |
86 | This means the modules to include often need to be tweaked manually. |
87 | |
87 | |
88 | All this does not preclude more permissive modes to be implemented in |
88 | All this does not preclude more permissive modes to be implemented in |
89 | the future, but right now, you have to resolve state hidden dependencies |
89 | the future, but right now, you have to resolve hidden dependencies |
90 | manually. |
90 | manually. |
91 | |
91 | |
92 | =item * PAR works out of the box, F<staticperl> does not. |
92 | =item * PAR works out of the box, F<staticperl> does not. |
93 | |
93 | |
94 | Maintaining your own custom perl build can be a pain in the ass, and while |
94 | Maintaining your own custom perl build can be a pain in the ass, and while |
… | |
… | |
202 | =item F<staticperl cpan> [args...] |
202 | =item F<staticperl cpan> [args...] |
203 | |
203 | |
204 | Starts an interactive CPAN shell that you can use to install further |
204 | Starts an interactive CPAN shell that you can use to install further |
205 | modules. Installs the perl first if necessary, but apart from that, |
205 | modules. Installs the perl first if necessary, but apart from that, |
206 | no magic is involved: you could just as well run it manually via |
206 | no magic is involved: you could just as well run it manually via |
207 | F<~/.staticperl/perl/bin/cpan>. |
207 | F<~/.staticperl/perl/bin/cpan>, except that F<staticperl> additionally |
|
|
208 | sets the environment variable C<$PERL> to the path of the perl |
|
|
209 | interpreter, which is handy in subshells. |
208 | |
210 | |
209 | Any additional arguments are simply passed to the F<cpan> command. |
211 | Any additional arguments are simply passed to the F<cpan> command. |
210 | |
212 | |
211 | =item F<staticperl instcpan> module... |
213 | =item F<staticperl instcpan> module... |
212 | |
214 | |
… | |
… | |
547 | |
549 | |
548 | Just like C<--add>, except that it treats the file as binary and adds it |
550 | Just like C<--add>, except that it treats the file as binary and adds it |
549 | without any postprocessing (perl files might get stripped to reduce their |
551 | without any postprocessing (perl files might get stripped to reduce their |
550 | size). |
552 | size). |
551 | |
553 | |
552 | If you specify an alias you should probably add a C<&> prefix to avoid |
554 | If you specify an alias you should probably add a C</> prefix to avoid |
553 | clashing with embedded perl files (whose paths never start with C<&>), |
555 | clashing with embedded perl files (whose paths never start with C</>), |
554 | and/or use a special directory prefix, such as C<&res/name>. |
556 | and/or use a special directory prefix, such as C</res/name>. |
555 | |
557 | |
556 | You can later get a copy of these files by calling C<staticperl::find |
558 | You can later get a copy of these files by calling C<static::find |
557 | "alias">. |
559 | "alias">. |
558 | |
560 | |
559 | An alternative way to embed binary files is to convert them to perl and |
561 | An alternative way to embed binary files is to convert them to perl and |
560 | use C<do> to get the contents - this method is a bit cumbersome, but works |
562 | use C<do> to get the contents - this method is a bit cumbersome, but works |
561 | both inside and outside of a staticperl bundle: |
563 | both inside and outside of a staticperl bundle, without extra ado: |
562 | |
564 | |
563 | # a "binary" file, call it "bindata.pl" |
565 | # a "binary" file, call it "bindata.pl" |
564 | <<'SOME_MARKER' |
566 | <<'SOME_MARKER' |
565 | binary data NOT containing SOME_MARKER |
567 | binary data NOT containing SOME_MARKER |
566 | SOME_MARKER |
568 | SOME_MARKER |
567 | |
569 | |
568 | # load the binary |
570 | # load the binary |
569 | chomp (my $data = do "bindata.pl"); |
571 | chomp (my $data = do "bindata.pl"); |
|
|
572 | |
|
|
573 | =item C<--allow-dynamic> |
|
|
574 | |
|
|
575 | By default, when F<mkbundle> hits a dynamic perl extension (e.g. a F<.so> |
|
|
576 | or F<.dll> file), it will stop with a fatal error. |
|
|
577 | |
|
|
578 | When this option is enabled, F<mkbundle> packages the shared |
|
|
579 | object into the bundle instead, with a prefix of F<!> |
|
|
580 | (e.g. F<!auto/List/Util/Util.so>). What you do with that is currently up |
|
|
581 | to you, F<staticperl> has no special support for this at the moment, apart |
|
|
582 | from working around the lack of availability of F<PerlIO::scalar> while |
|
|
583 | bootstrapping, at a speed cost. |
|
|
584 | |
|
|
585 | One way to deal with this is to write all files starting with F<!> into |
|
|
586 | some directory and then C<unshift> that path onto C<@INC>. |
|
|
587 | |
|
|
588 | #TODO: example |
570 | |
589 | |
571 | =back |
590 | =back |
572 | |
591 | |
573 | =item Step 2: filter all files using C<--include> and C<--exclude> options. |
592 | =item Step 2: filter all files using C<--include> and C<--exclude> options. |
574 | |
593 | |
… | |
… | |
897 | about as big as 5.12.3). |
916 | about as big as 5.12.3). |
898 | |
917 | |
899 | =item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ... |
918 | =item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ... |
900 | |
919 | |
901 | Usually set to C<1> to make modules "less inquisitive" during their |
920 | Usually set to C<1> to make modules "less inquisitive" during their |
902 | installation, you can set any environment variable you want - some modules |
921 | installation. You can set (and export!) any environment variable you want |
903 | (such as L<Coro> or L<EV>) use environment variables for further tweaking. |
922 | - some modules (such as L<Coro> or L<EV>) use environment variables for |
|
|
923 | further tweaking. |
904 | |
924 | |
905 | =item C<PERL_PREFIX> |
925 | =item C<PERL_PREFIX> |
906 | |
926 | |
907 | The prefix where perl gets installed (default: F<$STATICPERL/perl>), |
927 | The prefix where perl gets installed (default: F<$STATICPERL/perl>), |
908 | i.e. where the F<bin> and F<lib> subdirectories will end up. |
928 | i.e. where the F<bin> and F<lib> subdirectories will end up. |
… | |
… | |
1121 | |
1141 | |
1122 | =back |
1142 | =back |
1123 | |
1143 | |
1124 | =head1 RUNTIME FUNCTIONALITY |
1144 | =head1 RUNTIME FUNCTIONALITY |
1125 | |
1145 | |
1126 | Binaries created with C<mkbundle>/C<mkperl> contain extra functions, which |
1146 | Binaries created with C<mkbundle>/C<mkperl> contain extra functionality, |
1127 | are required to access the bundled perl sources, but might be useful for |
1147 | mostly related to the extra files bundled in the binary (the virtual |
1128 | other purposes. |
1148 | filesystem). All of this data is statically compiled into the binary, and |
|
|
1149 | accessing means copying it from a read-only section of your binary. Data |
|
|
1150 | pages in this way is usually freed by the operating system, as it isn't |
|
|
1151 | use more the onace. |
|
|
1152 | |
|
|
1153 | =head2 VIRTUAL FILESYSTEM |
|
|
1154 | |
|
|
1155 | Every bundle has a virtual filesystem. The only information stored in it |
|
|
1156 | is the path and contents of each file that was bundled. |
|
|
1157 | |
|
|
1158 | =head3 LAYOUT |
|
|
1159 | |
|
|
1160 | Any path starting with an ampersand (F<&>) or exclamation mark (F<!>) are |
|
|
1161 | reserved by F<staticperl>. They must only be used as described in this |
|
|
1162 | section. |
|
|
1163 | |
|
|
1164 | =over 4 |
|
|
1165 | |
|
|
1166 | =item ! |
|
|
1167 | |
|
|
1168 | All files that typically cannot be loaded from memory (such as dynamic |
|
|
1169 | objects or shared libraries), but have to reside in the filesystem, are |
|
|
1170 | prefixed with F<!>. Typically these files get written out to some |
|
|
1171 | (semi-)temporary directory shortly after program startup, or before being |
|
|
1172 | used. |
|
|
1173 | |
|
|
1174 | =item !boot |
|
|
1175 | |
|
|
1176 | The bootstrap file, if specified during bundling. |
|
|
1177 | |
|
|
1178 | =item !auto/ |
|
|
1179 | |
|
|
1180 | Shared objects or dlls corresponding to dynamically-linked perl extensions |
|
|
1181 | are stored with an F<!auto/> prefix. |
|
|
1182 | |
|
|
1183 | =item !lib/ |
|
|
1184 | |
|
|
1185 | External shared libraries are stored in this directory. |
|
|
1186 | |
|
|
1187 | =item any letter |
|
|
1188 | |
|
|
1189 | Any path starting with a letter is a perl library file. For example, |
|
|
1190 | F<Coro/AIO.pm> corresponds to the file loaded by C<use Coro::AIO>, and |
|
|
1191 | F<Coro/jit.pl> corresponds to C<require "Coro/jit.pl">. |
|
|
1192 | |
|
|
1193 | Obviously, module names shouldn't start with any other characters than |
|
|
1194 | letters :) |
|
|
1195 | |
|
|
1196 | =back |
|
|
1197 | |
|
|
1198 | =head3 FUNCTIONS |
|
|
1199 | |
|
|
1200 | =over 4 |
|
|
1201 | |
|
|
1202 | =item $file = static::find $path |
|
|
1203 | |
|
|
1204 | Returns the data associated with the given C<$path> |
|
|
1205 | (e.g. C<Digest/MD5.pm>, C<auto/POSIX/autosplit.ix>). |
|
|
1206 | |
|
|
1207 | Returns C<undef> if the file isn't embedded. |
|
|
1208 | |
|
|
1209 | =item @paths = static::list |
|
|
1210 | |
|
|
1211 | Returns the list of all paths embedded in this binary. |
|
|
1212 | |
|
|
1213 | =back |
|
|
1214 | |
|
|
1215 | =head2 EXTRA FEATURES |
1129 | |
1216 | |
1130 | In addition, for the embedded loading of perl files to work, F<staticperl> |
1217 | In addition, for the embedded loading of perl files to work, F<staticperl> |
1131 | overrides the C<@INC> array. |
1218 | overrides the C<@INC> array. |
1132 | |
|
|
1133 | =over 4 |
|
|
1134 | |
|
|
1135 | =item $file = staticperl::find $path |
|
|
1136 | |
|
|
1137 | Returns the data associated with the given C<$path> |
|
|
1138 | (e.g. C<Digest/MD5.pm>, C<auto/POSIX/autosplit.ix>), which is basically |
|
|
1139 | the UNIX path relative to the perl library directory. |
|
|
1140 | |
|
|
1141 | Returns C<undef> if the file isn't embedded. |
|
|
1142 | |
|
|
1143 | =item @paths = staticperl::list |
|
|
1144 | |
|
|
1145 | Returns the list of all paths embedded in this binary. |
|
|
1146 | |
|
|
1147 | =back |
|
|
1148 | |
1219 | |
1149 | =head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT |
1220 | =head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT |
1150 | |
1221 | |
1151 | To make truly static (Linux-) libraries, you might want to have a look at |
1222 | To make truly static (Linux-) libraries, you might want to have a look at |
1152 | buildroot (L<http://buildroot.uclibc.org/>). |
1223 | buildroot (L<http://buildroot.uclibc.org/>). |