From a77a1654bd518638f08a302567102a1add026790 Mon Sep 17 00:00:00 2001 From: Shmuel Zeigerman Date: Sat, 23 Nov 2024 18:30:43 +0200 Subject: [PATCH] Embed luajit in far2m, currently the only way to 'require' C-modules --- far/CMakeLists.txt | 3 +++ far/src/macro/macro.cpp | 9 +++++++++ far/src/plug/PluginW.cpp | 2 +- luafar/CMakeLists.txt | 2 -- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/far/CMakeLists.txt b/far/CMakeLists.txt index 54789204b..8ee462441 100644 --- a/far/CMakeLists.txt +++ b/far/CMakeLists.txt @@ -219,6 +219,7 @@ target_include_directories(far2m PRIVATE src/vt ${CMAKE_CURRENT_BINARY_DIR} ${UCHARDET_INCLUDE_DIRS} + ${LIBLUA_INCLUDE_DIR} ../WinPort) add_dependencies(far2m bootstrap WinPort) @@ -233,6 +234,8 @@ set_target_properties(far2m PROPERTIES ENABLE_EXPORTS TRUE) +target_link_libraries(far2m PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/libluajit.a) + if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") target_link_libraries(far2m PRIVATE ${WINPORT} diff --git a/far/src/macro/macro.cpp b/far/src/macro/macro.cpp index b85563fa5..f1d74b24c 100644 --- a/far/src/macro/macro.cpp +++ b/far/src/macro/macro.cpp @@ -33,6 +33,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "headers.hpp" +extern "C" { +#include +#include +#include +} + #include "Bookmarks.hpp" #include "clipboard.hpp" #include "cmdline.hpp" @@ -60,6 +66,9 @@ static long long msValues[constMsLAST]; int Log(const char* Format, ...) { + lua_State *L = lua_open(); + luaL_openlibs(L); + lua_close(L); va_list valist; va_start(valist, Format); diff --git a/far/src/plug/PluginW.cpp b/far/src/plug/PluginW.cpp index 2ed49b6ab..66be08b64 100644 --- a/far/src/plug/PluginW.cpp +++ b/far/src/plug/PluginW.cpp @@ -583,7 +583,7 @@ void CreatePluginStartupInfo(Plugin *pPlugin, PluginStartupInfo *PSI, FarStandar StartupInfo.TextV2=FarTextV2; StartupInfo.MessageV3=FarMessageV3Fn; StartupInfo.MenuV2=FarMenuV2Fn; - StartupInfo.LuafarLoaded=LoadLuafar(); + StartupInfo.LuafarLoaded=1;//LoadLuafar(); } *PSI=StartupInfo; diff --git a/luafar/CMakeLists.txt b/luafar/CMakeLists.txt index 3161595ea..bad280410 100644 --- a/luafar/CMakeLists.txt +++ b/luafar/CMakeLists.txt @@ -52,8 +52,6 @@ else() target_link_libraries(${PROJECT_NAME} utils) endif() -target_link_libraries(${PROJECT_NAME} luajit) - target_compile_definitions(${PROJECT_NAME} PRIVATE -DWINPORT_DIRECT -DFAR_DONT_USE_INTERNALS) target_include_directories(${PROJECT_NAME} PRIVATE ${SDK})