1 @rem Script to build LuaJIT with the PS5 SDK.
\r
2 @rem Donated to the public domain.
\r
4 @rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler)
\r
5 @rem or "VS20xx x64 Native Tools Command Prompt".
\r
7 @rem Then cd to this directory and run this script.
\r
9 @rem Recommended invocation:
\r
11 @rem ps5build release build, amalgamated, 64-bit GC
\r
12 @rem ps5build debug debug build, amalgamated, 64-bit GC
\r
14 @rem Additional command-line options (not generally recommended):
\r
16 @rem gc32 (before debug) 32-bit GC
\r
17 @rem noamalg (after debug) non-amalgamated build
\r
19 @if not defined INCLUDE goto :FAIL
\r
20 @if not defined SCE_PROSPERO_SDK_DIR goto :FAIL
\r
23 @rem ---- Host compiler ----
\r
24 @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
\r
25 @set LJLINK=link /nologo
\r
26 @set LJMT=mt /nologo
\r
27 @set DASMDIR=..\dynasm
\r
28 @set DASM=%DASMDIR%\dynasm.lua
\r
29 @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 lib_buffer.c
\r
31 @set DASC=vm_x64.dasc
\r
33 @if "%1" neq "gc32" goto :NOGC32
\r
35 @set GC64=-DLUAJIT_DISABLE_GC64
\r
36 @set DASC=vm_x86.dasc
\r
39 %LJCOMPILE% host\minilua.c
\r
40 @if errorlevel 1 goto :BAD
\r
41 %LJLINK% /out:minilua.exe minilua.obj
\r
42 @if errorlevel 1 goto :BAD
\r
43 if exist minilua.exe.manifest^
\r
44 %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
\r
46 @rem Check for 64 bit host compiler.
\r
48 @if not errorlevel 8 goto :FAIL
\r
50 @set DASMFLAGS=-D P64 -D NO_UNWIND
\r
51 minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
\r
52 @if errorlevel 1 goto :BAD
\r
54 if exist ..\.git ( git show -s --format=%%ct >luajit_relver.txt ) else ( type ..\.relver >luajit_relver.txt )
\r
55 minilua host\genversion.lua
\r
57 %LJCOMPILE% /I "." /I %DASMDIR% %GC64% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c
\r
58 @if errorlevel 1 goto :BAD
\r
59 %LJLINK% /out:buildvm.exe buildvm*.obj
\r
60 @if errorlevel 1 goto :BAD
\r
61 if exist buildvm.exe.manifest^
\r
62 %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
\r
64 buildvm -m elfasm -o lj_vm.s
\r
65 @if errorlevel 1 goto :BAD
\r
66 buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
\r
67 @if errorlevel 1 goto :BAD
\r
68 buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
\r
69 @if errorlevel 1 goto :BAD
\r
70 buildvm -m libdef -o lj_libdef.h %ALL_LIB%
\r
71 @if errorlevel 1 goto :BAD
\r
72 buildvm -m recdef -o lj_recdef.h %ALL_LIB%
\r
73 @if errorlevel 1 goto :BAD
\r
74 buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
\r
75 @if errorlevel 1 goto :BAD
\r
76 buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
\r
77 @if errorlevel 1 goto :BAD
\r
79 @rem ---- Cross compiler ----
\r
80 @set LJCOMPILE="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -Wall -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC %GC64%
\r
81 @set LJLIB="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-llvm-ar" rcus
\r
84 "%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -o lj_vm.o lj_vm.s
\r
86 @if "%1" neq "debug" goto :NODEBUG
\r
88 @set LJCOMPILE=%LJCOMPILE% -g -O0
\r
89 @set TARGETLIB=libluajitD_ps5.a
\r
92 @set LJCOMPILE=%LJCOMPILE% -O2
\r
93 @set TARGETLIB=libluajit_ps5.a
\r
96 @if "%1" neq "noamalg" goto :AMALG
\r
97 for %%f in (lj_*.c lib_*.c) do (
\r
99 @if errorlevel 1 goto :BAD
\r
102 %LJLIB% %TARGETLIB% lj_*.o lib_*.o
\r
103 @if errorlevel 1 goto :BAD
\r
106 %LJCOMPILE% ljamalg.c
\r
107 @if errorlevel 1 goto :BAD
\r
108 %LJLIB% %TARGETLIB% ljamalg.o lj_vm.o
\r
109 @if errorlevel 1 goto :BAD
\r
112 @del *.o *.obj *.manifest minilua.exe buildvm.exe
\r
114 @echo === Successfully built LuaJIT for PS5 ===
\r
119 @echo *******************************************************
\r
120 @echo *** Build FAILED -- Please check the error messages ***
\r
121 @echo *******************************************************
\a\r
124 @echo To run this script you must open a "Visual Studio .NET Command Prompt"
\r
125 @echo (64 bit host compiler). The PS5 Prospero SDK must be installed, too.
\r