removed option to disable Lua support

Dieser Commit ist enthalten in:
Reinder Feenstra 2022-08-24 23:15:57 +02:00
Ursprung ff56381ba0
Commit ec58e35463
5 geänderte Dateien mit 30 neuen und 54 gelöschten Zeilen

Datei anzeigen

@ -18,7 +18,7 @@ The project goal is to develop open source software that can control everything
## Build Traintastic from source
*This section is only for developers, if your just want to use it [download Traintastic](https://traintastic.org/download).*
*This section is only for developers, if your just want to use it [download Traintastic](https://traintastic.org/download).*
### Requirements:
@ -58,9 +58,9 @@ Note: When cloning the source from git, git-lfs is required.
- Create a build directory: `cmake -E make_directory build`
- Go into the created build directory: `cd build`
- Configure CMake:
- Windows: `cmake ../ -G "Visual Studio 16 2019" -A x64 -T ClangCL -DCMAKE_BUILD_TYPE=Release -DUSB_XPRESSNET=OFF`
- Linux: `cmake ../ -DCMAKE_BUILD_TYPE=Release -DUSB_XPRESSNET=OFF`
- macOS: `cmake ../ -DCMAKE_BUILD_TYPE=Release -DUSB_XPRESSNET=OFF -DENABLE_LUA_SCRIPTING=OFF`
- Windows: `cmake ../ -G "Visual Studio 16 2019" -A x64 -T ClangCL -DCMAKE_BUILD_TYPE=Release`
- Linux: `cmake ../ -DCMAKE_BUILD_TYPE=Release`
- macOS: `cmake ../ -DCMAKE_BUILD_TYPE=Release`
- Build traintastic-server: `cmake --build . --config Release --target traintastic-server`

Datei anzeigen

@ -137,6 +137,8 @@ file(GLOB SOURCES
"src/hardware/protocol/z21/iohandler/*.cpp"
"src/log/*.hpp"
"src/log/*.cpp"
"src/lua/*.hpp"
"src/lua/*.cpp"
"src/network/*.hpp"
"src/network/*.cpp"
"src/train/*.hpp"
@ -157,6 +159,7 @@ file(GLOB SOURCES
file(GLOB TEST_SOURCES
"test/board/*.cpp"
"test/lua/*.cpp"
"test/objectcreatedestroy.cpp"
)
@ -218,45 +221,32 @@ target_link_libraries(traintastic-server PRIVATE ${LibArchive_LIBRARIES})
target_include_directories(traintastic-server-test PRIVATE ${LibArchive_INCLUDE_DIRS})
target_link_libraries(traintastic-server-test PRIVATE ${LibArchive_LIBRARIES})
### OPTIONS ###
# liblua5.3
if(WIN32)
add_definitions(-DLUA_BUILD_AS_DLL)
set(LUA_INCLUDE_DIR "thirdparty/lua5.3/include")
set(LUA_LIBRARIES lua53)
option(ENABLE_LUA_SCRIPTING "Lua scripting support" ON)
message(STATUS "Lua scripting support: ${ENABLE_LUA_SCRIPTING}")
if(ENABLE_LUA_SCRIPTING)
if(WIN32)
add_definitions(-DLUA_BUILD_AS_DLL)
set(LUA_INCLUDE_DIR "thirdparty/lua5.3/include")
set(LUA_LIBRARIES lua53)
add_custom_command(TARGET traintastic-server PRE_LINK
COMMAND lib "/def:${PROJECT_SOURCE_DIR}/thirdparty/lua5.3/bin/win64/lua53.def" /out:lua53.lib /machine:x64)
add_custom_command(TARGET traintastic-server-test PRE_LINK
COMMAND lib "/def:${PROJECT_SOURCE_DIR}/thirdparty/lua5.3/bin/win64/lua53.def" /out:lua53.lib /machine:x64)
add_custom_command(TARGET traintastic-server PRE_LINK
COMMAND lib "/def:${PROJECT_SOURCE_DIR}/thirdparty/lua5.3/bin/win64/lua53.def" /out:lua53.lib /machine:x64)
add_custom_command(TARGET traintastic-server-test PRE_LINK
COMMAND lib "/def:${PROJECT_SOURCE_DIR}/thirdparty/lua5.3/bin/win64/lua53.def" /out:lua53.lib /machine:x64)
# copy lua53.dll to build directory, to be able to run the tests:
add_custom_command(TARGET traintastic-server-test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/thirdparty/lua5.3/bin/win64/lua53.dll" .)
elseif(APPLE)
set(LUA_INCLUDE_DIR "/usr/local/opt/lua@5.3/include/lua")
set(LUA_LIBRARIES "/usr/local/opt/lua@5.3/lib/liblua5.3.dylib")
else()
find_package(Lua 5.3 REQUIRED)
endif()
file(GLOB SOURCES_LUA "src/lua/*.hpp" "src/lua/*.cpp")
list(APPEND SOURCES ${SOURCES_LUA})
target_include_directories(traintastic-server PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(traintastic-server PRIVATE ${LUA_LIBRARIES})
file(GLOB TEST_SOURCES_LUA "test/lua/*.cpp")
list(APPEND TEST_SOURCES ${TEST_SOURCES_LUA})
target_include_directories(traintastic-server-test PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(traintastic-server-test PRIVATE ${LUA_LIBRARIES})
# copy lua53.dll to build directory, to be able to run the tests:
add_custom_command(TARGET traintastic-server-test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/thirdparty/lua5.3/bin/win64/lua53.dll" .)
elseif(APPLE)
set(LUA_INCLUDE_DIR "/usr/local/opt/lua@5.3/include/lua")
set(LUA_LIBRARIES "/usr/local/opt/lua@5.3/lib/liblua5.3.dylib")
else()
add_definitions(-DDISABLE_LUA_SCRIPTING)
find_package(Lua 5.3 REQUIRED)
endif()
target_include_directories(traintastic-server PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(traintastic-server PRIVATE ${LUA_LIBRARIES})
target_include_directories(traintastic-server-test PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(traintastic-server-test PRIVATE ${LUA_LIBRARIES})
### OPTIONS END ###
### LIBRARIES END ###
target_sources(traintastic-server PRIVATE ${SOURCES})
target_sources(traintastic-server-test PRIVATE ${TEST_SOURCES} ${SOURCES})

Datei anzeigen

@ -64,9 +64,7 @@ void World::init(World& world)
world.clock.setValueInternal(std::make_shared<Clock>(world, world.clock.name()));
world.trains.setValueInternal(std::make_shared<TrainList>(world, world.trains.name()));
world.railVehicles.setValueInternal(std::make_shared<RailVehicleList>(world, world.railVehicles.name()));
#ifndef DISABLE_LUA_SCRIPTING
world.luaScripts.setValueInternal(std::make_shared<Lua::ScriptList>(world, world.luaScripts.name()));
#endif
world.linkRailTiles.setValueInternal(std::make_shared<LinkRailTileList>(world, world.linkRailTiles.name()));
}
@ -87,9 +85,7 @@ World::World(Private /*unused*/) :
clock{this, "clock", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore},
trains{this, "trains", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly},
railVehicles{this, "rail_vehicles", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly},
#ifndef DISABLE_LUA_SCRIPTING
luaScripts{this, "lua_scripts", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore},
#endif
linkRailTiles{this, "link_rail_tiles", nullptr, PropertyFlags::ReadOnly | PropertyFlags::SubObject | PropertyFlags::NoStore},
state{this, "state", WorldState(), PropertyFlags::ReadOnly | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly},
edit{this, "edit", false, PropertyFlags::ReadWrite | PropertyFlags::NoStore,
@ -253,10 +249,8 @@ World::World(Private /*unused*/) :
m_interfaceItems.add(trains);
Attributes::addObjectEditor(railVehicles, false);
m_interfaceItems.add(railVehicles);
#ifndef DISABLE_LUA_SCRIPTING
Attributes::addObjectEditor(luaScripts, false);
m_interfaceItems.add(luaScripts);
#endif
Attributes::addObjectEditor(linkRailTiles, false);
m_interfaceItems.add(linkRailTiles);

Datei anzeigen

@ -46,9 +46,7 @@
#include "../hardware/output/outputcontroller.hpp"
#include "../train/trainlist.hpp"
#include "../vehicle/rail/railvehiclelist.hpp"
#ifndef DISABLE_LUA_SCRIPTING
#include "../lua/scriptlist.hpp"
#endif
#include "../lua/scriptlist.hpp"
class WorldLoader;
class LinkRailTile;
@ -102,9 +100,7 @@ class World : public Object
ObjectProperty<Clock> clock;
ObjectProperty<TrainList> trains;
ObjectProperty<RailVehicleList> railVehicles;
#ifndef DISABLE_LUA_SCRIPTING
ObjectProperty<Lua::ScriptList> luaScripts;
#endif
ObjectProperty<LinkRailTileList> linkRailTiles;

Datei anzeigen

@ -39,9 +39,7 @@
#include "../hardware/decoder/decoderfunction.hpp"
#include "../vehicle/rail/railvehicles.hpp"
#include "../train/train.hpp"
#ifndef DISABLE_LUA_SCRIPTING
#include "../lua/script.hpp"
#endif
#include "../lua/script.hpp"
using nlohmann::json;
@ -221,10 +219,8 @@ void WorldLoader::createObject(ObjectData& objectData)
objectData.object = RailVehicles::create(*m_world, classId, id);
else if(classId == Train::classId)
objectData.object = Train::create(*m_world, id);
#ifndef DISABLE_LUA_SCRIPTING
else if(classId == Lua::Script::classId)
objectData.object = Lua::Script::create(*m_world, id);
#endif
if(!objectData.object)
throw LogMessageException(LogMessage::C1012_UNKNOWN_CLASS_X_CANT_RECREATE_OBJECT_X, classId, id);