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

Re: [MacPerl] Compiling Runtime



Chris wrote:
>At 13.22 7/10/97, Strider wrote:
>>When I compile a runtime version of an app, it never includes the 'use's
>>and 'require's. I'd like to include "x.x"; but it always seems to tell me
>>that I don't have to predeclare. What am I doing wrong?
>
>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)?
>
>

This code works fine for most modules except some toolbox modules which use
dynamically loaded shared libraries (extension modules). Just save the code
below as droplet and let it examine your runtime.

>
>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 (priv.)
	++41-1-446 23 35 (buis.)
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