root/trunk/Padre/script/padre

Revision 11090, 3.8 KB (checked in by adamk, 45 hours ago)

Everything that needs threads should make sure they are loaded themselves. This removes the need to load threads during a client call to the single instance server.

Line 
1#!/usr/bin/perl
2
3use 5.008005;
4use strict;
5use warnings;
6use Carp ();
7
8local $| = 1;
9local $SIG{__DIE__} =
10        $ENV{PADRE_DIE}
11        ? sub { print STDERR Carp::longmess "\nDIE: @_\n" . ( "-" x 80 ) . "\n" }
12        : $SIG{__DIE__};
13
14# Must run using wxPerl on OS X.
15if ( $^O eq 'darwin' and $^X !~ m{/wxPerl\.app/} ) {
16        require File::Which;
17        my $perl = scalar File::Which::which('wxPerl');
18        chomp($perl);
19        if ( -e $perl ) {
20                warn "spawning 'wxPerl' interpreter for OS X\n";
21                system( $perl, '-S', $0, @ARGV );
22        } else {
23                warn "padre cannot find wxPerl executable (which it requires on OS X)\n";
24        }
25        exit 0;
26}
27
28# Handle special command line cases early, because options like --home
29# MUST be processed before the Padre.pm library is loaded.
30require Getopt::Long;
31my $USAGE   = '';
32my $VERSION = '';
33my $HOME    = undef;
34my $RESET   = undef;
35my $SESSION = undef;
36my $PRELOAD = undef;
37my $DESKTOP = undef;
38my $ACTIONS = undef;
39my $getopt  = Getopt::Long::GetOptions(
40        'help|usage'    => \$USAGE,
41        'version'       => \$VERSION,
42        'home=s'        => \$HOME,
43        'reset'         => \$RESET,
44        'session=s'     => \$SESSION,
45        'desktop'       => \$DESKTOP,
46        'actionqueue=s' => \$ACTIONS,
47        'preload'       => \$PRELOAD, # Keep this sekrit for now --ADAMK
48);
49
50
51
52
53
54#####################################################################
55# Special Execution Modules
56
57# Padre command line usage
58if ( $USAGE or not $getopt ) {
59        print <<"END_USAGE";
60Usage: $0 [FILENAMES]
61
62--help              Shows this help message
63--home=dir          Forces Padre "home" directory to a specific location
64--reset             Flush entire local config directory and reset to defaults
65--session=name      Open given session during Padre startup
66--version           Prints Padre version and quits
67--desktop           Integrate Padre with your desktop
68--actionqueue=list  Run a list of comma-seperated actions after Padre startup
69
70END_USAGE
71        exit(1);
72}
73
74# Padre version
75if ($VERSION) {
76        require Padre;
77        my $msg = "Perl Application Development and Refactoring Environment $Padre::VERSION\n";
78        if ( $^O eq 'MSWin32' and $^X =~ /wperl\.exe/ ) {
79
80                # Under wperl, there is no console so we will use
81                # a message box
82                require Padre::Wx;
83                Wx::MessageBox(
84                        $msg,
85                        Wx::gettext("Version"),
86                        Wx::wxOK(),
87                );
88        } else {
89                print $msg;
90        }
91        exit(0);
92}
93
94# Lock in the home and constants, which are needed for everything else
95local $ENV{PADRE_HOME} = defined($HOME) ? $HOME : $ENV{PADRE_HOME};
96require Padre::Constant;
97
98# Destroy and reinitialise our config directory
99if ($RESET) {
100        require File::Remove;
101        File::Remove::remove( \1, Padre::Constant::CONFIG_DIR() );
102        Padre::Constant::init();
103}
104
105if ($DESKTOP) {
106        require Padre::Desktop;
107        unless ( Padre::Desktop::desktop() ) {
108                warn "--desktop not implemented for $^O\n";
109        }
110        exit(1);
111}
112
113# local $ENV{PADRE_PAR_PATH} = $ENV{PAR_TEMP} || '';
114
115# If we have an action queue then we are running for automation reasons.
116# Avoid the startup logic and continue to the main startup.
117unless ( defined $ACTIONS ) {
118
119        # Run the Padre startup sequence before we load the main application
120        require Padre::Startup;
121        unless ( Padre::Startup::startup() ) {
122
123                # Startup process says to abort the main load and exit now
124                exit(0);
125        }
126}
127
128require Padre;
129
130if ($PRELOAD) {
131
132        # Load the entire application into memory immediately
133        Padre->import(':everything');
134
135        #       use Aspect;
136        #       aspect( 'NYTProf',
137        #               call qr/^Padre::/ &
138        #               call qr/\b(?:refresh|update)\w*\z/ & !
139        #               call qr/^Padre::(?:Locker|Wx::Progress)::/
140        #       );
141}
142
143# Build the application
144my $ide = Padre->new(
145        files       => \@ARGV,
146        session     => $SESSION,
147        actionqueue => $ACTIONS,
148) or die "Failed to create Padre instance";
149
150# Start the application
151$ide->run;
152
153# Copyright 2008-2010 The Padre development team as listed in Padre.pm.
154# LICENSE
155# This program is free software; you can redistribute it and/or
156# modify it under the same terms as Perl 5 itself.
Note: See TracBrowser for help on using the browser.