1
0
mirror of https://github.com/minetest-mods/irc.git synced 2024-06-30 05:10:22 +02:00

Fixes to build system

This commit is contained in:
Diego Martínez 2012-12-15 15:00:40 -02:00
parent d0a19055c5
commit 801869d6fb
5 changed files with 52 additions and 35 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
Build* Build*
dists
irc-* irc-*
irc irc
*.zip *.zip

View File

@ -74,24 +74,33 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/lua)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/luasocket) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/luasocket)
add_library(luasocket_lib MODULE ${LUASOCKET_SRCS} ${LUA_SRCS}) add_library(luasocket_lib MODULE ${LUASOCKET_SRCS} ${LUA_SRCS})
set_target_properties(luasocket_lib
PROPERTIES set_target_properties(luasocket_lib PROPERTIES
OUTPUT_NAME luasocket OUTPUT_NAME luasocket)
#COMPILE_FLAGS "-Wall -Werror"
)
if(WIN32) if(WIN32)
find_library(ws2_32_lib # When using MinGW32, CMake prefixes DLLs with "lib". Force remove
NAMES ws2_32 # this prefix regardless of compiler.
) set_target_properties(luasocket_lib PROPERTIES
target_link_libraries(luasocket_lib PREFIX "")
${ws2_32_lib} if (NOT MSVC) # GCC?
) # The `-fPIC' flag generates a warning on MinGW32, which combined
# with `-Werror' makes that an error though `-fPIC' is ignored.
# We use `-fno-PIC' to avoid that.
set_target_properties(luasocket_lib PROPERTIES
COMPILE_FLAGS "-fno-PIC -Wall -Werror")
endif()
find_library(ws2_32_lib NAMES ws2_32)
target_link_libraries(luasocket_lib ${ws2_32_lib})
else() # Possibly Unix
set_target_properties(luasocket_lib PROPERTIES
COMPILE_FLAGS "-Wall -Werror")
endif() endif()
set(dir ${CMAKE_CURRENT_SOURCE_DIR}/irc/) set(dir ${CMAKE_CURRENT_BINARY_DIR}/irc/)
if(WIN32) if(WIN32)
set(lib "${CMAKE_CURRENT_BINARY_DIR}/libluasocket.dll") set(lib "${CMAKE_CURRENT_BINARY_DIR}/luasocket.dll")
else() else()
set(lib "${CMAKE_CURRENT_BINARY_DIR}/libluasocket.so") set(lib "${CMAKE_CURRENT_BINARY_DIR}/libluasocket.so")
endif() endif()

View File

@ -43,22 +43,27 @@ Under Linux:
cmake .. cmake ..
- Use the build tool for the generated build system to compile the - Use the build tool for the generated build system to compile the
native library. For example, if using Code::Blocks, open the generated native library. For example, if using Code::Blocks, open the generated
workspace and build from there. If using make, just run "make" from workspace and build from there. If using `make', just run "make" from
within the Build directory. within the Build directory.
- Use the packmod.sh shell script to copy the files into a ready to use - Again use the build tool to invoke the `pack_mod' target. For example,
mod directory named `irc'. if using `make', run "make pack_mod" from within the build directory.
This will create an `irc-mod/irc' directory inside the build directory.
This `irc' directory will be ready to be deployed to your Minetest mods
directory. [Currently, there's a problem when compiling for GCC/MinGW32:
the library will be named `libluasocket.dll', but the mod looks for
`luasocket.dll'. There is a temporary fix to make the mod also search
for `libluasocket.dll'.]
INSTALLING INSTALLING
---------- ----------
Just put theit in any of the Just put the created `irc' directory in any of the directories where
directories where Minetest looks for mods. For more information, see: Minetest looks for mods. For more information, see:
http://wiki.minetest.net/wiki/Installing_mods http://wiki.minetest.net/wiki/Installing_mods
SETTINGS SETTINGS
-------- --------
All settings are changed directly in the script. If any of these settings All settings are changed in the `config.lua' file. If any of these settings
are either nil or false, the default value is used. are either nil or false, the default value is used.
mt_irc.server (string, default "irc.freenode.net") mt_irc.server (string, default "irc.freenode.net")

View File

@ -2,6 +2,11 @@
# ONLY FOR MAINTAINER USE!! # ONLY FOR MAINTAINER USE!!
t="`pwd`";
cd "`dirname "$0"`/..";
basedir="`pwd`";
cd "$t";
ver=0.1.0; ver=0.1.0;
do_make() # [PLATFORM] do_make() # [PLATFORM]
@ -15,6 +20,7 @@ do_make() # [PLATFORM]
BLD_SFX="-$1"; BLD_SFX="-$1";
fi fi
cd "$basedir";
mkdir -p Build$BLD_SFX; mkdir -p Build$BLD_SFX;
cd Build$BLD_SFX; cd Build$BLD_SFX;
cmake $TC_FILE .. || exit; cmake $TC_FILE .. || exit;
@ -24,16 +30,16 @@ do_make() # [PLATFORM]
} }
cd "`dirname "$0"`/.."; mkdir -p "$basedir/dists"
rm -fr irc;
# Native Version # Native Version
do_make; (do_make \
tar cfz Kaeza-irc-$ver-`uname -s`-`uname -p`.tar.gz irc || exit; && cd Build \
rm -fr irc; && tar cfz "$basedir/dists/Kaeza-irc-$ver-`uname -s`-`uname -p`.tar.gz" irc \
) || exit;
# Linux -> MinGW32 Crosscompiler # Linux -> MinGW32 Crosscompiler
do_make i586-mingw32msvc; (do_make i586-mingw32msvc \
zip -r Kaeza-irc-$ver-Win32.zip irc || exit; && cd Build-i586-mingw32msvc \
rm -fr irc; && zip -r "$basedir/dists/Kaeza-irc-$ver-Win32.zip" irc \
) || exit;

View File

@ -69,10 +69,6 @@ minetest.register_globalstep(function ( dtime )
end end
end); end);
local function strltrim ( s )
return s:gsub("^[[:space:]]*", "");
end
minetest.register_on_joinplayer(function ( player ) minetest.register_on_joinplayer(function ( player )
if (not mt_irc.connect_ok) then if (not mt_irc.connect_ok) then
@ -146,14 +142,14 @@ minetest.register_chatcommand("msg", {
func = function ( name, param ) func = function ( name, param )
local pos = param:find(" ", 1, true); local pos = param:find(" ", 1, true);
if (not pos) then return; end if (not pos) then return; end
local nick = param:sub(1, pos - 1); local name = param:sub(1, pos - 1);
local msg = param:sub(pos + 1); local msg = param:sub(pos + 1);
local t = { local t = {
name=nick; name=nick;
message=msg; message=msg;
}; };
local text = mt_irc.message_format_out:gsub("%$%(([^)]+)%)", t) local text = mt_irc.message_format_out:gsub("%$%(([^)]+)%)", t)
irc.send("PRIVMSG", nick, text); irc.send("PRIVMSG", name, text);
end; end;
}); });