src/ps4build.bat - luajit-2.0-src

Global variables defined

Source code

  1. @rem Script to build LuaJIT with the PS4 SDK.
  2. @rem Donated to the public domain.
  3. @rem
  4. @rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler)
  5. @rem Then cd to this directory and run this script.

  6. @if not defined INCLUDE goto :FAIL
  7. @if not defined SCE_ORBIS_SDK_DIR goto :FAIL

  8. @setlocal
  9. @rem ---- Host compiler ----
  10. @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
  11. @set LJLINK=link /nologo
  12. @set LJMT=mt /nologo
  13. @set DASMDIR=..\dynasm
  14. @set DASM=%DASMDIR%\dynasm.lua
  15. @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

  16. %LJCOMPILE% host\minilua.c
  17. @if errorlevel 1 goto :BAD
  18. %LJLINK% /out:minilua.exe minilua.obj
  19. @if errorlevel 1 goto :BAD
  20. if exist minilua.exe.manifest^
  21.   %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe

  22. @rem Check for 64 bit host compiler.
  23. @minilua
  24. @if not errorlevel 8 goto :FAIL

  25. @set DASMFLAGS=-D P64
  26. minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
  27. @if errorlevel 1 goto :BAD

  28. %LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI host\buildvm*.c
  29. @if errorlevel 1 goto :BAD
  30. %LJLINK% /out:buildvm.exe buildvm*.obj
  31. @if errorlevel 1 goto :BAD
  32. if exist buildvm.exe.manifest^
  33.   %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe

  34. buildvm -m elfasm -o lj_vm.s
  35. @if errorlevel 1 goto :BAD
  36. buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
  37. @if errorlevel 1 goto :BAD
  38. buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
  39. @if errorlevel 1 goto :BAD
  40. buildvm -m libdef -o lj_libdef.h %ALL_LIB%
  41. @if errorlevel 1 goto :BAD
  42. buildvm -m recdef -o lj_recdef.h %ALL_LIB%
  43. @if errorlevel 1 goto :BAD
  44. buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
  45. @if errorlevel 1 goto :BAD
  46. buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
  47. @if errorlevel 1 goto :BAD

  48. @rem ---- Cross compiler ----
  49. @set LJCOMPILE="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-clang" -c -Wall -DLUAJIT_DISABLE_FFI
  50. @set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus
  51. @set INCLUDE=""

  52. orbis-as -o lj_vm.o lj_vm.s

  53. @if "%1" neq "debug" goto :NODEBUG
  54. @shift
  55. @set LJCOMPILE=%LJCOMPILE% -g -O0
  56. @set TARGETLIB=libluajitD.a
  57. goto :BUILD
  58. :NODEBUG
  59. @set LJCOMPILE=%LJCOMPILE% -O2
  60. @set TARGETLIB=libluajit.a
  61. :BUILD
  62. del %TARGETLIB%
  63. @if "%1"=="amalg" goto :AMALG
  64. for %%f in (lj_*.c lib_*.c) do (
  65.   %LJCOMPILE% %%f
  66.   @if errorlevel 1 goto :BAD
  67. )

  68. %LJLIB% %TARGETLIB% lj_*.o lib_*.o
  69. @if errorlevel 1 goto :BAD
  70. @goto :NOAMALG
  71. :AMALG
  72. %LJCOMPILE% ljamalg.c
  73. @if errorlevel 1 goto :BAD
  74. %LJLIB% %TARGETLIB% ljamalg.o lj_vm.o
  75. @if errorlevel 1 goto :BAD
  76. :NOAMALG

  77. @del *.o *.obj *.manifest minilua.exe buildvm.exe
  78. @echo.
  79. @echo === Successfully built LuaJIT for PS4 ===

  80. @goto :END
  81. :BAD
  82. @echo.
  83. @echo *******************************************************
  84. @echo *** Build FAILED -- Please check the error messages ***
  85. @echo *******************************************************
  86. @goto :END
  87. :FAIL
  88. @echo To run this script you must open a "Visual Studio .NET Command Prompt"
  89. @echo (64 bit host compiler). The PS4 Orbis SDK must be installed, too.
  90. :END