[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Creating a completely standalone runtime MacPerl app



  Some time ago, there was a discussion here about creating a
completely standalone MacPerl runtime application.  Such an
application could be distributed without having to be
accompanied by any external library/header files.

  Two methods for doing so were briefly mentioned:

  - Appending the text of the relevant library/header files
    to the MacPerl script, then saving it as a runtime app.

  - Saving the script as a runtime app, then pasting the text of
    these library/header files into TEXT resources in the app.
    (As Matthias Neeracher mentioned at the time, this uses an
    undocumented feature of MacPerl.)

  These general descriptions didn't provide enough detail for
me, at least, to successfully use them to create a completely
standalone runtime app.

  As a result, I thought it worth sharing the following
"cookbook" instructions.  Perhaps others might find these
useful, as well.

  The first set of instructions, which use the first method
above, was shared with us by Dave Gillen <ds_gillen@pnl.gov>.
Dave wrote:

>It is possible to do.  Here are the steps:
>
>- take the text from a library file and insert it into your MacPerl script
>file.  Remove all of the references to the library name.  For example, if
>there was a subroutine named Foo'Bar, just change it to Bar.
>
>- create a line at the top of your Perl script file
>&MacPerl'LoadExternals("Your filename")  Don't put a pathname, just the
>filename of your standalone executable that you're going to create.
>
>- save your script as a standalone executable
>
>- copy all of the resources from the library files into the standalong
>executable
>
>Then, it should work.

  The second set of instructions use the second approach above.
Michael Alderete (of the Office of the Chancellor here at UC
Berkeley) discovered these when he examined a standalone runtime
MacPerl application--an HTML table conversion utility from the
Info-Mac archives.  (The following is my paraphrase of Michael's
instructions:)

>  Include "require" statements in your script in the following format:
>
>require "Dev:pseudo:StandardFile.pl";  # "TEXT" resource # 130.
>require "Dev:pseudo:GUSI.ph";          # "TEXT" resource # 131.
>require "Dev:pseudo:FindFolder.pl";    # "TEXT" # 129 and "XFCN" # 3956.
>
>[StandardFile.pl, GUSI.ph, and FindFolder.pl, above, are all part of the
> standard set of libraries bundled with MacPerl, and are used as
> representative examples]
>
>  As the comments on the lines above suggest, each "require" statement
>above corresponds to a 'TEXT' resource which holds the text of a
>single library or header file.  The name of each 'TEXT' resource
>corresponds to the name of the library file it holds.  (E.g. the
>'TEXT' resource whose name is "StandardFile.pl" contains the full
>text of StandardFile.pl.)
>
>  In addition, one would then need to copy the resources (e.g. XCMDs
>and XFCNs), if any, from each of these library files into the
>standalone executable.

  Comments on the relative merits of these two methods
(including any non-obvious side effects of either method ;-), as
well as any corrections to the "cookbook" instructions above,
would be appreciated!

Aron Roberts  Workstation Software Support Group . 221 Evans Hall
              University of California, Berkeley, CA 94720-3808
              aron@garnet.berkeley.edu . (510) 642-5974 . fax (510) 643-5385