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

Re: [MacPerl] Help with standalones



At 20.28 9/9/97, Brian Eaton wrote:
>1)  I was subscribed to the list under a different e-mail address for a
>couple of months last year, and recall seeing a script to perform some of
>the heavy labor in creating a standalone (ie searching through the script
>to get a list of all the libraries required, and adding them as TEXT
>resources).  I thought I saved a copy of this handy little thing, but can't
>locate it on my hard drive or CPAN.  Does anybody have a copy they could
>e-mail me?

Below is an e-mail message containing code that can help.  Use at your own
peril; I'm not sure if it is totally finished code.  Maybe the author can
help/bring us up to date (I don't think much was posted after this)?

--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])



From: ziege@ito.umnw.ethz.ch
X-Sender: ziege@baikal.ethz.ch
Mime-Version: 1.0
Date: Sat, 26 Apr 1997 19:42:04 +0200
To: mac-perl@iis.ee.ethz.ch
Subject: Re: [MacPerl] Howto import modules ...
X-MIME-Autoconverted: from quoted-printable to 8bit by err.ethz.ch id TAA09573
Sender: owner-mac-perl@iis.ee.ethz.ch
Precedence: bulk

As the logical next step toward building a standalone app I modified the
droplet slightly so it allows to drop a runtime version and saves the
imported modules as 'TEXT' resources directly into the file:

#"ExtractModules.dp"
#=========================================
#!perl

use Mac::Resources;
use Mac::Memory;

#ARGV now in scalar context (thanks to Bart and Chris)
$res= OpenResFile($ARGV[0]) || die $^E;

#first 'TEXT' resource is source code:
$sourceCodeRes= Get1IndResource('TEXT', 1);
$sourceCodeText= $sourceCodeRes-> get();

#clear the hash:
undef(%INC);

#suppress warnings about redefining subroutines
#by 'eval(use...)':
local $^W = 0;

#angle operator doesn't work here(?):
@sourceCodeText= split /\n/, $sourceCodeText;
for (@sourceCodeText){
        if(/^use.*;/){
                eval($_); #read the %INC
        }
}

$id= 5000;
foreach $libFileName(keys %INC) {
        $aText= "";

        open(libFile, $INC{$libFileName}) or die $^E;
        while(<libFile>){
                $aText.= $_;
        }
        $codeHand= new Handle($aText);

        #UNIX-> Mac Folder
        $libFileName=~ s/\//:/g;
        AddResource($codeHand, 'TEXT', $id, $libFileName) or die $^E;
        WriteResource($codeHand) or die $^E;;
        ReleaseResource($codeHand) or die $^E;;
        $codeHand-> dispose;
        $id++;
        print "Copied module ".$libFileName." into resource fork.\n";
}
CloseResFile($res);
sleep(3);
&MacPerl'Quit(3);

#=======================================================

Michael Ziege
Sallenbachstr. 11
8055 ZŸrich
Switzerland
tel.    ++41-1-463 82 78
e-mail. ziege@ito.umnw.ethz.ch





***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch