… | |
… | |
382 | =over 4 |
382 | =over 4 |
383 | |
383 | |
384 | =item C<--use> F<module> | C<-M>F<module> |
384 | =item C<--use> F<module> | C<-M>F<module> |
385 | |
385 | |
386 | Include the named module and trace direct dependencies. This is done by |
386 | Include the named module and trace direct dependencies. This is done by |
387 | C<require>'ing the module in a subprocess and tracing which other modules |
387 | C<use>'ing the module from a fresh package in a subprocess and tracing |
388 | and files it actually loads. |
388 | which other modules and files it actually loads. |
389 | |
389 | |
390 | Example: include AnyEvent and AnyEvent::Impl::Perl. |
390 | Example: include AnyEvent and AnyEvent::Impl::Perl. |
391 | |
391 | |
392 | staticperl mkbundle --use AnyEvent --use AnyEvent::Impl::Perl |
392 | staticperl mkbundle --use AnyEvent --use AnyEvent::Impl::Perl |
393 | |
393 | |
… | |
… | |
420 | code, or maybe one of the modules you use need a special use statement. In |
420 | code, or maybe one of the modules you use need a special use statement. In |
421 | that case, you can use C<--eval> to execute some perl snippet or set some |
421 | that case, you can use C<--eval> to execute some perl snippet or set some |
422 | variables or whatever you need. All files C<require>'d or C<use>'d while |
422 | variables or whatever you need. All files C<require>'d or C<use>'d while |
423 | executing the snippet are included in the final bundle. |
423 | executing the snippet are included in the final bundle. |
424 | |
424 | |
425 | Keep in mind that F<mkbundle> will only C<require> the modules named |
425 | Keep in mind that F<mkbundle> will not import any symbols from the modules |
426 | by the C<--use> option, so do not expect the symbols from modules you |
426 | named by the C<--use> option, so do not expect the symbols from modules |
427 | C<--use>'d earlier on the command line to be available. |
427 | you C<--use>'d earlier on the command line to be available. |
428 | |
428 | |
429 | Example: force L<AnyEvent> to detect a backend and therefore include it |
429 | Example: force L<AnyEvent> to detect a backend and therefore include it |
430 | in the final bundle. |
430 | in the final bundle. |
431 | |
431 | |
432 | staticperl mkbundle --eval 'use AnyEvent; AnyEvent::detect' |
432 | staticperl mkbundle --eval 'use AnyEvent; AnyEvent::detect' |
… | |
… | |
467 | --incglob '/unicore/**.pl' |
467 | --incglob '/unicore/**.pl' |
468 | |
468 | |
469 | =item C<--add> F<file> | C<--add> "F<file> alias" |
469 | =item C<--add> F<file> | C<--add> "F<file> alias" |
470 | |
470 | |
471 | Adds the given (perl) file into the bundle (and optionally call it |
471 | Adds the given (perl) file into the bundle (and optionally call it |
472 | "alias"). The F<file> is either an absolute path or a path relative to |
472 | "alias"). The F<file> is either an absolute path or a path relative to the |
473 | the current directory. If an alias is specified, then this is the name it |
473 | current directory. If an alias is specified, then this is the name it will |
474 | will use for C<@INC> searches, otherwise the F<file> will be used as the |
474 | use for C<@INC> searches, otherwise the path F<file> will be used as the |
475 | internal name. |
475 | internal name. |
476 | |
476 | |
477 | This switch is used to include extra files into the bundle. |
477 | This switch is used to include extra files into the bundle. |
478 | |
478 | |
479 | Example: embed the file F<httpd> in the current directory as F<httpd.pm> |
479 | Example: embed the file F<httpd> in the current directory as F<httpd.pm> |
480 | when creating the bundle. |
480 | when creating the bundle. |
481 | |
481 | |
482 | staticperl mkperl --add "httpd httpd.pm" |
482 | staticperl mkperl --add "httpd httpd.pm" |
|
|
483 | |
|
|
484 | # can be accessed via "use httpd" |
|
|
485 | |
|
|
486 | Example: add a file F<initcode> from the current directory. |
|
|
487 | |
|
|
488 | staticperl mkperl --add 'initcode &initcode' |
|
|
489 | |
|
|
490 | # can be accessed via "do '&initcode'" |
483 | |
491 | |
484 | Example: add local files as extra modules in the bundle. |
492 | Example: add local files as extra modules in the bundle. |
485 | |
493 | |
486 | # specification file |
494 | # specification file |
487 | add file1 myfiles/file1.pm |
495 | add file1 myfiles/file1.pm |
… | |
… | |
497 | |
505 | |
498 | Just like C<--add>, except that it treats the file as binary and adds it |
506 | Just like C<--add>, except that it treats the file as binary and adds it |
499 | without any postprocessing (perl files might get stripped to reduce their |
507 | without any postprocessing (perl files might get stripped to reduce their |
500 | size). |
508 | size). |
501 | |
509 | |
502 | You should probably add a C</> prefix to avoid clashing with embedded perl |
510 | If you specify an alias you should probably add a C<&> prefix to avoid |
503 | files (whose paths do not start with C</>), and/or use a special directory |
511 | clashing with embedded perl files (whose paths never start with C<&>), |
504 | prefix, such as C</res/name>. |
512 | and/or use a special directory prefix, such as C<&res/name>. |
505 | |
513 | |
506 | You can later get a copy of these files by calling C<staticperl::find |
514 | You can later get a copy of these files by calling C<staticperl::find |
507 | "alias">. |
515 | "alias">. |
508 | |
516 | |
509 | An alternative way to embed binary files is to convert them to perl and |
517 | An alternative way to embed binary files is to convert them to perl and |
… | |
… | |
664 | The difference to the (mutually exclusive) C<--perl> option is that the |
672 | The difference to the (mutually exclusive) C<--perl> option is that the |
665 | binary created by this option will not try to act as a perl interpreter - |
673 | binary created by this option will not try to act as a perl interpreter - |
666 | instead it will simply initialise the perl interpreter, clean it up and |
674 | instead it will simply initialise the perl interpreter, clean it up and |
667 | exit. |
675 | exit. |
668 | |
676 | |
669 | This means that, by default, it will do nothing but burna few CPU cycles |
677 | This means that, by default, it will do nothing but burn a few CPU cycles |
670 | - for it to do something useful you I<must> add some boot code, e.g. with |
678 | - for it to do something useful you I<must> add some boot code, e.g. with |
671 | the C<--boot> option. |
679 | the C<--boot> option. |
672 | |
680 | |
673 | Example: create a standalone perl binary called F<./myexe> that will |
681 | Example: create a standalone perl binary called F<./myexe> that will |
674 | execute F<appfile> when it is started. |
682 | execute F<appfile> when it is started. |
… | |
… | |
953 | A header file that contains the prototypes of the few symbols "exported" |
961 | A header file that contains the prototypes of the few symbols "exported" |
954 | by bundle.c, and also exposes the perl headers to the application. |
962 | by bundle.c, and also exposes the perl headers to the application. |
955 | |
963 | |
956 | =over 4 |
964 | =over 4 |
957 | |
965 | |
958 | =item staticperl_init () |
966 | =item staticperl_init (xs_init = 0) |
959 | |
967 | |
960 | Initialises the perl interpreter. You can use the normal perl functions |
968 | Initialises the perl interpreter. You can use the normal perl functions |
961 | after calling this function, for example, to define extra functions or |
969 | after calling this function, for example, to define extra functions or |
962 | to load a .pm file that contains some initialisation code, or the main |
970 | to load a .pm file that contains some initialisation code, or the main |
963 | program function: |
971 | program function: |
… | |
… | |
970 | } |
978 | } |
971 | |
979 | |
972 | static void |
980 | static void |
973 | run_myapp(void) |
981 | run_myapp(void) |
974 | { |
982 | { |
975 | staticperl_init (); |
983 | staticperl_init (0); |
976 | newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$"); |
984 | newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$"); |
977 | eval_pv ("require myapp::main", 1); // executes "myapp/main.pm" |
985 | eval_pv ("require myapp::main", 1); // executes "myapp/main.pm" |
978 | } |
986 | } |
979 | |
987 | |
|
|
988 | When your bootcode already wants to access some XS functions at |
|
|
989 | compiletime, then you need to supply an C<xs_init> function pointer that |
|
|
990 | is called as soon as perl is initialised enough to define XS functions, |
|
|
991 | but before the preamble code is executed: |
|
|
992 | |
|
|
993 | static void |
|
|
994 | xs_init (pTHX) |
|
|
995 | { |
|
|
996 | newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$"); |
|
|
997 | } |
|
|
998 | |
|
|
999 | static void |
|
|
1000 | run_myapp(void) |
|
|
1001 | { |
|
|
1002 | staticperl_init (xs_init); |
|
|
1003 | } |
|
|
1004 | |
|
|
1005 | =item staticperl_cleanup () |
|
|
1006 | |
|
|
1007 | In the unlikely case that you want to destroy the perl interpreter, here |
|
|
1008 | is the corresponding function. |
|
|
1009 | |
980 | =item staticperl_xs_init (pTHX) |
1010 | =item staticperl_xs_init (pTHX) |
981 | |
1011 | |
982 | Sometimes you need direct control over C<perl_parse> and C<perl_run>, in |
1012 | Sometimes you need direct control over C<perl_parse> and C<perl_run>, in |
983 | which case you do not want to use C<staticperl_init> but call them on your |
1013 | which case you do not want to use C<staticperl_init> but call them on your |
984 | own. |
1014 | own. |
985 | |
1015 | |
986 | Then you need this function - either pass it directly as the C<xs_init> |
1016 | Then you need this function - either pass it directly as the C<xs_init> |
987 | function to C<perl_parse>, or call it from your own C<xs_init> function. |
1017 | function to C<perl_parse>, or call it as one of the first things from your |
988 | |
1018 | own C<xs_init> function. |
989 | =item staticperl_cleanup () |
|
|
990 | |
|
|
991 | In the unlikely case that you want to destroy the perl interpreter, here |
|
|
992 | is the corresponding function. |
|
|
993 | |
1019 | |
994 | =item PerlInterpreter *staticperl |
1020 | =item PerlInterpreter *staticperl |
995 | |
1021 | |
996 | The perl interpreter pointer used by staticperl. Not normally so useful, |
1022 | The perl interpreter pointer used by staticperl. Not normally so useful, |
997 | but there it is. |
1023 | but there it is. |