From 801869d6fb43444dc85a8d2613b2f4648572421e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Sat, 15 Dec 2012 15:00:40 -0200 Subject: [PATCH] Fixes to build system --- .gitignore | 1 + CMakeLists.txt | 35 ++++++++++++++++++++++------------- README.txt | 19 ++++++++++++------- etc/zipmod.sh | 24 +++++++++++++++--------- src/init.lua | 8 ++------ 5 files changed, 52 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 2555dd6..c2314b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ Build* +dists irc-* irc *.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index b661be5..607f7ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,24 +74,33 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/lua) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/luasocket) add_library(luasocket_lib MODULE ${LUASOCKET_SRCS} ${LUA_SRCS}) -set_target_properties(luasocket_lib - PROPERTIES - OUTPUT_NAME luasocket - #COMPILE_FLAGS "-Wall -Werror" -) + +set_target_properties(luasocket_lib PROPERTIES + OUTPUT_NAME luasocket) + if(WIN32) - find_library(ws2_32_lib - NAMES ws2_32 - ) - target_link_libraries(luasocket_lib - ${ws2_32_lib} - ) + # When using MinGW32, CMake prefixes DLLs with "lib". Force remove + # this prefix regardless of compiler. + set_target_properties(luasocket_lib PROPERTIES + PREFIX "") + 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() -set(dir ${CMAKE_CURRENT_SOURCE_DIR}/irc/) +set(dir ${CMAKE_CURRENT_BINARY_DIR}/irc/) if(WIN32) - set(lib "${CMAKE_CURRENT_BINARY_DIR}/libluasocket.dll") + set(lib "${CMAKE_CURRENT_BINARY_DIR}/luasocket.dll") else() set(lib "${CMAKE_CURRENT_BINARY_DIR}/libluasocket.so") endif() diff --git a/README.txt b/README.txt index 0951c48..a179ddb 100644 --- a/README.txt +++ b/README.txt @@ -43,22 +43,27 @@ Under Linux: cmake .. - Use the build tool for the generated build system to compile the 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. - - Use the packmod.sh shell script to copy the files into a ready to use - mod directory named `irc'. - + - Again use the build tool to invoke the `pack_mod' target. For example, + 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 ---------- -Just put theit in any of the - directories where Minetest looks for mods. For more information, see: +Just put the created `irc' directory in any of the directories where + Minetest looks for mods. For more information, see: http://wiki.minetest.net/wiki/Installing_mods 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. mt_irc.server (string, default "irc.freenode.net") diff --git a/etc/zipmod.sh b/etc/zipmod.sh index 097e183..71b9522 100755 --- a/etc/zipmod.sh +++ b/etc/zipmod.sh @@ -2,6 +2,11 @@ # ONLY FOR MAINTAINER USE!! +t="`pwd`"; +cd "`dirname "$0"`/.."; +basedir="`pwd`"; +cd "$t"; + ver=0.1.0; do_make() # [PLATFORM] @@ -15,6 +20,7 @@ do_make() # [PLATFORM] BLD_SFX="-$1"; fi + cd "$basedir"; mkdir -p Build$BLD_SFX; cd Build$BLD_SFX; cmake $TC_FILE .. || exit; @@ -24,16 +30,16 @@ do_make() # [PLATFORM] } -cd "`dirname "$0"`/.."; - -rm -fr irc; +mkdir -p "$basedir/dists" # Native Version -do_make; -tar cfz Kaeza-irc-$ver-`uname -s`-`uname -p`.tar.gz irc || exit; -rm -fr irc; +(do_make \ + && cd Build \ + && tar cfz "$basedir/dists/Kaeza-irc-$ver-`uname -s`-`uname -p`.tar.gz" irc \ +) || exit; # Linux -> MinGW32 Crosscompiler -do_make i586-mingw32msvc; -zip -r Kaeza-irc-$ver-Win32.zip irc || exit; -rm -fr irc; +(do_make i586-mingw32msvc \ + && cd Build-i586-mingw32msvc \ + && zip -r "$basedir/dists/Kaeza-irc-$ver-Win32.zip" irc \ +) || exit; diff --git a/src/init.lua b/src/init.lua index 4f66c9c..7b5f098 100644 --- a/src/init.lua +++ b/src/init.lua @@ -69,10 +69,6 @@ minetest.register_globalstep(function ( dtime ) end end); -local function strltrim ( s ) - return s:gsub("^[[:space:]]*", ""); -end - minetest.register_on_joinplayer(function ( player ) if (not mt_irc.connect_ok) then @@ -146,14 +142,14 @@ minetest.register_chatcommand("msg", { func = function ( name, param ) local pos = param:find(" ", 1, true); 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 t = { name=nick; message=msg; }; local text = mt_irc.message_format_out:gsub("%$%(([^)]+)%)", t) - irc.send("PRIVMSG", nick, text); + irc.send("PRIVMSG", name, text); end; });