forked from OpenKore/openkore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.pl
161 lines (145 loc) · 3.56 KB
/
start.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env perl
# Win32 Perl script launcher
# This file is meant to be compiled by PerlApp. It acts like a mini-Perl interpreter.
#
# Your script's initialization and main loop code should be placed in a function
# called __start() in the main package. That function will be called by this
# launcher. The reason for this is that otherwise, the perl interpreter will be
# in "eval" all the time while running your script. It will break __DIE__ signal
# handlers that check for the value of $^S.
#
# If your script is run by this launcher, the environment variable INTERPRETER is
# set. Your script should call __start() manually if this environment variable is not
# set.
#
# example script:
# our $quit = 0;
#
# sub __start {
# print "Hello world initialized.\n";
# while (!$quit) {
# ...
# }
# }
#
# __start() unless defined $ENV{INTERPRETER};
package StarterScript;
BEGIN {
if ($ENV{BUILDING_WX} == 1 && $^O eq 'MSWin32') {
require Wx::Perl::Packager;
} elsif ($ENv{BUILDING_WX} == 2 && $^O eq 'MSWin32') {
require Tk;
} elsif ($ENv{BUILDING_WX} == 3 && $^O eq 'MSWin32') {
require Win32::GUI;
}
}
use strict;
use Config;
if ($^O ne 'MSWin32') {
# We are not on Windows, so tell the user about it
print "\nThis file is meant to be compiled by PerlApp.\n";
print "To run kore, execute openkore.pl instead.\n\n";
exit 1;
}
# PerlApp 6's @INC doesn't contain '.', so add it
my $hasCurrentDir;
foreach (@INC) {
if ($_ eq ".") {
$hasCurrentDir = 1;
last;
}
}
push @INC, "." if (!$hasCurrentDir);
if (0) {
# Force PerlApp to include the following modules
use FindBin;
require base;
require bytes;
require lib;
require integer;
require warnings;
require UNIVERSAL;
require Exporter;
require Fcntl;
require Carp;
require Math::Trig;
require Text::Wrap;
require Text::ParseWords;
require Time::HiRes;
require IO::Socket::INET;
require Getopt::Long;
require Digest::MD5;
require SelfLoader;
require Data::Dumper;
require Win32;
require Win32::Console;
require Win32::Process;
require XSTools;
require Encode;
require Encode::KR;
require Encode::TW;
require Encode::JP;
require Encode::CN;
require encoding;
require Storable;
require Compress::Zlib;
# new Perl 5.12 and more
require "unicore/lib/Perl/SpacePer.pl";
require "unicore/lib/Perl/Word.pl";
require "unicore/lib/Nt/De.pl";
require "unicore/lib/Gc/Cc.pl";
require "unicore/lib/Blk/ASCII.pl";
# Old Perl 5.10 and less
# require "unicore/lib/gc_sc/SpacePer.pl";
# require "unicore/lib/gc_sc/Word.pl";
# require "unicore/lib/gc_sc/Digit.pl";
# require "unicore/lib/gc_sc/Cntrl.pl";
# require "unicore/lib/gc_sc/ASCII.pl";
require HTML::Entities;
}
if ($PerlApp::TOOL eq "PerlApp") {
$ENV{INTERPRETER} = PerlApp::exe();
if (PerlApp::exe() =~ /wxstart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Wx';
}
if (PerlApp::exe() =~ /vxstart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Vx';
}
if (PerlApp::exe() =~ /winguistart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Win32';
}
if (PerlApp::exe() =~ /tkstart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Tk';
}
} else {
print "Do not run start.pl directly! If you're using Perl then run openkore.pl instead!\n";
<STDIN>;
exit 1;
}
my $file = "openkore.pl";
if ($ARGV[0] eq '!') {
shift;
while (@ARGV) {
if ($ARGV[0] =~ /^-I(.*)/) {
unshift @INC, $1;
} else {
last;
}
shift;
}
$file = shift;
}
$0 = $file;
FindBin::again();
{
package main;
do $file;
}
if ($@) {
print $@;
print "\nPress ENTER to exit.\n";
<STDIN>;
exit 1;
} elsif (defined $ENV{INTERPRETER}) {
main::__start() if defined(&main::__start);
}