mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Add Xbox One port.
This commit is contained in:
parent
458a40b724
commit
26b95a90f5
@ -124,7 +124,7 @@ operating systems, CPUs and compilers:
|
||||
<td class="compatos">GCC 4.x</td>
|
||||
<td class="compatos">ORBIS (<a href="#ps4">PS4</a>)</td>
|
||||
<td class="compatos">GCC 4.x</td>
|
||||
<td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0</td>
|
||||
<td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0<br>Durango (<a href="#xboxone">Xbox One</a>)</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td>
|
||||
@ -516,6 +516,16 @@ the following commands:
|
||||
cd src
|
||||
xedkbuild
|
||||
</pre>
|
||||
<p>
|
||||
To cross-compile for <b id="xboxone">Xbox One</b> from a Windows host,
|
||||
open a "Visual Studio .NET Command Prompt" (64 bit host compiler),
|
||||
<tt>cd</tt> to the directory where you've unpacked the sources and run
|
||||
the following commands:
|
||||
</p>
|
||||
<pre class="code">
|
||||
cd src
|
||||
xb1build
|
||||
</pre>
|
||||
|
||||
<h2 id="embed">Embedding LuaJIT</h2>
|
||||
<p>
|
||||
|
@ -166,7 +166,7 @@ LuaJIT is Copyright © 2005-2015 Mike Pall, released under the
|
||||
<tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr>
|
||||
</table>
|
||||
<table class="feature os os3">
|
||||
<tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td></tr>
|
||||
<tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td><td>Xbox One</td></tr>
|
||||
</table>
|
||||
<table class="feature compiler">
|
||||
<tr><td>GCC</td><td>CLANG<br>LLVM</td><td>MSVC</td></tr>
|
||||
|
@ -99,7 +99,7 @@ static int io_file_close(lua_State *L, IOFileUD *iof)
|
||||
int stat = -1;
|
||||
#if LJ_TARGET_POSIX
|
||||
stat = pclose(iof->fp);
|
||||
#elif LJ_TARGET_WINDOWS
|
||||
#elif LJ_TARGET_WINDOWS && !LJ_TARGET_XBOXONE
|
||||
stat = _pclose(iof->fp);
|
||||
#else
|
||||
lua_assert(0);
|
||||
@ -400,7 +400,7 @@ LJLIB_CF(io_open)
|
||||
|
||||
LJLIB_CF(io_popen)
|
||||
{
|
||||
#if LJ_TARGET_POSIX || LJ_TARGET_WINDOWS
|
||||
#if LJ_TARGET_POSIX || (LJ_TARGET_WINDOWS && !LJ_TARGET_XBOXONE)
|
||||
const char *fname = strdata(lj_lib_checkstr(L, 1));
|
||||
GCstr *s = lj_lib_optstr(L, 2);
|
||||
const char *mode = s ? strdata(s) : "r";
|
||||
|
@ -96,9 +96,17 @@ static void setprogdir(lua_State *L)
|
||||
static void pusherror(lua_State *L)
|
||||
{
|
||||
DWORD error = GetLastError();
|
||||
#if LJ_TARGET_XBOXONE
|
||||
wchar_t wbuffer[128];
|
||||
char buffer[128*2];
|
||||
if (FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, error, 0, buffer, sizeof(wbuffer)/sizeof(wchar_t), NULL) &&
|
||||
WideCharToMultiByte(CP_ACP, 0, wbuffer, 128, buffer, 128*2, NULL, NULL))
|
||||
#else
|
||||
char buffer[128];
|
||||
if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, error, 0, buffer, sizeof(buffer), NULL))
|
||||
#endif
|
||||
lua_pushstring(L, buffer);
|
||||
else
|
||||
lua_pushfstring(L, "system error %d\n", error);
|
||||
|
@ -120,6 +120,13 @@
|
||||
#define LJ_TARGET_CONSOLE 1
|
||||
#endif
|
||||
|
||||
#ifdef _DURANGO
|
||||
#define LJ_TARGET_XBOXONE 1
|
||||
#define LJ_TARGET_CONSOLE 1
|
||||
#define LJ_TARGET_GC64 1
|
||||
#define LoadLibraryA(name) LoadLibraryExA((name), NULL, 0)
|
||||
#endif
|
||||
|
||||
#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */
|
||||
#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */
|
||||
#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */
|
||||
|
@ -172,9 +172,17 @@ LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt,
|
||||
const char *name)
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
#if LJ_TARGET_XBOXONE
|
||||
wchar_t wbuf[128];
|
||||
char buf[128*2];
|
||||
if (!FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, err, 0, buf, sizeof(wbuf)/sizeof(wchar_t), NULL) ||
|
||||
!WideCharToMultiByte(CP_ACP, 0, wbuf, 128, buf, 128*2, NULL, NULL))
|
||||
#else
|
||||
char buf[128];
|
||||
if (!FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, err, 0, buf, sizeof(buf), NULL))
|
||||
#endif
|
||||
buf[0] = '\0';
|
||||
lj_err_callermsg(L, lj_strfmt_pushf(L, fmt, name, buf));
|
||||
}
|
||||
|
101
src/xb1build.bat
Normal file
101
src/xb1build.bat
Normal file
@ -0,0 +1,101 @@
|
||||
@rem Script to build LuaJIT with the Xbox One SDK.
|
||||
@rem Donated to the public domain.
|
||||
@rem
|
||||
@rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler)
|
||||
@rem Then cd to this directory and run this script.
|
||||
|
||||
@if not defined INCLUDE goto :FAIL
|
||||
@if not defined DurangoXDK goto :FAIL
|
||||
|
||||
@setlocal
|
||||
@echo ---- Host compiler ----
|
||||
@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /DLUAJIT_ENABLE_GC64
|
||||
@set LJLINK=link /nologo
|
||||
@set LJMT=mt /nologo
|
||||
@set DASMDIR=..\dynasm
|
||||
@set DASM=%DASMDIR%\dynasm.lua
|
||||
@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
|
||||
|
||||
%LJCOMPILE% host\minilua.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
%LJLINK% /out:minilua.exe minilua.obj
|
||||
@if errorlevel 1 goto :BAD
|
||||
if exist minilua.exe.manifest^
|
||||
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
|
||||
|
||||
@rem Error out for 64 bit host compiler
|
||||
@minilua
|
||||
@if not errorlevel 8 goto :FAIL
|
||||
|
||||
@set DASMFLAGS=-D WIN -D FFI -D P64
|
||||
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x64.dasc
|
||||
@if errorlevel 1 goto :BAD
|
||||
|
||||
%LJCOMPILE% /I "." /I %DASMDIR% /D_DURANGO host\buildvm*.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
%LJLINK% /out:buildvm.exe buildvm*.obj
|
||||
@if errorlevel 1 goto :BAD
|
||||
if exist buildvm.exe.manifest^
|
||||
%LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
|
||||
|
||||
buildvm -m peobj -o lj_vm.obj
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m libdef -o lj_libdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m recdef -o lj_recdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
|
||||
@echo ---- Cross compiler ----
|
||||
|
||||
@set CWD=%cd%
|
||||
@call "%DurangoXDK%\xdk\DurangoVars.cmd" XDK
|
||||
@cd /D "%CWD%"
|
||||
@shift
|
||||
|
||||
@set LJCOMPILE="cl" /nologo /c /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /D_LIB /D_UNICODE /D_DURANGO
|
||||
@set LJLIB="lib" /nologo
|
||||
|
||||
@if "%1"=="debug" (
|
||||
@shift
|
||||
@set LJCOMPILE=%LJCOMPILE% /Zi /MDd /Od
|
||||
@set LJLINK=%LJLINK% /debug
|
||||
) else (
|
||||
@set LJCOMPILE=%LJCOMPILE% /MD /O2 /DNDEBUG
|
||||
)
|
||||
|
||||
@if "%1"=="amalg" goto :AMALG
|
||||
%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
%LJLIB% /OUT:luajit.lib lj_*.obj lib_*.obj
|
||||
@if errorlevel 1 goto :BAD
|
||||
@goto :NOAMALG
|
||||
:AMALG
|
||||
%LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
%LJLIB% /OUT:luajit.lib ljamalg.obj lj_vm.obj
|
||||
@if errorlevel 1 goto :BAD
|
||||
:NOAMALG
|
||||
|
||||
@del *.obj *.manifest minilua.exe buildvm.exe
|
||||
@echo.
|
||||
@echo === Successfully built LuaJIT for Xbox One ===
|
||||
|
||||
@goto :END
|
||||
:BAD
|
||||
@echo.
|
||||
@echo *******************************************************
|
||||
@echo *** Build FAILED -- Please check the error messages ***
|
||||
@echo *******************************************************
|
||||
@goto :END
|
||||
:FAIL
|
||||
@echo To run this script you must open a "Visual Studio .NET Command Prompt"
|
||||
@echo (64 bit host compiler). The Xbox One SDK must be installed, too.
|
||||
:END
|
Loading…
Reference in New Issue
Block a user