src/msvcbuild.bat - luajit-2.0-src

Global variables defined

Source code

  1. @rem Script to build LuaJIT with MSVC.
  2. @rem Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
  3. @rem
  4. @rem Either open a "Visual Studio .NET Command Prompt"
  5. @rem (Note that the Express Edition does not contain an x64 compiler)
  6. @rem -or-
  7. @rem Open a "Windows SDK Command Shell" and set the compiler environment:
  8. @rem     setenv /release /x86
  9. @rem   -or-
  10. @rem     setenv /release /x64
  11. @rem
  12. @rem Then cd to this directory and run this script.

  13. @if not defined INCLUDE goto :FAIL

  14. @setlocal
  15. @set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
  16. @set LJLINK=link /nologo
  17. @set LJMT=mt /nologo
  18. @set LJLIB=lib /nologo /nodefaultlib
  19. @set DASMDIR=..\dynasm
  20. @set DASM=%DASMDIR%\dynasm.lua
  21. @set LJDLLNAME=lua51.dll
  22. @set LJLIBNAME=lua51.lib
  23. @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

  24. %LJCOMPILE% host\minilua.c
  25. @if errorlevel 1 goto :BAD
  26. %LJLINK% /out:minilua.exe minilua.obj
  27. @if errorlevel 1 goto :BAD
  28. if exist minilua.exe.manifest^
  29.   %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe

  30. @set DASMFLAGS=-D WIN -D JIT -D FFI -D P64
  31. @set LJARCH=x64
  32. @minilua
  33. @if errorlevel 8 goto :X64
  34. @set DASMFLAGS=-D WIN -D JIT -D FFI
  35. @set LJARCH=x86
  36. @set LJCOMPILE=%LJCOMPILE% /arch:SSE2
  37. :X64
  38. minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
  39. @if errorlevel 1 goto :BAD

  40. %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
  41. @if errorlevel 1 goto :BAD
  42. %LJLINK% /out:buildvm.exe buildvm*.obj
  43. @if errorlevel 1 goto :BAD
  44. if exist buildvm.exe.manifest^
  45.   %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe

  46. buildvm -m peobj -o lj_vm.obj
  47. @if errorlevel 1 goto :BAD
  48. buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
  49. @if errorlevel 1 goto :BAD
  50. buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
  51. @if errorlevel 1 goto :BAD
  52. buildvm -m libdef -o lj_libdef.h %ALL_LIB%
  53. @if errorlevel 1 goto :BAD
  54. buildvm -m recdef -o lj_recdef.h %ALL_LIB%
  55. @if errorlevel 1 goto :BAD
  56. buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
  57. @if errorlevel 1 goto :BAD
  58. buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
  59. @if errorlevel 1 goto :BAD

  60. @if "%1" neq "debug" goto :NODEBUG
  61. @shift
  62. @set LJCOMPILE=%LJCOMPILE% /Zi
  63. @set LJLINK=%LJLINK% /debug
  64. :NODEBUG
  65. @if "%1"=="amalg" goto :AMALGDLL
  66. @if "%1"=="static" goto :STATIC
  67. %LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
  68. @if errorlevel 1 goto :BAD
  69. %LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
  70. @if errorlevel 1 goto :BAD
  71. @goto :MTDLL
  72. :STATIC
  73. %LJCOMPILE% lj_*.c lib_*.c
  74. @if errorlevel 1 goto :BAD
  75. %LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
  76. @if errorlevel 1 goto :BAD
  77. @goto :MTDLL
  78. :AMALGDLL
  79. %LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c
  80. @if errorlevel 1 goto :BAD
  81. %LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
  82. @if errorlevel 1 goto :BAD
  83. :MTDLL
  84. if exist %LJDLLNAME%.manifest^
  85.   %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2

  86. %LJCOMPILE% luajit.c
  87. @if errorlevel 1 goto :BAD
  88. %LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
  89. @if errorlevel 1 goto :BAD
  90. if exist luajit.exe.manifest^
  91.   %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe

  92. @del *.obj *.manifest minilua.exe buildvm.exe
  93. @echo.
  94. @echo === Successfully built LuaJIT for Windows/%LJARCH% ===

  95. @goto :END
  96. :BAD
  97. @echo.
  98. @echo *******************************************************
  99. @echo *** Build FAILED -- Please check the error messages ***
  100. @echo *******************************************************
  101. @goto :END
  102. :FAIL
  103. @echo You must open a "Visual Studio .NET Command Prompt" to run this script
  104. :END