mod packer for Windows

This commit is contained in:
Diego Martínez 2012-12-01 18:15:06 -02:00
parent f88de06675
commit cc53525bd4
4 changed files with 93 additions and 12 deletions

72
packmod.bat Executable file
View File

@ -0,0 +1,72 @@
@echo off
echo Detecting directories...
set srcdir=.
set bindir=Build
if exist CMakeLists.txt goto fnd_dir
set srcdir=..
set bindir=.
if exist ..\CMakeLists.txt goto fnd_dir
echo Error: Couldn't find CMakeLists.txt.
goto done
:fnd_dir
set lib=%bindir%\src\luasocket\libluasocket.dll
if exist %lib% goto fnd_lib
rem # It's impossible to use *.so files on Windows, so we skip that check.
echo Error: Couldn't find luasocket lib.
echo Did you compile before running this script?
goto done
set dir=%srcdir%/irc
md %dir%
echo "Copying files...";
copy %srcdir%/src/luairc/irc.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luairc/irc %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/doc/LICENSE-LuaIRC.txt %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/ftp.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/http.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/ltn12.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/mime.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/smtp.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/socket.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/tp.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/luasocket/url.lua %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/doc/LICENSE-luasocket.txt %dir%
if errorlevel 1 goto copyerr
copy %lib% %dir%
if errorlevel 1 goto copyerr
copy %srcdir%/src/init.lua
if errorlevel 1 goto copyerr
copy %srcdir%/README.txt
if errorlevel 1 goto copyerr
copy %srcdir%/doc/LICENSE.txt
if errorlevel 1 goto copyerr
goto ok
:copyerr
echo Error: failed to copy files
goto done
:ok
echo "Operation completed successfully!";
:done

View File

@ -22,11 +22,7 @@ else
exit 1; exit 1;
fi fi
version="`cat "$srcdir/CMakeLists.txt" \ mkdir "$srcdir/irc";
| grep 'MINETEST_IRC_VERSION' \
| sed -e 's/^set(MINETEST_IRC_VERSION \([^)]*\))/\1/'`";
mkdir "$srcdir/irc-$version";
files_luairc="\ files_luairc="\
$srcdir/src/luairc/irc.lua $srcdir/src/luairc/irc.lua
@ -62,7 +58,7 @@ IFS='
echo "Copying files..."; echo "Copying files...";
for file in $files; do for file in $files; do
IFS="$oIFS"; IFS="$oIFS";
cp -fr "$file" "$srcdir/irc-$version/"; cp -fr "$file" "$srcdir/irc";
done done
echo "Operation completed successfully!"; echo "Operation completed successfully!";

View File

@ -55,8 +55,10 @@ TIMEOUT = 60 -- connection timeout
NETWORK = "localhost" -- default network NETWORK = "localhost" -- default network
PORT = 6667 -- default port PORT = 6667 -- default port
NICK = "luabot" -- default nick NICK = "luabot" -- default nick
USERNAME = "LuaIRC" -- default username --USERNAME = "LuaIRC" -- default username
REALNAME = "LuaIRC" -- default realname USERNAME = "minetest" -- default username
--REALNAME = "LuaIRC" -- default realname
REALNAME = "minetest" -- default realname
DEBUG = false -- whether we want extra debug information DEBUG = false -- whether we want extra debug information
OUTFILE = nil -- file to send debug output to - nil is stdout OUTFILE = nil -- file to send debug output to - nil is stdout
-- }}} -- }}}
@ -92,13 +94,17 @@ end
-- begin_main_loop {{{ -- begin_main_loop {{{
local function begin_main_loop() local function begin_main_loop()
while main_loop_iter() do end --while main_loop_iter() do end
end end
-- }}} -- }}}
poll = main_loop_iter;
-- incoming_message {{{ -- incoming_message {{{
local function incoming_message(sock) local function incoming_message(sock)
local raw_msg = socket.try(sock:receive()) local rcvd = { sock:receive() };
if ((rcvd[1] == nil) and (rcvd[2] == "timeout")) then return true; end
local raw_msg = socket.try(base.unpack(rcvd))
irc_debug._message("RECV", raw_msg) irc_debug._message("RECV", raw_msg)
local msg = message._parse(raw_msg) local msg = message._parse(raw_msg)
misc._try_call_warn("Unhandled server message: " .. msg.command, misc._try_call_warn("Unhandled server message: " .. msg.command,
@ -643,6 +649,11 @@ end
-- }}} -- }}}
-- }}} -- }}}
--@@TEST@@
local function outgoing_message ( )
return true;
end
-- public functions {{{ -- public functions {{{
-- server commands {{{ -- server commands {{{
-- connect {{{ -- connect {{{
@ -683,10 +694,11 @@ function connect(args)
irc_sock = base.assert(socket.connect(network, port)) irc_sock = base.assert(socket.connect(network, port))
irc_sock:settimeout(timeout) irc_sock:settimeout(timeout)
_register_socket(irc_sock, 'r', incoming_message) _register_socket(irc_sock, 'r', incoming_message)
_register_socket(irc_sock, 'w', outgoing_message)
if args.pass then send("PASS", args.pass) end if args.pass then send("PASS", args.pass) end
send("NICK", nick) send("NICK", nick)
send("USER", username, get_ip(), network, realname) send("USER", username, get_ip(), network, realname)
begin_main_loop() --begin_main_loop()
end end
-- }}} -- }}}

View File

@ -10,7 +10,8 @@
local base = _G local base = _G
local string = require("string") local string = require("string")
local math = require("math") local math = require("math")
local socket = require("socket.core") --local socket = require("socket.core")
local socket = require("luasocket")
module("socket") module("socket")
----------------------------------------------------------------------------- -----------------------------------------------------------------------------