mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-14 23:51:45 +00:00
Some patches for lua on windows
This commit is contained in:
parent
35de28e239
commit
6229269506
7 changed files with 93 additions and 10 deletions
|
@ -37,15 +37,20 @@ endif(BUILD_WITH_PAWN)
|
||||||
option(BUILD_WITH_LUA "Enable Terra/Lua language" ON)
|
option(BUILD_WITH_LUA "Enable Terra/Lua language" ON)
|
||||||
if(BUILD_WITH_LUA)
|
if(BUILD_WITH_LUA)
|
||||||
#set(Terra_ROOT ${CMAKE_SOURCE_DIR}/external/terra/)
|
#set(Terra_ROOT ${CMAKE_SOURCE_DIR}/external/terra/)
|
||||||
find_package(Terra REQUIRED)
|
if(WIN32)
|
||||||
|
find_package(Lua REQUIRED)
|
||||||
|
else()
|
||||||
|
find_package(Terra REQUIRED)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_TERRA")
|
||||||
|
endif()
|
||||||
set(LuaScript_Sources
|
set(LuaScript_Sources
|
||||||
Script/LangLua/LangLua.cpp
|
Script/LangLua/LangLua.cpp
|
||||||
Script/LangLua/LuaFunc.cpp)
|
Script/LangLua/LuaFunc.cpp)
|
||||||
set(LuaScript_Headers ${Terra_INCLUDES} ${CMAKE_SOURCE_DIR}/extern/LuaBridge ${CMAKE_SOURCE_DIR}/extern/LuaBridge/detail
|
set(LuaScript_Headers ${Terra_INCLUDES} ${Lua_INCLUDES} ${CMAKE_SOURCE_DIR}/extern/LuaBridge ${CMAKE_SOURCE_DIR}/extern/LuaBridge/detail
|
||||||
Script/LangLua/LangLua.hpp)
|
Script/LangLua/LangLua.hpp)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA")
|
||||||
include_directories(${Terra_INCLUDES} ${CMAKE_SOURCE_DIR}/extern/LuaBridge)
|
include_directories(${Terra_INCLUDES} ${Lua_INCLUDES} ${CMAKE_SOURCE_DIR}/extern/LuaBridge)
|
||||||
endif(BUILD_WITH_LUA)
|
endif(BUILD_WITH_LUA)
|
||||||
|
|
||||||
set(NativeScript_Sources
|
set(NativeScript_Sources
|
||||||
|
@ -105,6 +110,7 @@ target_link_libraries(tes3mp-server
|
||||||
${RakNet_LIBRARY}
|
${RakNet_LIBRARY}
|
||||||
components
|
components
|
||||||
${Terra_LIBRARY}
|
${Terra_LIBRARY}
|
||||||
|
${Lua_LIBRARY}
|
||||||
${Pawn_LIBRARY}
|
${Pawn_LIBRARY}
|
||||||
${Breakpad_Library}
|
${Breakpad_Library}
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,7 +23,9 @@ LangLua::LangLua()
|
||||||
{
|
{
|
||||||
lua = luaL_newstate();
|
lua = luaL_newstate();
|
||||||
luaL_openlibs(lua); // load all lua std libs
|
luaL_openlibs(lua); // load all lua std libs
|
||||||
|
#if defined(ENABLE_TERRA)
|
||||||
terra_init(lua);
|
terra_init(lua);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
LangLua::~LangLua()
|
LangLua::~LangLua()
|
||||||
|
@ -98,7 +100,11 @@ void LangLua::LoadProgram(const char *filename)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
#if defined(ENABLE_TERRA)
|
||||||
if ((err = terra_loadfile(lua, filename)) != 0)
|
if ((err = terra_loadfile(lua, filename)) != 0)
|
||||||
|
#else
|
||||||
|
if ((err =luaL_loadfile(lua, filename)) != 0)
|
||||||
|
#endif
|
||||||
throw runtime_error("Lua script " + string(filename) + " error (" + to_string(err) + "): \"" +
|
throw runtime_error("Lua script " + string(filename) + " error (" + to_string(err) + "): \"" +
|
||||||
string(lua_tostring(lua, -1)) + "\"");
|
string(lua_tostring(lua, -1)) + "\"");
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,13 @@
|
||||||
#ifndef PLUGINSYSTEM3_LANGLUA_HPP
|
#ifndef PLUGINSYSTEM3_LANGLUA_HPP
|
||||||
#define PLUGINSYSTEM3_LANGLUA_HPP
|
#define PLUGINSYSTEM3_LANGLUA_HPP
|
||||||
|
|
||||||
|
#ifdef ENABLE_TERRA
|
||||||
#include <terra/terra.h>
|
#include <terra/terra.h>
|
||||||
|
#else
|
||||||
|
#include <lua5.1/lua.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <extern/LuaBridge/LuaBridge.h>
|
||||||
#include <LuaBridge.h>
|
#include <LuaBridge.h>
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
|
|
|
@ -96,7 +96,7 @@ void Script::UnloadScripts()
|
||||||
{
|
{
|
||||||
//Public::DeleteAll();
|
//Public::DeleteAll();
|
||||||
scripts.clear();
|
scripts.clear();
|
||||||
#if defined (ENABLE_LUA)
|
#if defined (ENABLE_TERRA)
|
||||||
terra_llvmshutdown();
|
terra_llvmshutdown();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,6 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#if defined (ENABLE_LUA)
|
|
||||||
#include <terra/terra.h>
|
|
||||||
#include <extern/LuaBridge/LuaBridge.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Script : private ScriptFunctions
|
class Script : private ScriptFunctions
|
||||||
{
|
{
|
||||||
// http://imgur.com/hU0N4EH
|
// http://imgur.com/hU0N4EH
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#if defined (ENABLE_LUA)
|
#if defined (ENABLE_LUA)
|
||||||
#include <terra/terra.h>
|
#include "LangLua/LangLua.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (ENABLE_PAWN)
|
#if defined (ENABLE_PAWN)
|
||||||
|
|
70
cmake/FindLua.cmake
Normal file
70
cmake/FindLua.cmake
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# - Try to find Lua
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# Lua_FOUND - system has Lua
|
||||||
|
# Lua_INCLUDES - the Lua include directory
|
||||||
|
# Lua_LIBRARY - Link these to use Lua
|
||||||
|
|
||||||
|
FIND_LIBRARY (Lua_LIBRARY_RELEASE NAMES lua5.1
|
||||||
|
PATHS
|
||||||
|
ENV LD_LIBRARY_PATH
|
||||||
|
ENV LIBRARY_PATH
|
||||||
|
/usr/lib64
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib64
|
||||||
|
/usr/local/lib
|
||||||
|
/opt/local/lib
|
||||||
|
$ENV{Lua_ROOT}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY (Lua_LIBRARY_DEBUG NAMES lua5.1
|
||||||
|
PATHS
|
||||||
|
ENV LD_LIBRARY_PATH
|
||||||
|
ENV LIBRARY_PATH
|
||||||
|
/usr/lib64
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib64
|
||||||
|
/usr/local/lib
|
||||||
|
/opt/local/lib
|
||||||
|
$ENV{Lua_ROOT}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FIND_PATH (Lua_INCLUDES lua5.1/lua.h
|
||||||
|
ENV CPATH
|
||||||
|
/usr/include
|
||||||
|
/usr/local/include
|
||||||
|
/opt/local/include
|
||||||
|
$ENV{Lua_ROOT}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(Lua_INCLUDES AND Lua_LIBRARY_RELEASE)
|
||||||
|
SET(Lua_FOUND TRUE)
|
||||||
|
ENDIF(Lua_INCLUDES AND Lua_LIBRARY_RELEASE)
|
||||||
|
|
||||||
|
IF(NOT Lua_LIBRARY_DEBUG)
|
||||||
|
SET(Lua_LIBRARY_DEBUG ${Lua_LIBRARY_RELEASE})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(Lua_FOUND)
|
||||||
|
SET(Lua_INCLUDES ${Lua_INCLUDES})
|
||||||
|
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
|
IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
|
||||||
|
SET(Lua_LIBRARY optimized ${Lua_LIBRARY_RELEASE} debug ${Lua_LIBRARY_DEBUG} ${ZLIB_LIBRARIES})
|
||||||
|
ELSE()
|
||||||
|
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
|
||||||
|
# then just use the release libraries
|
||||||
|
SET(Lua_LIBRARY ${Lua_LIBRARY_RELEASE} ${ZLIB_LIBRARIES})
|
||||||
|
ENDIF()
|
||||||
|
IF(NOT Lua_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")
|
||||||
|
ENDIF(NOT Lua_FIND_QUIETLY)
|
||||||
|
ELSE(Lua_FOUND)
|
||||||
|
IF(Lua_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR "Could not find Lua")
|
||||||
|
ENDIF(Lua_FIND_REQUIRED)
|
||||||
|
ENDIF(Lua_FOUND)
|
||||||
|
|
Loading…
Reference in a new issue