Add Lua/LuaJit and sol3 to openmw

dont-compose-content
Petr Mikheev 4 years ago
parent c94339f248
commit 9e168fd9cc

@ -1,4 +1,4 @@
#!/bin/sh -ex
curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/android/openmw-android-deps-20201129.zip -o ~/openmw-android-deps.zip
curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/android/openmw-android-deps-20201230.zip -o ~/openmw-android-deps.zip
unzip -o ~/openmw-android-deps -d /usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr > /dev/null

@ -575,6 +575,11 @@ if [ -z $SKIP_DOWNLOAD ]; then
"https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/lz4_win${BITS}_v1_9_2.7z" \
"lz4_win${BITS}_v1_9_2.7z"
# LuaJIT
download "LuaJIT 2.1.0-beta3" \
"https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/LuaJIT-2.1.0-beta3-msvc${MSVC_REAL_YEAR}-win${BITS}.7z" \
"LuaJIT-2.1.0-beta3-msvc${MSVC_REAL_YEAR}-win${BITS}.7z"
# Google test and mock
if [ ! -z $TEST_FRAMEWORK ]; then
echo "Google test 1.10.0..."
@ -934,6 +939,25 @@ printf "LZ4 1.9.2... "
}
cd $DEPS
echo
# LuaJIT 2.1.0-beta3
printf "LuaJIT 2.1.0-beta3... "
{
if [ -d LuaJIT ]; then
printf "Exists. "
elif [ -z $SKIP_EXTRACT ]; then
rm -rf LuaJIT
eval 7z x -y LuaJIT-2.1.0-beta3-msvc${MSVC_REAL_YEAR}-win${BITS}.7z -o$(real_pwd)/LuaJIT $STRIP
fi
export LUAJIT_DIR="$(real_pwd)/LuaJIT"
add_cmake_opts -DLuaJit_INCLUDE_DIR="${LUAJIT_DIR}/include" \
-DLuaJit_LIBRARY="${LUAJIT_DIR}/lib/lua51.lib"
for CONFIGURATION in ${CONFIGURATIONS[@]}; do
add_runtime_dlls $CONFIGURATION "$(pwd)/LuaJIT/bin/lua51.dll"
done
echo Done.
}
cd $DEPS
echo
# Google Test and Google Mock
if [ ! -z $TEST_FRAMEWORK ]; then
printf "Google test 1.10.0 ..."

@ -21,7 +21,7 @@ declare -rA GROUPED_DEPS=(
libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev
libsdl2-dev libqt5opengl5-dev libopenal-dev libunshield-dev libtinyxml-dev
libbullet-dev liblz4-dev libpng-dev libjpeg-dev
libbullet-dev liblz4-dev libpng-dev libjpeg-dev libluajit-5.1-dev
ca-certificates
"
# TODO: add librecastnavigation-dev when debian is ready

@ -394,6 +394,22 @@ endif()
find_package(SDL2 2.0.9 REQUIRED)
find_package(OpenAL REQUIRED)
option(USE_LUAJIT "Switch Lua/LuaJit (TRUE is highly recommended)" TRUE)
if(USE_LUAJIT)
find_package(LuaJit REQUIRED)
set(LUA_INCLUDE_DIR ${LuaJit_INCLUDE_DIR})
set(LUA_LIBRARIES ${LuaJit_LIBRARIES})
else(USE_LUAJIT)
find_package(Lua REQUIRED)
add_compile_definitions(NO_LUAJIT)
endif(USE_LUAJIT)
# Download sol - C++ library binding to Lua
file(DOWNLOAD
"https://github.com/ThePhD/sol2/releases/download/v3.2.2/sol.hpp" "${OpenMW_BINARY_DIR}/extern/sol3.2.2/sol/sol.hpp"
EXPECTED_MD5 ba113cf458f60672917108e69bb4d958)
set(SOL_INCLUDE_DIRS ${OpenMW_BINARY_DIR}/extern/sol3.2.2 ${OpenMW_SOURCE_DIR}/extern/sol_config)
include_directories(
BEFORE SYSTEM
"."
@ -403,6 +419,8 @@ include_directories(
${OPENAL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${BULLET_INCLUDE_DIRS}
${LUA_INCLUDE_DIR}
${SOL_INCLUDE_DIRS}
)
link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
@ -661,11 +679,10 @@ if (WIN32)
endif()
if (BUILD_OPENMW)
if (OPENMW_UNITY_BUILD)
# \bigobj is required:
# 1) for OPENMW_UNITY_BUILD;
# 2) to compile lua binginds, because sol3 is heavily templated.
set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS} ${MT_BUILD} /bigobj")
else()
set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS} ${MT_BUILD}")
endif()
endif()
if (BUILD_WIZARD)
@ -682,6 +699,11 @@ if (WIN32)
#set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif()
if (BUILD_OPENMW AND APPLE)
# Without these flags LuaJit crashes on startup on OSX
set_target_properties(openmw PROPERTIES LINK_FLAGS "-pagezero_size 10000 -image_base 100000000")
endif()
# Apple bundling
if (OPENMW_OSX_DEPLOYMENT AND APPLE)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND CMAKE_VERSION VERSION_LESS 3.13.4)

@ -146,6 +146,7 @@ target_link_libraries(openmw
"osg-ffmpeg-videoplayer"
"oics"
components
${LUA_LIBRARIES}
)
if(OSG_STATIC)

@ -0,0 +1,14 @@
# Once found, defines:
# LuaJit_FOUND
# LuaJit_INCLUDE_DIR
# LuaJit_LIBRARIES
include(LibFindMacros)
libfind_pkg_detect(LuaJit luajit
FIND_PATH luajit.h PATH_SUFFIXES luajit luajit-2.1
FIND_LIBRARY luajit-5.1 luajit
)
libfind_process(LuaJit)

@ -0,0 +1,15 @@
#ifndef SOL_SINGLE_CONFIG_HPP
#define SOL_SINGLE_CONFIG_HPP
#define SOL_SAFE_USERTYPE 1
#define SOL_SAFE_REFERENCES 1
#define SOL_SAFE_FUNCTION_CALLS 1
#define SOL_SAFE_FUNCTION 1
#define SOL_NO_NIL 0
#ifndef NO_LUAJIT
#define SOL_LUAJIT 1
#define SOL_EXCEPTIONS_SAFE_PROPAGATION 0
#endif
#endif // SOL_SINGLE_CONFIG_HPP
Loading…
Cancel
Save