1 @rem Script to build LuaJIT with the PS4 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 Then cd to this directory and run this script.
\r
7 @if not defined INCLUDE goto :FAIL
\r
8 @if not defined SCE_ORBIS_SDK_DIR goto :FAIL
\r
11 @rem ---- Host compiler ----
\r
12 @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
\r
13 @set LJLINK=link /nologo
\r
14 @set LJMT=mt /nologo
\r
15 @set DASMDIR=..\dynasm
\r
16 @set DASM=%DASMDIR%\dynasm.lua
\r
17 @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
\r
19 %LJCOMPILE% host\minilua.c
\r
20 @if errorlevel 1 goto :BAD
\r
21 %LJLINK% /out:minilua.exe minilua.obj
\r
22 @if errorlevel 1 goto :BAD
\r
23 if exist minilua.exe.manifest^
\r
24 %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
\r
26 @rem Check for 64 bit host compiler.
\r
28 @if not errorlevel 8 goto :FAIL
\r
30 @set DASMFLAGS=-D P64
\r
31 minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
\r
32 @if errorlevel 1 goto :BAD
\r
34 %LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI host\buildvm*.c
\r
35 @if errorlevel 1 goto :BAD
\r
36 %LJLINK% /out:buildvm.exe buildvm*.obj
\r
37 @if errorlevel 1 goto :BAD
\r
38 if exist buildvm.exe.manifest^
\r
39 %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
\r
41 buildvm -m elfasm -o lj_vm.s
\r
42 @if errorlevel 1 goto :BAD
\r
43 buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
\r
44 @if errorlevel 1 goto :BAD
\r
45 buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
\r
46 @if errorlevel 1 goto :BAD
\r
47 buildvm -m libdef -o lj_libdef.h %ALL_LIB%
\r
48 @if errorlevel 1 goto :BAD
\r
49 buildvm -m recdef -o lj_recdef.h %ALL_LIB%
\r
50 @if errorlevel 1 goto :BAD
\r
51 buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
\r
52 @if errorlevel 1 goto :BAD
\r
53 buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
\r
54 @if errorlevel 1 goto :BAD
\r
56 @rem ---- Cross compiler ----
\r
57 @set LJCOMPILE="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-clang" -c -Wall -DLUAJIT_DISABLE_FFI
\r
58 @set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus
\r
61 orbis-as -o lj_vm.o lj_vm.s
\r
63 @if "%1" neq "debug" goto :NODEBUG
\r
65 @set LJCOMPILE=%LJCOMPILE% -g -O0
\r
66 @set TARGETLIB=libluajitD.a
\r
69 @set LJCOMPILE=%LJCOMPILE% -O2
\r
70 @set TARGETLIB=libluajit.a
\r
73 @if "%1"=="amalg" goto :AMALG
\r
74 for %%f in (lj_*.c lib_*.c) do (
\r
76 @if errorlevel 1 goto :BAD
\r
79 %LJLIB% %TARGETLIB% lj_*.o lib_*.o
\r
80 @if errorlevel 1 goto :BAD
\r
83 %LJCOMPILE% ljamalg.c
\r
84 @if errorlevel 1 goto :BAD
\r
85 %LJLIB% %TARGETLIB% ljamalg.o lj_vm.o
\r
86 @if errorlevel 1 goto :BAD
\r
89 @del *.o *.obj *.manifest minilua.exe buildvm.exe
\r
91 @echo === Successfully built LuaJIT for PS4 ===
\r
96 @echo *******************************************************
\r
97 @echo *** Build FAILED -- Please check the error messages ***
\r
98 @echo *******************************************************
\a\r
101 @echo To run this script you must open a "Visual Studio .NET Command Prompt"
\r
102 @echo (64 bit host compiler). The PS4 Orbis SDK must be installed, too.
\r