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.31 by root, Thu Dec 23 14:16:25 2010 UTC vs.
Revision 1.35 by root, Thu Feb 10 22:44:29 2011 UTC

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
386Include the named module and trace direct dependencies. This is done by 386Include the named module and trace direct dependencies. This is done by
387C<require>'ing the module in a subprocess and tracing which other modules 387C<use>'ing the module from a fresh package in a subprocess and tracing
388and files it actually loads. 388which other modules and files it actually loads.
389 389
390Example: include AnyEvent and AnyEvent::Impl::Perl. 390Example: 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
420code, or maybe one of the modules you use need a special use statement. In 420code, or maybe one of the modules you use need a special use statement. In
421that case, you can use C<--eval> to execute some perl snippet or set some 421that case, you can use C<--eval> to execute some perl snippet or set some
422variables or whatever you need. All files C<require>'d or C<use>'d while 422variables or whatever you need. All files C<require>'d or C<use>'d while
423executing the snippet are included in the final bundle. 423executing the snippet are included in the final bundle.
424 424
425Keep in mind that F<mkbundle> will only C<require> the modules named 425Keep in mind that F<mkbundle> will not import any symbols from the modules
426by the C<--use> option, so do not expect the symbols from modules you 426named by the C<--use> option, so do not expect the symbols from modules
427C<--use>'d earlier on the command line to be available. 427you C<--use>'d earlier on the command line to be available.
428 428
429Example: force L<AnyEvent> to detect a backend and therefore include it 429Example: force L<AnyEvent> to detect a backend and therefore include it
430in the final bundle. 430in 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
471Adds the given (perl) file into the bundle (and optionally call it 471Adds 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
473the current directory. If an alias is specified, then this is the name it 473current directory. If an alias is specified, then this is the name it will
474will use for C<@INC> searches, otherwise the F<file> will be used as the 474use for C<@INC> searches, otherwise the path F<file> will be used as the
475internal name. 475internal name.
476 476
477This switch is used to include extra files into the bundle. 477This switch is used to include extra files into the bundle.
478 478
479Example: embed the file F<httpd> in the current directory as F<httpd.pm> 479Example: embed the file F<httpd> in the current directory as F<httpd.pm>
480when creating the bundle. 480when 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
486Example: 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
484Example: add local files as extra modules in the bundle. 492Example: 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
498Just like C<--add>, except that it treats the file as binary and adds it 506Just like C<--add>, except that it treats the file as binary and adds it
499without any postprocessing (perl files might get stripped to reduce their 507without any postprocessing (perl files might get stripped to reduce their
500size). 508size).
501 509
502You should probably add a C</> prefix to avoid clashing with embedded perl 510If you specify an alias you should probably add a C<&> prefix to avoid
503files (whose paths do not start with C</>), and/or use a special directory 511clashing with embedded perl files (whose paths never start with C<&>),
504prefix, such as C</res/name>. 512and/or use a special directory prefix, such as C<&res/name>.
505 513
506You can later get a copy of these files by calling C<staticperl::find 514You can later get a copy of these files by calling C<staticperl::find
507"alias">. 515"alias">.
508 516
509An alternative way to embed binary files is to convert them to perl and 517An alternative way to embed binary files is to convert them to perl and
664The difference to the (mutually exclusive) C<--perl> option is that the 672The difference to the (mutually exclusive) C<--perl> option is that the
665binary created by this option will not try to act as a perl interpreter - 673binary created by this option will not try to act as a perl interpreter -
666instead it will simply initialise the perl interpreter, clean it up and 674instead it will simply initialise the perl interpreter, clean it up and
667exit. 675exit.
668 676
669This means that, by default, it will do nothing but burna few CPU cycles 677This 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
671the C<--boot> option. 679the C<--boot> option.
672 680
673Example: create a standalone perl binary called F<./myexe> that will 681Example: create a standalone perl binary called F<./myexe> that will
674execute F<appfile> when it is started. 682execute F<appfile> when it is started.
953A header file that contains the prototypes of the few symbols "exported" 961A header file that contains the prototypes of the few symbols "exported"
954by bundle.c, and also exposes the perl headers to the application. 962by 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
960Initialises the perl interpreter. You can use the normal perl functions 968Initialises the perl interpreter. You can use the normal perl functions
961after calling this function, for example, to define extra functions or 969after calling this function, for example, to define extra functions or
962to load a .pm file that contains some initialisation code, or the main 970to load a .pm file that contains some initialisation code, or the main
963program function: 971program 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
988When your bootcode already wants to access some XS functions at
989compiletime, then you need to supply an C<xs_init> function pointer that
990is called as soon as perl is initialised enough to define XS functions,
991but 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
1007In the unlikely case that you want to destroy the perl interpreter, here
1008is the corresponding function.
1009
980=item staticperl_xs_init (pTHX) 1010=item staticperl_xs_init (pTHX)
981 1011
982Sometimes you need direct control over C<perl_parse> and C<perl_run>, in 1012Sometimes you need direct control over C<perl_parse> and C<perl_run>, in
983which case you do not want to use C<staticperl_init> but call them on your 1013which case you do not want to use C<staticperl_init> but call them on your
984own. 1014own.
985 1015
986Then you need this function - either pass it directly as the C<xs_init> 1016Then you need this function - either pass it directly as the C<xs_init>
987function to C<perl_parse>, or call it from your own C<xs_init> function. 1017function to C<perl_parse>, or call it as one of the first things from your
988 1018own C<xs_init> function.
989=item staticperl_cleanup ()
990
991In the unlikely case that you want to destroy the perl interpreter, here
992is the corresponding function.
993 1019
994=item PerlInterpreter *staticperl 1020=item PerlInterpreter *staticperl
995 1021
996The perl interpreter pointer used by staticperl. Not normally so useful, 1022The perl interpreter pointer used by staticperl. Not normally so useful,
997but there it is. 1023but there it is.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines