Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compile new executable #3611

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified NetRedirect.dll
Binary file not shown.
Binary file modified XSTools.dll
Binary file not shown.
4 changes: 4 additions & 0 deletions control/sys.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
###### Localization settings ######
locale

###### Interface settings ######
# Available interface list: Console, Tk, Vx, Win32, Wx
interface

###### Localization compatibility ######
# Enable to make Kore compatible with old 2.0 configs.
locale_compat 0
Expand Down
10 changes: 2 additions & 8 deletions makedist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ else
fi

if [[ "$BINDIST" == "1" ]]; then
for F in start.exe wxstart.exe NetRedirect.dll XSTools.dll start-poseidon.exe; do
for F in openkore.exe NetRedirect.dll XSTools.dll start-poseidon.exe; do
if [[ ! -f "$F" ]]; then
echo "Please put $F in the current folder."
exit 1
Expand Down Expand Up @@ -218,16 +218,10 @@ if [[ "$BINDIST" == "1" ]]; then
cp -v XSTools.dll NetRedirect.dll start-poseidon.exe "$PACKAGEDIR/" || err

# Win32 binary
cp -v start.exe "$PACKAGEDIR/" || err
cp -v openkore.exe "$PACKAGEDIR/" || err
zip -9r "$PACKAGE-$VERSION-win32.zip" "$PACKAGEDIR" || err
echo "$PACKAGE-$VERSION-win32.zip created"

# Win32 Wx binary
cp -v wxstart.exe "$PACKAGEDIR/" || err
rm -vf "$PACKAGEDIR/start.exe"
zip -9r "$PACKAGE-$VERSION-win32_WX.zip" "$PACKAGEDIR" || err
echo "$PACKAGE-$VERSION-win32_wx.zip created"

elif [[ "$SEMIBINDIST" == "1" ]]; then
# Create tarball
echo "Creating distribution archive..."
Expand Down
Binary file added openkore.exe
Binary file not shown.
1 change: 1 addition & 0 deletions openkore.pl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sub __start {

use Globals;
use Interface;
Settings::parseInterfaceName();
$interface = Interface->loadInterface($Settings::interface);
$interface->title($Settings::NAME);
selfCheck();
Expand Down
130 changes: 130 additions & 0 deletions src/Poseidon/start.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/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;
use FindBin;

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 or PAR.\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
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 Text::Balanced;
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;
require List::Util;
require File::Path;
require Math::BigInt;
require Math::BigInt::Calc;
require Math::BigInt::CalcEmu;
require Math::BigInt::FastCalc;
require Math::BigInt::Trace;
require Math::BigFloat;
require Math::BigFloat::Trace;
require Math::BigRat;
require Math::Complex;
require Math::Trig;
# 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";
}


if ($PerlApp::TOOL eq "PerlApp" || $ENV{PAR_PROGNAME}) {
# ok
} else {
print "Do not run start.pl directly! If you're using Perl then run openkore.pl instead!\n";
<STDIN>;
exit 1;
}

my $file = "./src/Poseidon/poseidon.pl";
$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);
}
20 changes: 13 additions & 7 deletions src/Settings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,7 @@ sub parseArguments {
$base_dead_log_file = File::Spec->catfile($logs_folder, "dead_log.txt");
update_log_filenames();

if (!defined $interface) {
if ($ENV{OPENKORE_DEFAULT_INTERFACE} && $ENV{OPENKORE_DEFAULT_INTERFACE} ne "") {
$interface = $ENV{OPENKORE_DEFAULT_INTERFACE};
} else {
$interface = "Console"
}
}

if ($starting_ai) {
$AI::AI = AI::AUTO() if $starting_ai =~ /^(on|auto)$/;
$AI::AI = AI::MANUAL() if $starting_ai =~ /^manual$/;
Expand All @@ -259,6 +253,18 @@ sub parseArguments {
return 1;
}

sub parseInterfaceName {
if (!defined $interface) {
if($sys{interface} && $sys{interface} ne "") {
$interface = $sys{interface};
} elsif ($ENV{OPENKORE_DEFAULT_INTERFACE} && $ENV{OPENKORE_DEFAULT_INTERFACE} ne "") {
$interface = $ENV{OPENKORE_DEFAULT_INTERFACE};
} else {
$interface = "Console";
}
}
}

sub update_log_filenames {
my @logAppend;
push @logAppend, "_$config{username}_$config{char}" if $config{logAppendUsername} && $config{username};
Expand Down
6 changes: 6 additions & 0 deletions src/build/PAR_compile_openkore.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rem this script generate a .exe with support to all interfaces
cd ..\..
wxpar -lib src -o openkore.exe start.pl --module Wx::Perl::Packager --module Wx --module Wx:: --module Win32::GUI --module Win32::GUI::Constants --module Tk --module Tk:: --module Win32::API
pause

Rem --icon src\build\openkore.ico
3 changes: 3 additions & 0 deletions src/build/PAR_compile_poseidon.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd ..\Poseidon
pp -lib src -o start-poseidon.exe start.pl
pause
5 changes: 5 additions & 0 deletions src/build/PAR_compile_start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd ..\..
pp -lib src -o start.exe start.pl
pause

Rem --icon src\build\openkore.ico
5 changes: 5 additions & 0 deletions src/build/PAR_compile_tk.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd ..\..
pp -lib src -o tkstart.exe start.pl -g --module Tk --module Tk:: --module Win32::API
pause

Rem --icon src\build\openkore.ico
5 changes: 5 additions & 0 deletions src/build/PAR_compile_vx.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd ..\..
pp -lib src -o vxstart.exe start.pl -g --module Tk --module Tk::
pause

Rem --icon src\build\openkore.ico
5 changes: 5 additions & 0 deletions src/build/PAR_compile_wingui.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd ..\..
pp -lib src -o winguistart.exe start.pl -g --module Win32::GUI --module Win32::GUI::Constants
pause

Rem --icon src\build\openkore.ico
5 changes: 5 additions & 0 deletions src/build/PAR_compile_wx.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd ..\..
wxpar -lib src -o wxstart.exe start.pl --module Wx::Perl::Packager --module Wx --module Wx::
pause

Rem --icon src\build\openkore.ico
Binary file removed start.exe
Binary file not shown.
35 changes: 34 additions & 1 deletion start.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ BEGIN

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 "\nThis file is meant to be compiled by PerlApp or PAR.\n";
print "To run kore, execute openkore.pl instead.\n\n";
exit 1;
}
Expand Down Expand Up @@ -71,6 +71,7 @@ BEGIN
require Math::Trig;
require Text::Wrap;
require Text::ParseWords;
require Text::Balanced;
require Time::HiRes;
require IO::Socket::INET;
require Getopt::Long;
Expand All @@ -89,6 +90,24 @@ BEGIN
require encoding;
require Storable;
require Compress::Zlib;
require List::Util;
require File::Path;
require Math::BigInt;
require Math::BigInt::Calc;
require Math::BigInt::CalcEmu;
require Math::BigInt::FastCalc;
require Math::BigInt::Trace;
require Math::BigFloat;
require Math::BigFloat::Trace;
require Math::BigRat;
require Math::Complex;
require Math::Trig;
# include http request libs - https://github.com/rathena/rathena/pull/5731
require LWP::UserAgent;
require HTTP::Request;
require HTTP::Request::Common;
require HTTP::Cookies;
require HTTP::Headers;
# new Perl 5.12 and more
require "unicore/lib/Perl/SpacePer.pl";
require "unicore/lib/Perl/Word.pl";
Expand Down Expand Up @@ -122,8 +141,22 @@ BEGIN
if (PerlApp::exe() =~ /tkstart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Tk';
}
} elsif($ENV{PAR_PROGNAME}) {
if ($ENV{PAR_PROGNAME} =~ /wxstart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Wx';
}

if ($ENV{PAR_PROGNAME} =~ /vxstart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Vx';
}

if ($ENV{PAR_PROGNAME} =~ /winguistart\.exe$/i) {
$ENV{OPENKORE_DEFAULT_INTERFACE} = 'Win32';
}

if ($ENV{PAR_PROGNAME} =~ /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>;
Expand Down
Binary file removed tkstart.exe
Binary file not shown.
Binary file removed vxstart.exe
Binary file not shown.
Binary file removed winguistart.exe
Binary file not shown.
Binary file removed wxstart.exe
Binary file not shown.