From ecc8ffbd8033724b026f10ab435f7054c37f145d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 23 Jun 2021 13:59:01 +0100 Subject: Compile the entire Lua stack as C++ * Fixes #5216 --- SetFlags.cmake | 7 ++++++- lib/SQLiteCpp | 2 +- lib/lua | 2 +- lib/luaexpat | 2 +- lib/sqlite | 2 +- lib/tolua++ | 2 +- src/Bindings/LuaState.cpp | 19 +++++-------------- src/Bindings/LuaState.h | 5 +---- src/Bindings/PluginLua.cpp | 5 +---- tests/Generating/CMakeLists.txt | 2 +- tests/LoadablePieces/CMakeLists.txt | 2 +- tests/LuaThreadStress/CMakeLists.txt | 2 +- 12 files changed, 21 insertions(+), 31 deletions(-) diff --git a/SetFlags.cmake b/SetFlags.cmake index d3a7801ee..869307d91 100644 --- a/SetFlags.cmake +++ b/SetFlags.cmake @@ -88,6 +88,11 @@ function(set_global_flags) # Make build use Unicode: add_compile_definitions(UNICODE _UNICODE) + + # Turn off CRT warnings: + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + + return () endif() # Allow for a forced 32-bit build under 64-bit OS: @@ -99,7 +104,7 @@ function(set_global_flags) # https://en.wikipedia.org/wiki/Uname # https://gcc.gnu.org/onlinedocs/gcc/index.html # Have the compiler generate code specifically targeted at the current machine on Linux: - if(UNIX AND NOT NO_NATIVE_OPTIMIZATION AND NOT CMAKE_CROSSCOMPILING) + if(NOT NO_NATIVE_OPTIMIZATION AND NOT CMAKE_CROSSCOMPILING) string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR) if (SYSTEM_PROCESSOR MATCHES "^(i386|i686|x86|amd64|mips)") message(STATUS "Optimising for this machine (march=native)") diff --git a/lib/SQLiteCpp b/lib/SQLiteCpp index a25ffb56a..b1f67393f 160000 --- a/lib/SQLiteCpp +++ b/lib/SQLiteCpp @@ -1 +1 @@ -Subproject commit a25ffb56ab1bae0f416ac5dfbddd4188ea3c1a9c +Subproject commit b1f67393fdac05d7d05b7f1232de688e82a7e98f diff --git a/lib/lua b/lib/lua index 935fe9113..f543fd793 160000 --- a/lib/lua +++ b/lib/lua @@ -1 +1 @@ -Subproject commit 935fe9113295e049baa8ab0163e2dfec0393a8dd +Subproject commit f543fd79318bf31c81141a07662eb71896a1d938 diff --git a/lib/luaexpat b/lib/luaexpat index 368e2927f..d1986776c 160000 --- a/lib/luaexpat +++ b/lib/luaexpat @@ -1 +1 @@ -Subproject commit 368e2927fcd227bf0af91b3e4b92e740196425cd +Subproject commit d1986776c6c3d209a8410bd5928facf157dc42bd diff --git a/lib/sqlite b/lib/sqlite index 4435d7e42..9aeab26b0 160000 --- a/lib/sqlite +++ b/lib/sqlite @@ -1 +1 @@ -Subproject commit 4435d7e4297220228174385302d430f1fdf3d090 +Subproject commit 9aeab26b00c0bf4c1c3d0afd61acaf08eaf949d3 diff --git a/lib/tolua++ b/lib/tolua++ index 4d24aa316..26e85c404 160000 --- a/lib/tolua++ +++ b/lib/tolua++ @@ -1 +1 @@ -Subproject commit 4d24aa316898964c23896fbb7419bdaa23638c26 +Subproject commit 26e85c404baf1d2e5eb4a21660d1f37176d7ab33 diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 3a1379df1..e4c537967 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -6,10 +6,7 @@ #include "Globals.h" #include "LuaState.h" -extern "C" -{ - #include "lua/src/lualib.h" -} +#include "lua/src/lualib.h" #undef TOLUA_TEMPLATE_BIND #include "tolua++/include/tolua++.h" @@ -34,17 +31,11 @@ extern "C" -// fwd: "SQLite/lsqlite3.c" -extern "C" -{ - int luaopen_lsqlite3(lua_State * L); -} +// fwd: "SQLite/lsqlite3.cpp" +int luaopen_lsqlite3(lua_State * L); -// fwd: "LuaExpat/lxplib.c": -extern "C" -{ - int luaopen_lxp(lua_State * L); -} +// fwd: "LuaExpat/lxplib.cpp": +int luaopen_lxp(lua_State * L); diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 420fdad69..d579369f0 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -30,10 +30,7 @@ stays valid but doesn't call into Lua code anymore, returning false for "failure #pragma once -extern "C" -{ - #include "lua/src/lauxlib.h" -} +#include "lua/src/lauxlib.h" #include "../Defines.h" #include "../FunctionRef.h" diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 9b6bccf7c..887e6d699 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -18,10 +18,7 @@ #include "../Root.h" #include "../WebAdmin.h" -extern "C" -{ - #include "lua/src/lauxlib.h" -} +#include "lua/src/lauxlib.h" #undef TOLUA_TEMPLATE_BIND #include "tolua++/include/tolua++.h" diff --git a/tests/Generating/CMakeLists.txt b/tests/Generating/CMakeLists.txt index 92307235f..572f2b6d9 100644 --- a/tests/Generating/CMakeLists.txt +++ b/tests/Generating/CMakeLists.txt @@ -161,7 +161,7 @@ add_library(GeneratorTestingSupport STATIC ${GENERATING_HDRS} ${STUBS} ) -target_link_libraries(GeneratorTestingSupport fmt::fmt jsoncpp_static tolualib libdeflate) +target_link_libraries(GeneratorTestingSupport fmt::fmt jsoncpp_static libdeflate lsqlite luaexpat tolualib) source_group("Stubs" FILES ${STUBS}) source_group("Generating" FILES ${GENERATING_HDRS} ${GENERATING_SRCS}) diff --git a/tests/LoadablePieces/CMakeLists.txt b/tests/LoadablePieces/CMakeLists.txt index c09cf8091..4133dea80 100644 --- a/tests/LoadablePieces/CMakeLists.txt +++ b/tests/LoadablePieces/CMakeLists.txt @@ -86,7 +86,7 @@ source_group("Shared" FILES ${SHARED_SRCS} ${SHARED_HDRS}) source_group("Sources" FILES ${SRCS}) source_group("Data files" FILES Test.cubeset Test1.schematic) add_executable(LoadablePieces ${SRCS} ${SHARED_SRCS} ${SHARED_HDRS} Test.cubeset Test1.schematic) -target_link_libraries(LoadablePieces tolualib zlib) +target_link_libraries(LoadablePieces libdeflate tolualib) add_test(NAME LoadablePieces-test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND LoadablePieces) diff --git a/tests/LuaThreadStress/CMakeLists.txt b/tests/LuaThreadStress/CMakeLists.txt index bd6b40f21..d4a929fdf 100644 --- a/tests/LuaThreadStress/CMakeLists.txt +++ b/tests/LuaThreadStress/CMakeLists.txt @@ -80,7 +80,7 @@ source_group("Shared" FILES ${SHARED_SRCS} ${SHARED_HDRS}) source_group("Sources" FILES ${SRCS}) source_group("Lua files" FILES Test.lua) add_executable(LuaThreadStress ${SRCS} ${SHARED_SRCS} ${SHARED_HDRS} Test.lua) -target_link_libraries(LuaThreadStress fmt::fmt Threads::Threads tolualib libdeflate) +target_link_libraries(LuaThreadStress fmt::fmt libdeflate lsqlite luaexpat Threads::Threads tolualib) add_test(NAME LuaThreadStress-test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND LuaThreadStress) -- cgit v1.2.3