From 82da817835329eff43bd05ac41e17de9144e70cf Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Mon, 30 Jan 2023 17:00:30 +0100 Subject: [PATCH] Frankenstein some more --- .gitmodules | 4 +- CHANGELOG.md | 1 + CMakeLists.txt | 13 +++-- lib/lua/CMakeLists.txt | 55 +++++++++++++++++++ lib/{lua => lua/src} | 0 src/CMakeLists.txt | 11 ++-- .../commands/CommandController.cpp | 5 +- src/controllers/plugins/PluginController.cpp | 11 ++-- 8 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 lib/lua/CMakeLists.txt rename lib/{lua => lua/src} (100%) diff --git a/.gitmodules b/.gitmodules index 25b40e3d1..310596ada 100644 --- a/.gitmodules +++ b/.gitmodules @@ -38,6 +38,6 @@ [submodule "lib/miniaudio"] path = lib/miniaudio url = https://github.com/mackron/miniaudio.git -[submodule "lib/lua"] - path = lib/lua +[submodule "lib/lua/src"] + path = lib/lua/src url = https://github.com/lua/lua diff --git a/CHANGELOG.md b/CHANGELOG.md index fd9a054f3..04ccbe529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unversioned +- Major: Add scripting capabilities with Lua (#4341) - Major: Added live emote updates for BTTV (#4147) - Minor: Change the highlight order to prioritize Message highlights over User highlights. (#4303) - Minor: Added ability to negate search options by prefixing it with an exclamation mark (e.g. `!badge:mod` to search for messages where the author does not have the moderator badge). (#4207) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1c54651c..1c40e69d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,11 +148,14 @@ else() add_subdirectory("${CMAKE_SOURCE_DIR}/lib/settings" EXCLUDE_FROM_ALL) endif() -add_custom_target( - Lua ALL - COMMAND make - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lib/lua -) + +set(LUA_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/lib/lua/src") +add_subdirectory(lib/lua) +#add_custom_target( +# Lua ALL +# COMMAND make +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lib/lua +#) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt new file mode 100644 index 000000000..0937645a8 --- /dev/null +++ b/lib/lua/CMakeLists.txt @@ -0,0 +1,55 @@ +project(lua CXX) + +set(LUA_VERSION_MAJOR 5) +set(LUA_VERSION_MINOR 4) +set(LUA_VERSION_PATCH 4) +set(LUA_VERSION "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}") + +#[====[ +Updating this list: +remove all listed files +go to line below, ^y2j4j$@" and then reindent the file names +/LUA_SRC +:r!ls lib/lua/src | grep '\.c' | grep -Ev 'lua\.c|onelua\.c' | sed 's#^#src/#' + +#]====] +set(LUA_SRC + "src/lapi.c" + "src/lauxlib.c" + "src/lbaselib.c" + "src/lcode.c" + "src/lcorolib.c" + "src/lctype.c" + "src/ldblib.c" + "src/ldebug.c" + "src/ldo.c" + "src/ldump.c" + "src/lfunc.c" + "src/lgc.c" + "src/linit.c" + "src/liolib.c" + "src/llex.c" + "src/lmathlib.c" + "src/lmem.c" + "src/loadlib.c" + "src/lobject.c" + "src/lopcodes.c" + "src/loslib.c" + "src/lparser.c" + "src/lstate.c" + "src/lstring.c" + "src/lstrlib.c" + "src/ltable.c" + "src/ltablib.c" + "src/ltests.c" + "src/ltm.c" + "src/lua.c" + "src/lundump.c" + "src/lutf8lib.c" + "src/lvm.c" + "src/lzio.c" +) + +add_library(lua STATIC ${LUA_SRC}) +#target_link_libraries(lua ${LIBS}) +set_source_files_properties(${LUA_SRC} PROPERTIES LANGUAGE CXX) diff --git a/lib/lua b/lib/lua/src similarity index 100% rename from lib/lua rename to lib/lua/src diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4be02da8e..828fa235f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -600,10 +600,11 @@ if (CHATTERINO_GENERATE_COVERAGE) ) endif () -add_dependencies(${LIBRARY_PROJECT} Lua) -target_include_directories(${LIBRARY_PROJECT} - PUBLIC "${CMAKE_SOURCE_DIR}/lib/lua/" - ) + +#add_dependencies(${LIBRARY_PROJECT} Lua) +#target_include_directories(${LIBRARY_PROJECT} +# PUBLIC "${CMAKE_SOURCE_DIR}/lib/lua/" +# ) target_link_libraries(${LIBRARY_PROJECT} PUBLIC Qt${MAJOR_QT_VERSION}::Core @@ -622,7 +623,7 @@ target_link_libraries(${LIBRARY_PROJECT} RapidJSON::RapidJSON LRUCache MagicEnum - "${CMAKE_SOURCE_DIR}/lib/lua/liblua.a" + lua ) if (BUILD_WITH_QTKEYCHAIN) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index a3ddd4128..932d0fd5e 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -45,16 +45,13 @@ #include "widgets/splits/SplitContainer.hpp" #include "widgets/Window.hpp" +#include #include #include #include #include #include -extern "C" { -#include -} - namespace { using namespace chatterino; diff --git a/src/controllers/plugins/PluginController.cpp b/src/controllers/plugins/PluginController.cpp index 2aa45aa75..51eb72dd3 100644 --- a/src/controllers/plugins/PluginController.cpp +++ b/src/controllers/plugins/PluginController.cpp @@ -12,12 +12,11 @@ #include #include -extern "C" { -#include -#include -#include -#include -} +//extern "C" { +#include "lauxlib.h" +#include "lua.h" +#include "lualib.h" +//} namespace chatterino {