1@rem Script to build LuaJIT with MSVC. 2@rem Copyright (C) 2005-2017 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 14@if not defined INCLUDE goto :FAIL 15 16@setlocal 17@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline 18@set LJLINK=link /nologo 19@set LJMT=mt /nologo 20@set LJLIB=lib /nologo /nodefaultlib 21@set DASMDIR=..\dynasm 22@set DASM=%DASMDIR%\dynasm.lua 23@set DASC=vm_x86.dasc 24@set LJDLLNAME=lua51.dll 25@set LJLIBNAME=lua51.lib 26@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 27 28%LJCOMPILE% host\minilua.c 29@if errorlevel 1 goto :BAD 30%LJLINK% /out:minilua.exe minilua.obj 31@if errorlevel 1 goto :BAD 32if exist minilua.exe.manifest^ 33 %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe 34 35@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 36@set LJARCH=x64 37@minilua 38@if errorlevel 8 goto :X64 39@set DASMFLAGS=-D WIN -D JIT -D FFI 40@set LJARCH=x86 41@set LJCOMPILE=%LJCOMPILE% /arch:SSE2 42:X64 43@if "%1" neq "gc64" goto :NOGC64 44@shift 45@set DASC=vm_x64.dasc 46@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_ENABLE_GC64 47:NOGC64 48minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC% 49@if errorlevel 1 goto :BAD 50 51%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c 52@if errorlevel 1 goto :BAD 53%LJLINK% /out:buildvm.exe buildvm*.obj 54@if errorlevel 1 goto :BAD 55if exist buildvm.exe.manifest^ 56 %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe 57 58buildvm -m peobj -o lj_vm.obj 59@if errorlevel 1 goto :BAD 60buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% 61@if errorlevel 1 goto :BAD 62buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% 63@if errorlevel 1 goto :BAD 64buildvm -m libdef -o lj_libdef.h %ALL_LIB% 65@if errorlevel 1 goto :BAD 66buildvm -m recdef -o lj_recdef.h %ALL_LIB% 67@if errorlevel 1 goto :BAD 68buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% 69@if errorlevel 1 goto :BAD 70buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 71@if errorlevel 1 goto :BAD 72 73@if "%1" neq "debug" goto :NODEBUG 74@shift 75@set LJCOMPILE=%LJCOMPILE% /Zi 76@set LJLINK=%LJLINK% /debug /opt:ref /opt:icf /incremental:no 77:NODEBUG 78@if "%1"=="amalg" goto :AMALGDLL 79@if "%1"=="static" goto :STATIC 80%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c 81@if errorlevel 1 goto :BAD 82%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj 83@if errorlevel 1 goto :BAD 84@goto :MTDLL 85:STATIC 86%LJCOMPILE% lj_*.c lib_*.c 87@if errorlevel 1 goto :BAD 88%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj 89@if errorlevel 1 goto :BAD 90@goto :MTDLL 91:AMALGDLL 92%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c 93@if errorlevel 1 goto :BAD 94%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj 95@if errorlevel 1 goto :BAD 96:MTDLL 97if exist %LJDLLNAME%.manifest^ 98 %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2 99 100%LJCOMPILE% luajit.c 101@if errorlevel 1 goto :BAD 102%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME% 103@if errorlevel 1 goto :BAD 104if exist luajit.exe.manifest^ 105 %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe 106 107@del *.obj *.manifest minilua.exe buildvm.exe 108@del host\buildvm_arch.h 109@del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h 110@echo. 111@echo === Successfully built LuaJIT for Windows/%LJARCH% === 112 113@goto :END 114:BAD 115@echo. 116@echo ******************************************************* 117@echo *** Build FAILED -- Please check the error messages *** 118@echo ******************************************************* 119@goto :END 120:FAIL 121@echo You must open a "Visual Studio .NET Command Prompt" to run this script 122:END 123