Skip to content

Commit

Permalink
Merge pull request #3 from ChugunovRoman/feat-add-lfs
Browse files Browse the repository at this point in the history
feat: Add lua file system library
  • Loading branch information
ChugunovRoman authored Apr 6, 2022
2 parents e63ae70 + 59ced78 commit a8ee211
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
[submodule "Externals/sse2neon"]
path = Externals/sse2neon
url = https://github.com/DLTcollab/sse2neon.git
[submodule "Externals/xrLuaFS"]
path = Externals/xrLuaFS
url = https://github.com/ChugunovRoman/luafilesystem.git
branch = open-x-ray-coc
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ message("git branch: " ${GIT_BRANCH})
include_directories(
${CMAKE_SOURCE_DIR}/Externals
${CMAKE_SOURCE_DIR}/Externals/luabind
${CMAKE_SOURCE_DIR}/Externals/xrLuaFS
${CMAKE_SOURCE_DIR}/Externals/xrLuaFS/src
)

add_subdirectory(Externals)
Expand Down
1 change: 1 addition & 0 deletions Externals/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_subdirectory(cximage)
add_subdirectory(GameSpy)
add_subdirectory(OPCODE)
add_subdirectory(ode)
add_subdirectory(xrLuaFS)
#add_subdirectory(NVTT)

if (MEMORY_ALLOCATOR STREQUAL "mimalloc")
Expand Down
2 changes: 1 addition & 1 deletion Externals/libtheora_static.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions Externals/xrLuaFS
Submodule xrLuaFS added at 8d6d5d
39 changes: 39 additions & 0 deletions Externals/xrLuaFS.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
<Import Project="..\src\xray_project_configurations.props" />
</ImportGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B23D8795-0C38-4684-A7A0-0155804C2E96}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ImportGroup Label="PropertySheets">
<Import Project="..\src\xray_project_configuration.props" />
</ImportGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\src\xray.props" />
</ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="xrLuaFS\src\lfs.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(xrExternals)LuaJIT-proj\LuaJIT.vcxproj">
<Project>{632aeeb6-dc06-4e15-9551-b2b09a4b73c5}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
19 changes: 19 additions & 0 deletions src/engine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzo", "..\Externals\lzo.vcx
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\Externals\zlib.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrLuaFS", "..\Externals\xrLuaFS.vcxproj", "{B23D8795-0C38-4684-A7A0-0155804C2E96}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg_static", "..\Externals\libogg_static.vcxproj", "{15CBFEFF-7965-41F5-B4E2-21E8795C9159}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtheora_static", "..\Externals\libtheora_static.vcxproj", "{653F3841-3F26-49B9-AFCF-091DB4B67031}"
Expand Down Expand Up @@ -871,6 +873,22 @@ Global
{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64
{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x86.ActiveCfg = Release|Win32
{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x86.Build.0 = Release|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Debug|x64.ActiveCfg = Debug|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Debug|x64.Build.0 = Debug|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Debug|x86.ActiveCfg = Debug|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Debug|x86.Build.0 = Debug|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Mixed|x64.ActiveCfg = Mixed|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Mixed|x64.Build.0 = Mixed|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Mixed|x86.ActiveCfg = Mixed|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Mixed|x86.Build.0 = Mixed|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release Master Gold|x64.ActiveCfg = Release Master Gold|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release Master Gold|x64.Build.0 = Release Master Gold|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release Master Gold|x86.ActiveCfg = Release Master Gold|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release Master Gold|x86.Build.0 = Release Master Gold|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release|x64.ActiveCfg = Release|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release|x64.Build.0 = Release|x64
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release|x86.ActiveCfg = Release|Win32
{B23D8795-0C38-4684-A7A0-0155804C2E96}.Release|x86.Build.0 = Release|Win32
{15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|x64.ActiveCfg = Debug|x64
{15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|x64.Build.0 = Debug|x64
{15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|x86.ActiveCfg = Debug|Win32
Expand Down Expand Up @@ -1212,6 +1230,7 @@ Global
{632AEEB6-DC06-4E15-9551-B2B09A4B73C5} = {DAEF6FB5-4F98-4B34-B049-8828EFEC9250}
{DAFD6D98-3DCD-40AD-BC85-EC71797B6767} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348}
{ABB5EAE7-B3E6-432E-B636-333449892EA6} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348}
{B23D8795-0C38-4684-A7A0-0155804C2E96} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348}
{FABD5BBF-EA6F-4633-A34F-95CDC553CA36} = {CB0C814D-FB4E-453B-B7A0-716F4A1EACA4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
2 changes: 2 additions & 0 deletions src/xrScriptEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/Externals/luabind
${CMAKE_SOURCE_DIR}/Externals/xrLuaFS
${SDL_INCLUDE_DIRS}
)

Expand All @@ -58,6 +59,7 @@ target_link_libraries(${PROJECT_NAME}
xrAPI
xrCore
xrLuabind
xrLuaFS
${LUA_LIBRARIES}
)

Expand Down
8 changes: 5 additions & 3 deletions src/xrScriptEngine/script_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifdef USE_DEBUGGER
#include "script_debugger.hpp"
#endif
#include <lfs.h>
#include <stdarg.h>
#include "Common/Noncopyable.hpp"
#include "xrCore/ModuleLookup.hpp"
Expand Down Expand Up @@ -687,11 +688,11 @@ void CScriptEngine::initialize_lua_studio(lua_State* state, cs::lua_studio::worl
return;
}

s_create_world =
s_create_world =
(create_world_function_type)s_script_debugger_module->GetProcAddress("_cs_lua_studio_backend_create_world@12");
R_ASSERT2(s_create_world, "can't find function \"cs_lua_studio_backend_create_world\"");

s_destroy_world =
s_destroy_world =
(destroy_world_function_type)s_script_debugger_module->GetProcAddress("_cs_lua_studio_backend_destroy_world@4");
R_ASSERT2(s_destroy_world, "can't find function \"cs_lua_studio_backend_destroy_world\" in the library");

Expand Down Expand Up @@ -926,7 +927,7 @@ void CScriptEngine::init(ExporterFunc exporterFunc, bool loadGlobalNamespace)
{
const bool nilConversion =
pSettingsOpenXRay->read_if_exists<bool>("lua_scripting", "allow_nil_conversion", true);

luabind::allow_nil_conversion(nilConversion);
luabind::disable_super_deprecation();

Expand Down Expand Up @@ -965,6 +966,7 @@ void CScriptEngine::init(ExporterFunc exporterFunc, bool loadGlobalNamespace)
luajit::open_lib(lua(), LUA_STRLIBNAME, luaopen_string);
luajit::open_lib(lua(), LUA_BITLIBNAME, luaopen_bit);
luajit::open_lib(lua(), LUA_FFILIBNAME, luaopen_ffi);
luajit::open_lib(lua(), LUA_FSLIBNAME, luaopen_lfs);
#ifndef MASTER_GOLD
luajit::open_lib(lua(), LUA_DBLIBNAME, luaopen_debug);
#endif
Expand Down
10 changes: 9 additions & 1 deletion src/xrScriptEngine/xrScriptEngine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<ClCompile>
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
<PreprocessorDefinitions>_USRDLL;XRSCRIPTENGINE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(xrExternals)xrLuaFS;
$(xrExternals)xrLuaFS\src;
%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down Expand Up @@ -84,9 +89,12 @@
<ProjectReference Include="$(xrExternals)luabind.vcxproj">
<Project>{ccd4afae-aa10-42c6-a452-fdee497ccdf1}</Project>
</ProjectReference>
<ProjectReference Include="..\..\Externals\LuaJIT-proj\LuaJIT.vcxproj">
<ProjectReference Include="$(xrExternals)LuaJIT-proj\LuaJIT.vcxproj">
<Project>{632aeeb6-dc06-4e15-9551-b2b09a4b73c5}</Project>
</ProjectReference>
<ProjectReference Include="$(xrExternals)xrLuaFS.vcxproj">
<Project>{b23d8795-0c38-4684-a7a0-0155804c2e96}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Natvis Include="..\OpenXRay.natvis" />
Expand Down
1 change: 1 addition & 0 deletions src/xray_input.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$(xrSdkDir)include;
$(xrExternals);
$(xrExternals)luajit\src;
$(xrExternals)xrLuaFS\src;
$(xrExternals)luabind;
%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
Expand Down

0 comments on commit a8ee211

Please sign in to comment.