src/psvitabuild.bat - luajit-2.0-src

Global variables defined

Source code

  1. @rem Script to build LuaJIT with the PS Vita SDK.
  2. @rem Donated to the public domain.
  3. @rem
  4. @rem Open a "Visual Studio .NET Command Prompt" (32 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_PSP2_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 32 bit host compiler.
  23. @minilua
  24. @if errorlevel 8 goto :FAIL

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

  28. %LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_ARM -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLJ_TARGET_PSVITA=1 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_PSP2_SDK_DIR%\host_tools\build\bin\psp2snc" -c -w -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC
  50. @set LJLIB="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2ld32" -r --output=
  51. @set INCLUDE=""

  52. "%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2as" -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. %LJCOMPILE% ljamalg.c
  64. @if errorlevel 1 goto :BAD
  65. %LJLIB%%TARGETLIB% ljamalg.o lj_vm.o
  66. @if errorlevel 1 goto :BAD

  67. @del *.o *.obj *.manifest minilua.exe buildvm.exe
  68. @echo.
  69. @echo === Successfully built LuaJIT for PS Vita ===

  70. @goto :END
  71. :BAD
  72. @echo.
  73. @echo *******************************************************
  74. @echo *** Build FAILED -- Please check the error messages ***
  75. @echo *******************************************************
  76. @goto :END
  77. :FAIL
  78. @echo To run this script you must open a "Visual Studio .NET Command Prompt"
  79. @echo (32 bit host compiler). The PS Vita SDK must be installed, too.
  80. :END