diff --git a/CI/before_install.android.sh b/CI/before_install.android.sh index 0243a96092..59d98f48c4 100755 --- a/CI/before_install.android.sh +++ b/CI/before_install.android.sh @@ -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 diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index 8d0b8647b4..0a6123505e 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -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 ..." diff --git a/CI/install_debian_deps.sh b/CI/install_debian_deps.sh index 2f905314b5..6a7f4a84a7 100755 --- a/CI/install_debian_deps.sh +++ b/CI/install_debian_deps.sh @@ -18,10 +18,10 @@ declare -rA GROUPED_DEPS=( libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-iostreams-dev - + 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4661f673f1..d20e451676 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) - set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS} ${MT_BUILD} /bigobj") - else() - set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS} ${MT_BUILD}") - endif() + # \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") 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) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 3fb762d305..c5c85dae86 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -146,6 +146,7 @@ target_link_libraries(openmw "osg-ffmpeg-videoplayer" "oics" components + ${LUA_LIBRARIES} ) if(OSG_STATIC) diff --git a/cmake/FindLuaJit.cmake b/cmake/FindLuaJit.cmake new file mode 100644 index 0000000000..0f38da9b4b --- /dev/null +++ b/cmake/FindLuaJit.cmake @@ -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) + diff --git a/extern/sol_config/sol/config.hpp b/extern/sol_config/sol/config.hpp new file mode 100644 index 0000000000..fc8c93e64c --- /dev/null +++ b/extern/sol_config/sol/config.hpp @@ -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