Skip to content

Commit 53a3b01

Browse files
Merge branch 'feature/ps5' into develop
2 parents afce01c + 3b71175 commit 53a3b01

6 files changed

Lines changed: 64 additions & 5 deletions

File tree

Plugins/UnLua/Source/ThirdParty/Lua/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ elseif(APPLE)
5252
${LUA_CORE}
5353
)
5454
endif()
55+
elseif(PS5)
56+
add_definitions(-DLUA_NO_OS_EXECUTE)
57+
add_definitions(-DLUA_NO_OS_TMPNAME)
58+
add_definitions(-DLUA_NO_IO_TMPFILE)
59+
add_library(Lua STATIC
60+
${LUA_CORE}
61+
)
62+
target_include_directories(Lua SYSTEM
63+
PRIVATE ${SCE_PROSPERO_SDK_DIR}/target/include
64+
PRIVATE ${SCE_PROSPERO_SDK_DIR}/target/include_common
65+
PRIVATE ${LUA_SRC_PATH}/../src-ps5
66+
)
5567
else()
5668
add_library(Lua STATIC
5769
${LUA_CORE}

Plugins/UnLua/Source/ThirdParty/Lua/Lua.Build.cs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private void BuildForLinuxAArch64()
171171
var buildFile = Path.Combine(buildDir, m_LibName);
172172
File.Copy(buildFile, libFile, true);
173173
}
174-
174+
175175
private void BuildForMac()
176176
{
177177
var abiName = Target.Architecture;
@@ -212,6 +212,38 @@ private void BuildForIOS()
212212
PublicAdditionalLibraries.Add(libFile);
213213
}
214214

215+
private void BuildForPS5()
216+
{
217+
var libFile = GetLibraryPath();
218+
PublicAdditionalLibraries.Add(libFile);
219+
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, m_LuaDirName, "src-ps5"));
220+
221+
if (File.Exists(libFile))
222+
return;
223+
224+
var sceRootDir = Environment.GetEnvironmentVariable("SCE_ROOT_DIR");
225+
if (string.IsNullOrEmpty(sceRootDir))
226+
throw new BuildException("SCE_ROOT_DIR environment variable needed.");
227+
228+
var sceSdkDir = Environment.GetEnvironmentVariable("SCE_PROSPERO_SDK_DIR");
229+
if (string.IsNullOrEmpty(sceSdkDir))
230+
throw new BuildException("SCE_PROSPERO_SDK_DIR environment variable needed.");
231+
232+
EnsureDirectoryExists(libFile);
233+
var sysRoot = Path.Combine(sceSdkDir, @"target");
234+
var clangPath = Path.Combine(sceSdkDir, @"host_tools/bin/prospero-clang.exe");
235+
var clangPlusPlusPath = Path.Combine(sceSdkDir, @"host_tools/bin/prospero-clang.exe");
236+
var arPath = Path.Combine(sceSdkDir, @"host_tools/bin/prospero-llvm-ar.exe");
237+
var args = new Dictionary<string, string>
238+
{
239+
{ "CMAKE_TOOLCHAIN_FILE", Path.Combine(sceRootDir, @"Prospero\Tools\CMake\PS5.cmake") },
240+
{ "PS5", "1"}
241+
};
242+
var buildDir = CMake(args);
243+
var buildFile = Path.Combine(buildDir, m_Config, m_LibName);
244+
File.Copy(buildFile, libFile, true);
245+
}
246+
215247
#endregion
216248

217249
private string CMake(Dictionary<string, string> extraArgs = null)
@@ -284,7 +316,7 @@ private string CMake(Dictionary<string, string> extraArgs = null)
284316
foreach (var arg in extraArgs)
285317
writer.Write(" -D{0}={1}", arg.Key, arg.Value);
286318
writer.WriteLine();
287-
writer.WriteLine("cd ../..");
319+
writer.WriteLine("cd ../..");
288320
writer.WriteLine("cmake --build {0}/build --config {1}", m_LuaDirName, m_Config);
289321
}
290322

@@ -391,6 +423,7 @@ private string GetBuildSystem()
391423
return "Xcode";
392424
return "Unix Makefiles";
393425
}
426+
394427
return null;
395428
}
396429

@@ -410,4 +443,4 @@ private void SetupForRuntimeDependency(string fullPath, string platform)
410443
private readonly string m_LuaDirName;
411444
private readonly string m_BuildSystem;
412445
private readonly bool m_CompileAsCpp;
413-
}
446+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
#ifndef _PS5_SIGNAL
3+
#define _PS5_SIGNAL
4+
#endif
5+
6+
#include <sys/signal.h>

Plugins/UnLua/Source/ThirdParty/Lua/lua-5.4.3/src/liolib.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,13 @@ static int io_popen (lua_State *L) {
299299

300300

301301
static int io_tmpfile (lua_State *L) {
302+
#if defined(LUA_NO_IO_TMPFILE)
303+
return 0;
304+
#else
302305
LStream *p = newfile(L);
303306
p->f = tmpfile();
304307
return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1;
308+
#endif
305309
}
306310

307311

Plugins/UnLua/Source/ThirdParty/Lua/lua-5.4.3/src/loslib.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,17 @@ static int os_rename (lua_State *L) {
172172

173173

174174
static int os_tmpname (lua_State *L) {
175+
#if defined(LUA_NO_OS_TMPNAME)
176+
return 0;
177+
#else
175178
char buff[LUA_TMPNAMBUFSIZE];
176179
int err;
177180
lua_tmpnam(buff, err);
178181
if (l_unlikely(err))
179182
return luaL_error(L, "unable to generate a unique filename");
180183
lua_pushstring(L, buff);
181184
return 1;
185+
#endif
182186
}
183187

184188

Plugins/UnLua/Source/UnLua/Private/DefaultParamCollection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
TMap<FName, FFunctionCollection> GDefaultParamCollection;
1919

20-
#pragma optimize("", off)
20+
PRAGMA_DISABLE_OPTIMIZATION
2121

2222
void CreateDefaultParamCollection()
2323
{
@@ -30,4 +30,4 @@ void CreateDefaultParamCollection()
3030
}
3131
}
3232

33-
#pragma optimize("", on)
33+
PRAGMA_ENABLE_OPTIMIZATION

0 commit comments

Comments
 (0)