diff --git a/extensions/scripting/lua-bindings/CMakeLists.txt b/extensions/scripting/lua-bindings/CMakeLists.txt index c766bf493e..5becef74e5 100644 --- a/extensions/scripting/lua-bindings/CMakeLists.txt +++ b/extensions/scripting/lua-bindings/CMakeLists.txt @@ -185,10 +185,6 @@ if(WINDOWS) target_compile_definitions(${ENGINEX_LUA_LIB} PUBLIC _USRLUASTATIC) endif() -target_compile_definitions(${ENGINEX_LUA_LIB} - PUBLIC LUA_COMPAT_MODULE -) - set_target_properties(${ENGINEX_LUA_LIB} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" diff --git a/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp b/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp index d8ffc0299d..2e97cf769f 100644 --- a/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp +++ b/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp @@ -69,8 +69,7 @@ namespace { size_t sz; s = lua_tolstring(L, -1, &sz); /* get result */ if (s == NULL) - return luaL_error(L, LUA_QL("tostring") " must return a string to " - LUA_QL("print")); + return luaL_error(L, "'tostring' must return a string to 'print'"); if (i>1) out->append("\t"); out->append(s, sz); lua_pop(L, 1); /* pop result */ @@ -188,11 +187,17 @@ void LuaStack::addSearchPath(const char* path) void LuaStack::addLuaLoader(lua_CFunction func) { if (!func) return; + +#if LUA_VERSION_NUM >= 504 || (LUA_VERSION_NUM >= 502 && !defined(LUA_COMPAT_LOADERS)) + const char* realname = "searchers"; +#else + const char* realname = "loaders"; +#endif // stack content after the invoking of the function // get loader table lua_getglobal(_state, "package"); /* L: package */ - lua_getfield(_state, -1, "loaders"); /* L: package, loaders */ + lua_getfield(_state, -1, realname); /* L: package, loaders */ // insert loader into index 2 lua_pushcfunction(_state, func); /* L: package, loaders, func */ @@ -205,7 +210,7 @@ void LuaStack::addLuaLoader(lua_CFunction func) lua_rawseti(_state, -2, 2); /* L: package, loaders */ // set loaders into package - lua_setfield(_state, -2, "loaders"); /* L: package */ + lua_setfield(_state, -2, realname); /* L: package */ lua_pop(_state, 1); } diff --git a/external/.gitignore b/external/.gitignore index c0e706a314..38bd572634 100644 --- a/external/.gitignore +++ b/external/.gitignore @@ -1,4 +1,3 @@ .vscode build -.DS_Store -/**/luaconf.h \ No newline at end of file +.DS_Store \ No newline at end of file diff --git a/external/lua/plainlua/CMakeLists.txt b/external/lua/plainlua/CMakeLists.txt index 86643bf925..4d6320dd8e 100644 --- a/external/lua/plainlua/CMakeLists.txt +++ b/external/lua/plainlua/CMakeLists.txt @@ -9,9 +9,6 @@ project(${lib_name}) include(../../cmake/CocosExternalConfig.cmake) -set ( LUA_IDSIZE 128 CACHE STRING "The maximum size for the description of the source." ) -configure_file ( ${LUA_SRC_PATH}/luaconf.h.in ${LUA_SRC_PATH}/luaconf.h ) - aux_source_directory(${LUA_SRC_PATH} LUA_CORE) list(REMOVE_ITEM LUA_CORE ${LUA_SRC_PATH}/lua.c ${LUA_SRC_PATH}/luac.c) @@ -26,11 +23,15 @@ if(${LUA_VERSION} VERSION_GREATER_EQUAL "5.4.0") # !important: traditional lua b target_compile_definitions(${target_name} PUBLIC LUA_COMPAT_APIINTCASTS=1) elseif(${LUA_VERSION} VERSION_GREATER_EQUAL "5.3.0") target_compile_definitions(${target_name} - PUBLIC LUA_COMPAT_5_1=1 - PUBLIC LUA_COMPAT_5_2=1 + PUBLIC LUA_COMPAT_5_1=1 + PUBLIC LUA_COMPAT_5_2=1 + PUBLIC LUA_COMPAT_MODULE=1 ) elseif(${LUA_VERSION} VERSION_GREATER_EQUAL "5.2.0") - target_compile_definitions(${target_name} PUBLIC LUA_COMPAT_ALL=1) + target_compile_definitions(${target_name} + PUBLIC LUA_COMPAT_ALL=1 + PUBLIC LUA_COMPAT_MODULE=1 + ) endif() if(BUILD_SHARED_LIBS) diff --git a/external/lua/plainlua/lua-5.3.6/src/luaconf.h.in b/external/lua/plainlua/lua-5.3.6/src/luaconf.h similarity index 99% rename from external/lua/plainlua/lua-5.3.6/src/luaconf.h.in rename to external/lua/plainlua/lua-5.3.6/src/luaconf.h index af7ce74ee4..c404f2b0a3 100644 --- a/external/lua/plainlua/lua-5.3.6/src/luaconf.h.in +++ b/external/lua/plainlua/lua-5.3.6/src/luaconf.h @@ -749,7 +749,7 @@ @@ of a function in debug information. ** CHANGE it if you want a different size. */ -#cmakedefine LUA_IDSIZE @LUA_IDSIZE@ +#define LUA_IDSIZE 128 /* @@ -784,6 +784,7 @@ /* ** Local configuration. You can use this space to add your redefinitions ** without modifying the main part of the file. +** !!!The follow definiations is engine-x specific, don't overwrite with official lua */ /* @@ Whether lua bytecode compatible with x86/x64 apps