Skip to content

Commit

Permalink
Embed luajit in far2m, currently the only way to 'require' C-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Nov 23, 2024
1 parent 8bb882d commit a77a165
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions far/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand Down
9 changes: 9 additions & 0 deletions far/src/macro/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "headers.hpp"

extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}

#include "Bookmarks.hpp"
#include "clipboard.hpp"
#include "cmdline.hpp"
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion far/src/plug/PluginW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions luafar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

1 comment on commit a77a165

@shmuz
Copy link
Owner Author

@shmuz shmuz commented on a77a165 Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The file far/libluajit.a is now required to build far2m for Android
  2. This file is not in the repository
  3. This file was built with the command line
    make PREFIX=/data/data/com.termux/files/usr
    (probably make PREFIX=$(PREFIX) would work as well).

Please sign in to comment.