From 09f5e862b800c1d005a12f8c5da475e3085703b4 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Mon, 12 Aug 2019 14:07:25 -0400 Subject: [PATCH] Lua 5.4 changes... oh boy! --- cmake/Modules/FindLuaBuild/LuaVanilla.cmake | 92 +++++++++++---------- include/sol/compatibility.hpp | 2 + include/sol/compatibility/compat-5.4.h | 25 ++++++ single/include/sol/forward.hpp | 4 +- single/include/sol/sol.hpp | 29 ++++++- 5 files changed, 106 insertions(+), 46 deletions(-) create mode 100644 include/sol/compatibility/compat-5.4.h diff --git a/cmake/Modules/FindLuaBuild/LuaVanilla.cmake b/cmake/Modules/FindLuaBuild/LuaVanilla.cmake index c2f2aa52..a6dcc5d7 100644 --- a/cmake/Modules/FindLuaBuild/LuaVanilla.cmake +++ b/cmake/Modules/FindLuaBuild/LuaVanilla.cmake @@ -185,7 +185,9 @@ if (LUA_VANILLA_VERSION MATCHES "^5\\.1") lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) +if (LUA_BUILD_LUA_COMPILER) set(LUA_VANILLA_LUAC_SOURCES luac.c print.c ) +endif() set(LUA_VANILLA_GENERATE_LUA_HPP true) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.2") set(LUA_VANILLA_LIB_SOURCES lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c @@ -194,7 +196,9 @@ elseif (LUA_VANILLA_VERSION MATCHES "^5\\.2") lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) +if (LUA_BUILD_LUA_COMPILER) set(LUA_VANILLA_LUAC_SOURCES luac.c ) +endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.3") set(LUA_VANILLA_LIB_SOURCES lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c @@ -203,7 +207,9 @@ elseif (LUA_VANILLA_VERSION MATCHES "^5\\.3") lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c loadlib.c linit.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) +if (LUA_BUILD_LUA_COMPILER) set(LUA_VANILLA_LUAC_SOURCES luac.c ) +endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4") if (LUA_VANILLA_VERSION MATCHES "work") @@ -215,7 +221,9 @@ elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4") lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) +if (LUA_BUILD_LUA_COMPILER) set(LUA_VANILLA_LUAC_SOURCES luac.c ) +endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) else() MESSAGE(WARNING "Using Lua 5.4.0-work1 file list for ${LUA_VERSION} version") @@ -225,14 +233,15 @@ else() lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) +if (LUA_BUILD_LUA_COMPILER) set(LUA_VANILLA_LUAC_SOURCES luac.c ) +endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) endif() set(LUA_VANILLA_SOURCE_DIR "${LUA_BUILD_TOPLEVEL}/src") prepend(LUA_VANILLA_LIB_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LIB_SOURCES}) prepend(LUA_VANILLA_LUA_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LUA_SOURCES}) -prepend(LUA_VANILLA_LUAC_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LUAC_SOURCES}) # download, just for the sake of download + extract # or pull from local folder @@ -242,7 +251,7 @@ if (LUA_LOCAL_DIR) file(COPY "${LUA_LOCAL_DIR}/include" DESTINATION "${LUA_BUILD_TOPLEVEL}") add_custom_target(LUA_VANILLA - DEPENDS "${LUA_VANILLA_LIB_SOURCES}" "${LUA_VANILLA_LUA_SOURCES}" "${LUA_VANILLA_LUAC_SOURCES}") + DEPENDS "${LUA_VANILLA_LIB_SOURCES}" "${LUA_VANILLA_LUA_SOURCES}") set(LUA_VANILLA_INCLUDE_DIRS ${LUA_VANILLA_INCLUDE_DIRS} "${LUA_VANILLA_SOURCE_DIR}" "${LUA_BUILD_TOPLEVEL}/include") else() ExternalProject_Add(LUA_VANILLA @@ -262,7 +271,7 @@ else() BUILD_COMMAND "" INSTALL_COMMAND "" TEST_COMMAND "" - BUILD_BYPRODUCTS "${LUA_VANILLA_LIB_SOURCES}" "${LUA_VANILLA_LUA_SOURCES}" "${LUA_VANILLA_LUAC_SOURCES}") + BUILD_BYPRODUCTS "${LUA_VANILLA_LIB_SOURCES}" "${LUA_VANILLA_LUA_SOURCES}") # make a quick lua.hpp for 5.1 targets that don't have it if (LUA_VANILLA_GENERATE_LUA_HPP) @@ -386,48 +395,47 @@ if (UNIX) endif() # LuaC Compiler -add_executable(${luacompiler} ${LUA_VANILLA_LUAC_SOURCES}) -if (BUILD_LUA_AS_DLL) - # TODO: figure out how to make DLL internal symbols for lua public so we don't have to do this - target_sources(${luacompiler} PRIVATE ${LUA_VANILLA_LIB_SOURCES}) -endif() -set_target_properties(${luacompiler} - PROPERTIES - LANGUAGE C - LINKER_LANGUAGE C - C_STANDARD 99 - C_EXTENSIONS TRUE - OUTPUT_NAME luac-${LUA_VANILLA_VERSION}) -target_include_directories(${luacompiler} - PRIVATE "${LUA_VANILLA_INCLUDE_DIRS}") -target_compile_definitions(${luacompiler} - PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE} - PRIVATE LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}) -if (MSVC) - target_compile_options(${luacompiler} - PRIVATE /W1) -else() - target_compile_options(${luacompiler} - PRIVATE -w) -endif() -if (WIN32) - #target_compile_definitions(${luacompiler} - # PRIVATE LUA_USE_WINDOWS) -else() - target_compile_definitions(${luacompiler} - PRIVATE LUA_USE_LINUX) -endif() -target_link_libraries(${luacompiler} PRIVATE ${liblua}) -if (CMAKE_DL_LIBS) - target_link_libraries(${luacompiler} PRIVATE ${CMAKE_DL_LIBS}) -endif() -if (UNIX) - # TODO: make readline optional? - target_link_libraries(${luacompiler} PRIVATE m readline) +if (LUA_BUILD_LUA_COMPILER) + set_target_properties(${luacompiler} + PROPERTIES + LANGUAGE C + LINKER_LANGUAGE C + C_STANDARD 99 + C_EXTENSIONS TRUE + OUTPUT_NAME luac-${LUA_VANILLA_VERSION}) + target_include_directories(${luacompiler} + PRIVATE "${LUA_VANILLA_INCLUDE_DIRS}") + target_compile_definitions(${luacompiler} + PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE} + PRIVATE LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}) + if (MSVC) + target_compile_options(${luacompiler} + PRIVATE /W1) + else() + target_compile_options(${luacompiler} + PRIVATE -w) + endif() + if (WIN32) + #target_compile_definitions(${luacompiler} + # PRIVATE LUA_USE_WINDOWS) + else() + target_compile_definitions(${luacompiler} + PRIVATE LUA_USE_LINUX) + endif() + target_link_libraries(${luacompiler} PRIVATE ${liblua}) + if (CMAKE_DL_LIBS) + target_link_libraries(${luacompiler} PRIVATE ${CMAKE_DL_LIBS}) + endif() + if (UNIX) + # TODO: make readline optional? + target_link_libraries(${luacompiler} PRIVATE m readline) + endif() endif() # set externally-visible target indicator set(LUA_LIBRARIES ${liblua}) set(LUA_INTERPRETER ${luainterpreter}) -set(LUA_COMPILER ${luacompiler}) +if (LUA_BUILD_LUA_COMPILER) + set(LUA_COMPILER ${luacompiler}) +endif() set(LUA_INCLUDE_DIRS "${LUA_VANILLA_SOURCE_DIR}") diff --git a/include/sol/compatibility.hpp b/include/sol/compatibility.hpp index 7e904afd..bd1c0607 100644 --- a/include/sol/compatibility.hpp +++ b/include/sol/compatibility.hpp @@ -42,7 +42,9 @@ #ifndef COMPAT53_INCLUDE_SOURCE #define COMPAT53_INCLUDE_SOURCE 1 #endif // Build Compat Layer Inline + #include "compatibility/compat-5.3.h" +#include "compatibility/compat-5.4.h" #endif // SOL_NO_COMPAT diff --git a/include/sol/compatibility/compat-5.4.h b/include/sol/compatibility/compat-5.4.h new file mode 100644 index 00000000..80d65bd7 --- /dev/null +++ b/include/sol/compatibility/compat-5.4.h @@ -0,0 +1,25 @@ +#ifndef NOT_KEPLER_PROJECT_COMPAT54_H_ +#define NOT_KEPLER_PROJECT_COMPAT54_H_ + +#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) +extern "C" { +#endif +#include +#include +#include +#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) +} +#endif + +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504 + +#if !defined(LUA_ERRGCMM) +/* So Lua 5.4 actually removes this, which breaks sol2... + man, this API is quite unstable...! +*/ +# define LUA_ERRGCMM (LUA_ERRERR + 2) +#endif /* LUA_ERRGCMM define */ + +#endif // Lua 5.4 only + +#endif // NOT_KEPLER_PROJECT_COMPAT54_H_ \ No newline at end of file diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index cd84123a..9b5a9510 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/sol/forward.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2019-07-26 02:13:25.323566 UTC -// This header was generated with sol v3.0.3 (revision eb5c442) +// Generated 2019-08-12 18:06:54.421648 UTC +// This header was generated with sol v3.0.3 (revision 5799084) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index 9c6d36cb..282de47c 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2019-07-26 02:13:25.052030 UTC -// This header was generated with sol v3.0.3 (revision eb5c442) +// Generated 2019-08-12 18:06:53.939935 UTC +// This header was generated with sol v3.0.3 (revision 5799084) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -2185,6 +2185,7 @@ namespace sol { #ifndef COMPAT53_INCLUDE_SOURCE #define COMPAT53_INCLUDE_SOURCE 1 #endif // Build Compat Layer Inline + // beginning of sol/compatibility/compat-5.3.h #ifndef KEPLER_PROJECT_COMPAT53_H_ @@ -3431,6 +3432,30 @@ COMPAT53_API void luaL_requiref(lua_State *L, const char *modname, // end of sol/compatibility/compat-5.3.h +// beginning of sol/compatibility/compat-5.4.h + +#ifndef NOT_KEPLER_PROJECT_COMPAT54_H_ +#define NOT_KEPLER_PROJECT_COMPAT54_H_ + +#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) +extern "C" { +#endif +#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) +} +#endif + +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504 + +#if !defined(LUA_ERRGCMM) +/* So Lua 5.4 actually removes this, which breaks sol2... + man, this API is quite unstable...! +*/ +# define LUA_ERRGCMM (LUA_ERRERR + 2) +#endif /* LUA_ERRGCMM define */ + +#endif // Lua 5.4 only + +#endif // NOT_KEPLER_PROJECT_COMPAT54_H_// end of sol/compatibility/compat-5.4.h #endif // SOL_NO_COMPAT