xmoto-0.6.1_lua_deprecated.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From fb004501a6387bb7ba5182b60ec305e9947dc545 Mon Sep 17 00:00:00 2001
  2. From: _yui <imbatman0xff@gmail.com>
  3. Date: Tue, 7 Jul 2020 21:44:49 +0300
  4. Subject: [PATCH 1/2] Fix building with Lua with deprecated functions removed
  5. ---
  6. src/CMakeLists.txt | 5 +++++
  7. src/xmoto/LuaLibBase.cpp | 6 ++++++
  8. 2 files changed, 11 insertions(+)
  9. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  10. index a3f328f9..3618360e 100644
  11. --- a/src/CMakeLists.txt
  12. +++ b/src/CMakeLists.txt
  13. @@ -461,6 +461,11 @@ check_prototype_definition(mkdir
  14. )
  15. target_compile_definitions(xmoto PUBLIC MS_MKDIR=$<BOOL:${MS_MKDIR}>)
  16. +if(USE_SYSTEM_Lua)
  17. + check_symbol_exists(luaL_openlib lauxlib.h HAVE_LUAL_OPENLIB)
  18. + target_compile_definitions(xmoto PUBLIC HAVE_LUAL_OPENLIB=$<BOOL:${HAVE_LUAL_OPENLIB}>)
  19. +endif()
  20. +
  21. target_compile_definitions(xmoto PUBLIC USE_OPENGL=$<BOOL:${USE_OPENGL}>)
  22. target_compile_definitions(xmoto PUBLIC USE_SDLGFX=$<BOOL:${USE_SDLGFX}>)
  23. target_compile_definitions(xmoto PUBLIC USE_GETTEXT=$<BOOL:${USE_GETTEXT}>)
  24. diff --git a/src/xmoto/LuaLibBase.cpp b/src/xmoto/LuaLibBase.cpp
  25. index fed3c79e..62b690e1 100644
  26. --- a/src/xmoto/LuaLibBase.cpp
  27. +++ b/src/xmoto/LuaLibBase.cpp
  28. @@ -42,7 +42,13 @@ LuaLibBase::LuaLibBase(const std::string &i_libname, luaL_Reg i_reg[]) {
  29. luaL_requiref(m_pL, LUA_TABLIBNAME, luaopen_table, 1);
  30. #endif
  31. +#if HAVE_LUAL_OPENLIB
  32. luaL_openlib(m_pL, i_libname.c_str(), i_reg, 0);
  33. +#else
  34. + lua_newtable(m_pL);
  35. + luaL_register(m_pL, i_libname.c_str(), i_reg);
  36. + lua_setglobal(m_pL, i_libname.c_str());
  37. +#endif
  38. }
  39. LuaLibBase::~LuaLibBase() {
  40. From 0a92ee4e8d6ffb88f137b74ba3e9a9b688ac50e6 Mon Sep 17 00:00:00 2001
  41. From: _yui <imbatman0xff@gmail.com>
  42. Date: Tue, 7 Jul 2020 23:01:38 +0300
  43. Subject: [PATCH 2/2] Change luaL_register to luaL_setfuncs for lua 5.2 and
  44. newer
  45. ---
  46. src/xmoto/LuaLibBase.cpp | 10 ++++++++--
  47. 1 file changed, 8 insertions(+), 2 deletions(-)
  48. diff --git a/src/xmoto/LuaLibBase.cpp b/src/xmoto/LuaLibBase.cpp
  49. index 62b690e1..911c5698 100644
  50. --- a/src/xmoto/LuaLibBase.cpp
  51. +++ b/src/xmoto/LuaLibBase.cpp
  52. @@ -44,11 +44,17 @@ LuaLibBase::LuaLibBase(const std::string &i_libname, luaL_Reg i_reg[]) {
  53. #if HAVE_LUAL_OPENLIB
  54. luaL_openlib(m_pL, i_libname.c_str(), i_reg, 0);
  55. -#else
  56. +#else // HAVE_LUAL_OPENLIB
  57. lua_newtable(m_pL);
  58. +
  59. +#if LUA_VERSION_NUM >= 502
  60. + luaL_setfuncs(m_pL, i_reg, 0);
  61. +#else // LUA_VERSION_NUM >= 502
  62. luaL_register(m_pL, i_libname.c_str(), i_reg);
  63. +#endif // LUA_VERSION_NUM >= 502
  64. +
  65. lua_setglobal(m_pL, i_libname.c_str());
  66. -#endif
  67. +#endif // HAVE_LUAL_OPENLIB
  68. }
  69. LuaLibBase::~LuaLibBase() {