Use system luajit

And drop luabins from preloaded modules
This commit is contained in:
wangqr 2019-09-07 17:06:50 -04:00
parent bf28e7efc3
commit 6702556776
4 changed files with 236 additions and 167 deletions

View file

@ -28,11 +28,13 @@ addons:
- libwxgtk3.0-dev - libwxgtk3.0-dev
- portaudio19-dev - portaudio19-dev
- libpulse-dev - libpulse-dev
- luajit
- libluajit-5.1-dev
matrix: env:
include: - {}
- {} - BUILD_SUIT=autotools
- env: BUILD_SUIT=autotools - BUILD_SUIT=autotools CONFIG_FLAGS="--with-system-luajit agi_cv_luajit_is_52=yes"
install: install:
- sudo luarocks install busted > /dev/null - sudo luarocks install busted > /dev/null
@ -51,7 +53,7 @@ script:
export CPPFLAGS="-fprofile-arcs -ftest-coverage"; export CPPFLAGS="-fprofile-arcs -ftest-coverage";
export LIBS="-lgcov"; export LIBS="-lgcov";
./autogen.sh; ./autogen.sh;
./configure --enable-debug || cat config.log; ./configure --enable-debug ${CONFIG_FLAGS} || cat config.log;
make -j2; make -j2;
make test || travis_terminate 1; make test || travis_terminate 1;
coveralls --exclude vendor --exclude src --exclude build --exclude tools --exclude libaegisub/windows > /dev/null; coveralls --exclude vendor --exclude src --exclude build --exclude tools --exclude libaegisub/windows > /dev/null;

View file

@ -7,7 +7,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include_directories("build") include_directories("build")
include_directories("libaegisub/include") include_directories("libaegisub/include")
include_directories("vendor/luajit/include")
add_library(libaegisub STATIC add_library(libaegisub STATIC
libaegisub/common/parser.cpp libaegisub/common/parser.cpp
@ -80,176 +79,27 @@ endif(UNIX)
SET_TARGET_PROPERTIES(libaegisub PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(libaegisub PROPERTIES PREFIX "")
target_compile_definitions(libaegisub PRIVATE CMAKE_BUILD) target_compile_definitions(libaegisub PRIVATE CMAKE_BUILD)
add_library(luabins STATIC find_package(LuaJIT REQUIRED)
vendor/luabins/src/fwrite.c target_include_directories(libaegisub PRIVATE ${LUAJIT_INCLUDE_DIR})
vendor/luabins/src/load.c
vendor/luabins/src/luabins.c
vendor/luabins/src/luainternals.c
vendor/luabins/src/save.c
vendor/luabins/src/savebuffer.c
vendor/luabins/src/write.c
)
add_executable(luajit-minilua vendor/luajit/src/host/minilua.c) add_custom_command(
if (NOT MSVC) OUTPUT ${PROJECT_SOURCE_DIR}/src/libresrc/default_config.cpp ${PROJECT_SOURCE_DIR}/src/libresrc/default_config.h
target_link_libraries(luajit-minilua m)
endif(NOT MSVC)
if (WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_custom_command(TARGET luajit-minilua POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/vendor/luajit/src/gen
COMMAND luajit-minilua ../dynasm/dynasm.lua -LN -D WIN -D JIT -D FFI -D P64 -o gen/buildvm_arch.h vm_x86.dasc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/luajit/src
)
else()
add_custom_command(TARGET luajit-minilua POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/vendor/luajit/src/gen
COMMAND luajit-minilua ../dynasm/dynasm.lua -LN -D WIN -D JIT -D FFI -o gen/buildvm_arch.h vm_x86.dasc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/luajit/src
)
endif()
else (WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_custom_command(TARGET luajit-minilua POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/vendor/luajit/src/gen
COMMAND luajit-minilua ../dynasm/dynasm.lua -D P64 -D JIT -D FFI -D FPU -D HFABI -D VER= -o gen/buildvm_arch.h vm_x86.dasc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/luajit/src
)
else()
add_custom_command(TARGET luajit-minilua POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/vendor/luajit/src/gen
COMMAND luajit-minilua ../dynasm/dynasm.lua -D JIT -D FFI -D FPU -D HFABI -D VER= -o gen/buildvm_arch.h vm_x86.dasc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/luajit/src
)
endif()
endif (WIN32)
add_custom_command(TARGET luajit-minilua POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/src/libresrc/default_config_win.json ${PROJECT_SOURCE_DIR}/src/libresrc/default_config_platform.json COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/src/libresrc/default_config_win.json ${PROJECT_SOURCE_DIR}/src/libresrc/default_config_platform.json
COMMAND luajit-minilua ../../tools/respack.lua manifest.respack default_config.cpp default_config.h COMMAND ${LUAJIT_EXECUTABLE} ../../tools/respack.lua manifest.respack default_config.cpp default_config.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/libresrc WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/libresrc
BYPRODUCTS ${PROJECT_SOURCE_DIR}/src/libresrc/default_config.cpp ${PROJECT_SOURCE_DIR}/src/libresrc/default_config.h
) )
add_custom_command(TARGET luajit-minilua POST_BUILD
COMMAND luajit-minilua ../../tools/respack.lua manifest.respack ../libresrc/bitmap.cpp ../libresrc/bitmap.h add_custom_command(
OUTPUT ${PROJECT_SOURCE_DIR}/src/libresrc/bitmap.cpp ${PROJECT_SOURCE_DIR}/src/libresrc/bitmap.h
COMMAND ${LUAJIT_EXECUTABLE} ../../tools/respack.lua manifest.respack ../libresrc/bitmap.cpp ../libresrc/bitmap.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/bitmaps WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/bitmaps
BYPRODUCTS ${PROJECT_SOURCE_DIR}/src/libresrc/bitmap.cpp ${PROJECT_SOURCE_DIR}/src/libresrc/bitmap.h
) )
add_executable(luajit-buildvm
vendor/luajit/src/host/buildvm.c
vendor/luajit/src/host/buildvm_asm.c
vendor/luajit/src/host/buildvm_peobj.c
vendor/luajit/src/host/buildvm_lib.c
vendor/luajit/src/host/buildvm_fold.c
)
target_include_directories(luajit-buildvm PRIVATE vendor/luajit/src vendor/luajit/src/gen)
add_dependencies(luajit-buildvm luajit-minilua)
if(UNIX)
add_custom_command(TARGET luajit-buildvm POST_BUILD
COMMAND luajit-buildvm -m elfasm -o lj_vm.s
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/luajit/src
BYPRODUCTS ${PROJECT_SOURCE_DIR}/vendor/luajit/src/lj_vm.s
)
set_property(SOURCE vendor/luajit/src/lj_vm.s PROPERTY LANGUAGE C)
elseif(MSVC)
add_custom_command(TARGET luajit-buildvm POST_BUILD
COMMAND luajit-buildvm -m peobj -o lj_vm.obj
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/luajit/src
BYPRODUCTS ${PROJECT_SOURCE_DIR}/vendor/luajit/src/lj_vm.obj
)
endif(UNIX)
add_custom_command(TARGET luajit-buildvm POST_BUILD
COMMAND luajit-buildvm -m ffdef -o gen/lj_ffdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
COMMAND luajit-buildvm -m bcdef -o gen/lj_bcdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
COMMAND luajit-buildvm -m folddef -o gen/lj_folddef.h lj_opt_fold.c
COMMAND luajit-buildvm -m recdef -o gen/lj_recdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
COMMAND luajit-buildvm -m libdef -o gen/lj_libdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
COMMAND luajit-buildvm -m vmdef -o jit/vmdef.lua lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/luajit/src
)
target_compile_definitions(luajit-buildvm PRIVATE LUAJIT_ENABLE_LUA52COMPAT)
add_library(luajit STATIC
vendor/luajit/src/lj_gc.c
vendor/luajit/src/lj_err.c
vendor/luajit/src/lj_char.c
vendor/luajit/src/lj_bc.c
vendor/luajit/src/lj_obj.c
vendor/luajit/src/lj_str.c
vendor/luajit/src/lj_tab.c
vendor/luajit/src/lj_func.c
vendor/luajit/src/lj_udata.c
vendor/luajit/src/lj_meta.c
vendor/luajit/src/lj_debug.c
vendor/luajit/src/lj_state.c
vendor/luajit/src/lj_dispatch.c
vendor/luajit/src/lj_vmevent.c
vendor/luajit/src/lj_vmmath.c
vendor/luajit/src/lj_strscan.c
vendor/luajit/src/lj_api.c
vendor/luajit/src/lj_lex.c
vendor/luajit/src/lj_parse.c
vendor/luajit/src/lj_bcread.c
vendor/luajit/src/lj_bcwrite.c
vendor/luajit/src/lj_load.c
vendor/luajit/src/lj_ir.c
vendor/luajit/src/lj_opt_mem.c
vendor/luajit/src/lj_opt_fold.c
vendor/luajit/src/lj_opt_narrow.c
vendor/luajit/src/lj_opt_dce.c
vendor/luajit/src/lj_opt_loop.c
vendor/luajit/src/lj_opt_split.c
vendor/luajit/src/lj_opt_sink.c
vendor/luajit/src/lj_mcode.c
vendor/luajit/src/lj_snap.c
vendor/luajit/src/lj_record.c
vendor/luajit/src/lj_crecord.c
vendor/luajit/src/lj_ffrecord.c
vendor/luajit/src/lj_asm.c
vendor/luajit/src/lj_trace.c
vendor/luajit/src/lj_gdbjit.c
vendor/luajit/src/lj_ctype.c
vendor/luajit/src/lj_cdata.c
vendor/luajit/src/lj_cconv.c
vendor/luajit/src/lj_ccall.c
vendor/luajit/src/lj_ccallback.c
vendor/luajit/src/lj_carith.c
vendor/luajit/src/lj_clib.c
vendor/luajit/src/lj_cparse.c
vendor/luajit/src/lj_lib.c
vendor/luajit/src/lj_alloc.c
vendor/luajit/src/lib_aux.c
vendor/luajit/src/lib_base.c
vendor/luajit/src/lib_math.c
vendor/luajit/src/lib_bit.c
vendor/luajit/src/lib_string.c
vendor/luajit/src/lib_table.c
vendor/luajit/src/lib_io.c
vendor/luajit/src/lib_os.c
vendor/luajit/src/lib_package.c
vendor/luajit/src/lib_debug.c
vendor/luajit/src/lib_jit.c
vendor/luajit/src/lib_ffi.c
vendor/luajit/src/lib_init.c
)
if(MSVC)
target_sources(luajit PRIVATE vendor/luajit/src/lj_vm.obj)
else(MSVC)
target_sources(luajit PRIVATE vendor/luajit/src/lj_vm.s)
set_property(SOURCE vendor/luajit/src/lj_vm.s PROPERTY LANGUAGE C)
target_link_libraries(luajit dl)
endif(MSVC)
target_include_directories(luajit PRIVATE vendor/luajit/src/gen)
add_dependencies(luajit luajit-buildvm)
target_compile_definitions(luajit PRIVATE LUAJIT_ENABLE_LUA52COMPAT)
add_library(resrc STATIC add_library(resrc STATIC
src/libresrc/bitmap.cpp src/libresrc/bitmap.cpp
src/libresrc/default_config.cpp src/libresrc/default_config.cpp
src/libresrc/libresrc.cpp src/libresrc/libresrc.cpp
) )
add_dependencies(resrc luajit-minilua)
add_library(csri STATIC add_library(csri STATIC
vendor/csri/lib/list.c vendor/csri/lib/list.c
@ -428,7 +278,8 @@ add_executable(Aegisub WIN32
src/video_slider.cpp src/video_slider.cpp
src/visual_feature.cpp src/visual_feature.cpp
) )
target_link_libraries(Aegisub ${CMAKE_DL_LIBS} libaegisub luabins luajit resrc csri) target_include_directories(Aegisub PRIVATE ${LUAJIT_INCLUDE_DIR})
target_link_libraries(Aegisub ${CMAKE_DL_LIBS} libaegisub ${LUAJIT_LIBRARIES} resrc csri)
target_compile_definitions(Aegisub PRIVATE CMAKE_BUILD) target_compile_definitions(Aegisub PRIVATE CMAKE_BUILD)
if (MSVC) if (MSVC)
@ -453,6 +304,7 @@ if (MSVC)
else(MSVC) else(MSVC)
target_sources(Aegisub PRIVATE src/crash_writer.cpp) target_sources(Aegisub PRIVATE src/crash_writer.cpp)
target_compile_options(Aegisub PRIVATE -include "${PROJECT_SOURCE_DIR}/src/agi_pre.h") target_compile_options(Aegisub PRIVATE -include "${PROJECT_SOURCE_DIR}/src/agi_pre.h")
target_link_libraries(Aegisub dl)
endif(MSVC) endif(MSVC)
if (WIN32) if (WIN32)

215
cmake/FindLuaJIT.cmake Normal file
View file

@ -0,0 +1,215 @@
#.rst:
# FindLuaJIT
# ----------
#
#
#
# Locate Lua library This module defines
#
# ::
#
# LUAJIT_FOUND - if false, do not try to link to Lua
# LUAJIT_EXECUTABLE - path to luajit command
# LUAJIT_LIBRARIES - both lua and lualib
# LUAJIT_LIBRARY_DIR - list of dir(s) that contain the libraries to link
# LUAJIT_INCLUDE_DIR - where to find lua.h
# LUAJIT_LINK_FLAGS - Link flags that are required, platform dependant
# LUAJIT_VERSION_STRING - the version of Lua found
# LUAJIT_VERSION_MAJOR - the major version of Lua
# LUAJIT_VERSION_MINOR - the minor version of Lua
# LUAJIT_VERSION_PATCH - the patch version of Lua
#
#
#
# Note that the expected include convention is
#
# ::
#
# #include "lua.h"
#
# and not
#
# ::
#
# #include <lua/lua.h>
#
# This is because, the lua location is not standardized and may exist in
# locations other than lua/
unset(_lua_include_subdirs)
unset(_lua_library_names)
# this is a function only to have all the variables inside go away automatically
function(set_lua_version_vars)
set(LUA_VERSIONS5 5.3 5.2 5.1 5.0)
set(LUAJIT_VERSIONS 2.0)
if (LuaJIT_FIND_VERSION_EXACT)
if (LuaJIT_FIND_VERSION_COUNT GREATER 1)
set(luajit_append_versions ${LuaJIT_FIND_VERSION_MAJOR}.${LuaJIT_FIND_VERSION_MINOR})
endif ()
elseif (LuaJIT_FIND_VERSION)
# once there is a different major version supported this should become a loop
if (NOT LuaJIT_FIND_VERSION_MAJOR GREATER 5)
if (LuaJIT_FIND_VERSION_COUNT EQUAL 1)
set(luajit_append_versions ${LUA_VERSIONS5})
else ()
foreach (subver IN LISTS LUA_VERSIONS5)
if (NOT subver VERSION_LESS ${LuaJIT_FIND_VERSION})
list(APPEND luajit_append_versions ${subver})
endif ()
endforeach ()
endif ()
endif ()
else ()
# once there is a different major version supported this should become a loop
set(luajit_append_versions ${LUA_VERSIONS5})
endif ()
foreach (ver IN LISTS luajit_append_versions LUAJIT_VERSIONS)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
list(APPEND _luajit_include_subdirs
include/luajit${CMAKE_MATCH_1}${CMAKE_MATCH_2}
include/luajit${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
include/luajit-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
)
list(APPEND _luajit_library_names
luajit${CMAKE_MATCH_1}${CMAKE_MATCH_2}
luajit${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
luajit.${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
luajit-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
)
endforeach ()
foreach (ver IN LISTS LUA_VERSIONS5)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
list(APPEND _luajit_library_names
luajit${CMAKE_MATCH_1}${CMAKE_MATCH_2}
luajit${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
luajit.${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
luajit-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
)
endforeach ()
set(_luajit_include_subdirs "${_luajit_include_subdirs}" PARENT_SCOPE)
set(_luajit_library_names "${_luajit_library_names}" PARENT_SCOPE)
endfunction(set_lua_version_vars)
set_lua_version_vars()
find_path(LUAJIT_INCLUDE_DIR luajit.h
HINTS
ENV LUAJIT_DIR
PATH_SUFFIXES ${_luajit_include_subdirs} include/luajit-2.1 include/luajit include
PATHS
${LUAJIT_DIR}
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
unset(_luajit_include_subdirs)
find_library(LUAJIT_LIBRARY
NAMES ${_luajit_library_names} luajit
HINTS
ENV LUAJIT_DIR
PATH_SUFFIXES lib
PATHS
${LUAJIT_DIR}
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)
unset(_luajit_library_names)
if (LUAJIT_LIBRARY)
# include the math library for Unix
if (UNIX AND NOT APPLE AND NOT BEOS)
find_library(LUAJIT_MATH_LIBRARY m)
set(LUAJIT_LIBRARIES "${LUAJIT_LIBRARY};${LUAJIT_MATH_LIBRARY}")
# For Windows and Mac, don't need to explicitly include the math library
else ()
set(LUAJIT_LIBRARIES "${LUAJIT_LIBRARY}")
endif ()
set(LUAJIT_LIBRARY_DIR )
foreach (lib ${LUAJIT_LIBRARIES})
get_filename_component(lib_dir ${lib} DIRECTORY CACHE)
list(APPEND LUAJIT_LIBRARY_DIR ${lib_dir})
endforeach ()
endif ()
# This macro is taken word-for-word from the FindLua module and placed into a macro to keep the semantics the same
macro(get_lua_versions include_dir)
# At least 5.[012] have different ways to express the version
# so all of them need to be tested. Lua 5.2 defines LUA_VERSION
# and LUA_RELEASE as joined by the C preprocessor, so avoid those.
file(STRINGS "${${include_dir}}/lua.h" lua_version_strings
REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUAJIT_LUA_VERSION_MAJOR ";${lua_version_strings};")
if (LUAJIT_LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUAJIT_LUA_VERSION_MINOR ";${lua_version_strings};")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUAJIT_LUA_VERSION_PATCH ";${lua_version_strings};")
set(LUA_VERSION_STRING "${LUAJIT_LUA_VERSION_MAJOR}.${LUAJIT_LUA_VERSION_MINOR}.${LUAJIT_LUA_VERSION_PATCH}")
else ()
string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUAJIT_LUA_VERSION_STRING ";${lua_version_strings};")
if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUAJIT_LUA_VERSION_STRING ";${lua_version_strings};")
endif ()
string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUAJIT_LUA_VERSION_MAJOR "${LUAJIT_LUA_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUAJIT_LUA_VERSION_MINOR "${LUAJIT_LUA_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUAJIT_LUA_VERSION_PATCH "${LUAJIT_LUA_VERSION_STRING}")
endif ()
unset(lua_version_strings)
endmacro(get_lua_versions)
if (LUAJIT_INCLUDE_DIR AND EXISTS "${LUAJIT_INCLUDE_DIR}/luajit.h")
# LuaJIT defines two preprocessor macros:
# LUA_VERSION -> version string with lua version in it
# LUA_VERSION_NUM -> numeric representation, i.e. 20003 for 2.0.3
# This just parses the LUAJIT_VERSION macro and extracts the version.
file(STRINGS "${LUAJIT_INCLUDE_DIR}/luajit.h" version_strings
REGEX "^#define[ \t]+LUAJIT_VERSION?[ \t]+(\"LuaJIT [0-9\\.]+(-(beta|alpha)[0-9]*)?\").*")
string(REGEX REPLACE ".*;#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT ([0-9\\.]+(-(beta|alpha)[0-9]*)?)\"[ \t]*;.*" "\\1" LUAJIT_VERSION_STRING_SHORT ";${version_strings};")
string(REGEX REPLACE ".*;([0-9]+\\.[0-9]+\\.[0-9]+(-(beta|alpha)[0-9]*)?);.*" "\\1" luajit_version_num ";${LUAJIT_VERSION_STRING_SHORT};")
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.(-(beta|alpha)[0-9]*)?$" "\\1" LUAJIT_VERSION_MAJOR "${luajit_version_num}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9](-(beta|alpha)[0-9]*)?$" "\\1" LUAJIT_VERSION_MINOR "${luajit_version_num}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+(-(beta|alpha)[0-9]*)?)$" "\\1" LUAJIT_VERSION_PATCH "${luajit_version_num}")
get_lua_versions(LUAJIT_INCLUDE_DIR)
set(LUAJIT_VERSION_STRING "${LUAJIT_LUA_VERSION_STRING} (${LUAJIT_VERSION_STRING_SHORT})")
message("Found LuaJIT ${LUAJIT_VERSION_STRING}")
endif()
if(APPLE)
# Not sure why this is true, but its mentioned here:
# http://luajit.org/install.html#embed
set(LUAJIT_LINK_FLAGS "-pagezero_size 10000 -image_base 100000000")
else()
set(LUAJIT_LINK_FLAGS "")
endif()
find_program(LUAJIT_EXECUTABLE luajit)
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LuaJIT_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
FOUND_VAR LuaJIT_FOUND
REQUIRED_VARS LUAJIT_EXECUTABLE LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR
VERSION_VAR LUAJIT_VERSION_STRING)
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARY LUAJIT_MATH_LIBRARY LUAJIT_LIBRARY_DIR LUAJIT_LINK_FLAGS)

View file

@ -19,7 +19,7 @@
#include "libaegisub/lua/ffi.h" #include "libaegisub/lua/ffi.h"
#include "libaegisub/lua/utils.h" #include "libaegisub/lua/utils.h"
extern "C" int luaopen_luabins(lua_State *L); // extern "C" int luaopen_luabins(lua_State *L);
extern "C" int luaopen_re_impl(lua_State *L); extern "C" int luaopen_re_impl(lua_State *L);
extern "C" int luaopen_unicode_impl(lua_State *L); extern "C" int luaopen_unicode_impl(lua_State *L);
extern "C" int luaopen_lfs_impl(lua_State *L); extern "C" int luaopen_lfs_impl(lua_State *L);
@ -38,7 +38,7 @@ void preload_modules(lua_State *L) {
set_field(L, "aegisub.__unicode_impl", luaopen_unicode_impl); set_field(L, "aegisub.__unicode_impl", luaopen_unicode_impl);
set_field(L, "aegisub.__lfs_impl", luaopen_lfs_impl); set_field(L, "aegisub.__lfs_impl", luaopen_lfs_impl);
set_field(L, "lpeg", luaopen_lpeg); set_field(L, "lpeg", luaopen_lpeg);
set_field(L, "luabins", luaopen_luabins); // set_field(L, "luabins", luaopen_luabins);
lua_pop(L, 2); lua_pop(L, 2);