made compatible with lua5.3

This commit is contained in:
Axel Kittenberger 2016-11-24 15:44:08 +01:00
parent b2da0ea6d2
commit 8367ae89a0
6 changed files with 29 additions and 6 deletions

View File

@ -54,7 +54,7 @@ add_custom_command( OUTPUT runner.c
# this supposes the Lua compiler 'luac' is sitting right next to the Lua interpreter 'lua'
add_custom_command( OUTPUT runner.out
COMMAND ${CMAKE_COMMAND} -E echo "Compiling built-in runner"
COMMAND ${LUA_EXECUTABLE}c -o runner.out ${PROJECT_SOURCE_DIR}/lsyncd.lua
COMMAND ${LUA_COMPILER} -o runner.out ${PROJECT_SOURCE_DIR}/lsyncd.lua
DEPENDS ${PROJECT_SOURCE_DIR}/lsyncd.lua
)
@ -75,7 +75,7 @@ set( DEFAULT_CONFIGS
add_custom_command( OUTPUT defaults.out
COMMAND ${CMAKE_COMMAND} -E echo "Compiling built-in default configs"
COMMAND ${LUA_EXECUTABLE}c -o defaults.out ${DEFAULT_CONFIGS}
COMMAND ${LUA_COMPILER} -o defaults.out ${DEFAULT_CONFIGS}
DEPENDS ${DEFAULT_CONFIGS}
)

View File

@ -4,6 +4,7 @@
"omit-dir-times",
"omit-dir-times"
"omit-link-times"
change: compatible with Lua5.3 (along with 5.1 and 5.2)
change: _verbatim forced for 'exitcodes' entry.
fix: ']' is not escaped for rsync rules, since rsync only applies
doesn't applie pattern matching if no other pattern chars

View File

@ -34,19 +34,21 @@
# Always search for non-versioned lua first (recommended)
SET(_POSSIBLE_LUA_INCLUDE include include/lua)
SET(_POSSIBLE_LUA_EXECUTABLE lua)
SET(_POSSIBLE_LUA_COMPILER luac)
SET(_POSSIBLE_LUA_LIBRARY lua)
# Determine possible naming suffixes (there is no standard for this)
IF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
SET(_POSSIBLE_SUFFIXES "${Lua_FIND_VERSION_MAJOR}${Lua_FIND_VERSION_MINOR}" "${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}" "-${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}")
ELSE(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
SET(_POSSIBLE_SUFFIXES "52" "5.2" "-5.2" "51" "5.1" "-5.1")
SET(_POSSIBLE_SUFFIXES "53" "5.3" "-5.3" "52" "5.2" "-5.2" "51" "5.1" "-5.1")
ENDIF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
# Set up possible search names and locations
FOREACH(_SUFFIX ${_POSSIBLE_SUFFIXES})
LIST(APPEND _POSSIBLE_LUA_INCLUDE "include/lua${_SUFFIX}")
LIST(APPEND _POSSIBLE_LUA_EXECUTABLE "lua${_SUFFIX}")
LIST(APPEND _POSSIBLE_LUA_COMPILER "luac${_SUFFIX}")
LIST(APPEND _POSSIBLE_LUA_LIBRARY "lua${_SUFFIX}")
ENDFOREACH(_SUFFIX)
@ -55,6 +57,11 @@ FIND_PROGRAM(LUA_EXECUTABLE
NAMES ${_POSSIBLE_LUA_EXECUTABLE}
)
# Find the lua executable
FIND_PROGRAM(LUA_COMPILER
NAMES ${_POSSIBLE_LUA_COMPILER}
)
# Find the lua header
FIND_PATH(LUA_INCLUDE_DIR lua.h
HINTS
@ -114,5 +121,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY LUA_EXECUTABLE)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY LUA_EXECUTABLE LUA_COMPILER)

View File

@ -495,7 +495,7 @@ inotify_ready(
extern void
register_inotify( lua_State *L )
{
luaL_register( L, LSYNCD_INOTIFYLIBNAME, linotfylib );
lua_compat_register( L, LSYNCD_INOTIFYLIBNAME, linotfylib );
}

View File

@ -1948,7 +1948,7 @@ l_jiffies_le(lua_State *L)
void
register_lsyncd( lua_State *L )
{
luaL_register( L, LSYNCD_LIBNAME, lsyncdlib );
lua_compat_register( L, LSYNCD_LIBNAME, lsyncdlib );
lua_setglobal( L, LSYNCD_LIBNAME );
// creates the metatable for the jiffies ( timestamps ) userdata

View File

@ -17,6 +17,7 @@
#define _DARWIN_C_SOURCE 1
#define LUA_COMPAT_ALL
#define LUA_COMPAT_5_1
// includes needed for headerfile
#include "config.h"
@ -31,6 +32,20 @@
#define LSYNCD_LIBNAME "lsyncd"
#define LSYNCD_INOTIFYLIBNAME "inotify"
/*
| Workaround to register a library for different lua versions.
*/
#if LUA_VERSION_NUM > 502
#define lua_compat_register( L, name, lib ) \
{ \
lua_newtable((L)); \
luaL_setfuncs((L), (lib), 0); \
}
#else
#define lua_compat_register( L, name, lib ) \
{luaL_register( (L), (name), (lib) );}
#endif
/**
* Lsyncd runtime configuration
*/