#!/usr/bin/perl ############################################################ # # Simple assistant for use with wxPerl and PerlApp / PDK # # Copyright (c) 2006 Mark Dootson mdootson@cpan.org # ############################################################ package PDKHelper; =head1 NAME wxpdk =head1 VERSION Version 0.15 =cut =head1 SYNOPSIS PerlAPP / PDK assistant To start perlapp gui run 'wxpdk' without any arguments. To use perlapp from the command line you can use wxpdk to create argument file wxpdk -A argfile.args then: e.g. perlapp @argfile.args--norunlib --gui --exe foo.exe foo.pl To create a full .perlapp file without loading GUI wxpdk -S foo.pl -P foo.parlapp All options to wxpdk are -S scriptname to package -P perlapp file to write -A args file to write with wxPerl dependencies -H print these options Wx::Perl::Packager does not support the --dyndll option for PerlApp. Wx::Perl::Packager does not support the --clean option for PerlApp Wx::Perl::Packager works with PerlApp by moving the following bound or included wxWidgets files to a separate temp directory: base core adv mingwm10.dll if present gdiplus.dll if needed by OS. The name of the directory is created using the logged in username, wxWidgets versions the file sizes of the wxWidgets DLLs. This ensures that your application gets the correct Wx dlls whilst also ensuring that only one temp directory is ever created for a unique set of wxWidgets DLLs All the wxWidgets dlls and mingwm10.dll should be bound as 'dllname.dll'. (i.e. not in subdirectories) The wxpdk utility takes care of this for you. At the start of your script ... #!c:/path/to/perl.exe use Wx::Perl::Packager; ..... or if you use threads with your application #!c:/path/to/perl.exe use threads; use threads::shared; use Wx::Perl::Packager; Wx::Perl::Packager must be loaded before any part of Wx so should appear at the top of your main script. If you load any part of Wx in a BEGIN block, then you must load Wx::Perl::Packager before it in your first BEGIN block. This may cause you problems if you use threads within your Wx application. The threads documentation advises against loading threads in a BEGIN block - so don't do it. =cut use strict; use Wx qw( :everything ); use base 'Wx::App'; my $VERSION = 0.15; sub OnInit { my( $this ) = shift; $this->{_pdkexe} = undef; $this->{_pdkparams} = undef; require Wx::Perl::Packager::PDKWindow; Wx::InitAllImageHandlers(); my( $mainwindow ) = Wx::Perl::Packager::PDKWindow->new(undef, -1); $this->SetTopWindow($mainwindow); $mainwindow->Show(1); return 1; } sub PDKExec { my $this = shift; if(@_) { $this->{_pdkexe} = shift; } return $this->{_pdkexe}; } sub PDKParams { my $this = shift; if(@_) { $this->{_pdkparams} = shift; } return $this->{_pdkparams}; } package main; use Wx::Perl::Packager 0.14; use Wx::Perl::Packager::Utils 0.14; use Getopt::Std; my %opts; getopts('S:P:A:Hh', \%opts); my $allowed = { -S => 'scriptname to package', -P => 'name of .perlapp file to output', -A => 'name of argument file for wxWidgets DLLs only', -H => 'help', }; if($opts{H} || $opts{h}) { print qq(wxpdk - helper for packaging wxPerl scripts with PerlApp\nOptions:\n); for my $key (keys(%$allowed)) { print qq($key\t$allowed->{$key}\n); } print qq(\nIf no options are specified, starts GUI interface\n); exit(0); } if( $^O !~ /^MSWin/ ) { die qq(This version of wxpdk only supports MSWin); } # options my($scriptname, $perlapp, $argfile, $nogui); if( $opts{S} ) { die qq(Unable to find scriptname $opts{S}) if(!-e $opts{S}); $scriptname = $opts{S}; } if( $opts{P} ) { die qq(Must provide option -S scriptname if you specify option -P perlapp) if(!$scriptname); $perlapp = $opts{P}; $nogui = 1; } if( $scriptname && (!$perlapp) ) { die qq(Must provide option -P perlapp if you specify option -S scriptname) if(!$scriptname); } $argfile = $opts{A} || 0; if($argfile || $scriptname) { # get DLLs my @libfiles = Wx::Perl::Packager::get_wxboundfiles(); if($scriptname) { Wx::Perl::Packager::Utils::create_perlapp_content(\@libfiles, $scriptname, $perlapp); print qq(PerlApp file created as: $perlapp\n); } if($argfile) { Wx::Perl::Packager::Utils::create_argfile_content(\@libfiles, $argfile); print qq(PerlApp \@Argument file created as: $argfile\n); } exit(0); } my( $app ) = PDKHelper->new(); $app->MainLoop(); my $pdkexec = $app->PDKExec(); my $pdkparams = $app->PDKParams(); if($pdkexec) { print qq(Running $pdkexec $pdkparams ....\n\n); system($pdkexec, $pdkparams); } 1; __END__