mikepaul-LuaJIT/src/msvcbuild.bat

137 lines
4.4 KiB
Batchfile
Raw Normal View History

2009-12-08 18:46:35 +00:00
@rem Script to build LuaJIT with MSVC.
2023-08-20 19:25:30 +00:00
@rem Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
2009-12-08 18:46:35 +00:00
@rem
2019-12-08 17:52:41 +00:00
@rem Open a "Visual Studio Command Prompt" (either x86 or x64).
@rem Then cd to this directory and run this script. Use the following
@rem options (in order), if needed. The default is a dynamic release build.
@rem
2019-12-08 20:21:30 +00:00
@rem nogc64 disable LJ_GC64 mode for x64
2019-12-08 17:52:41 +00:00
@rem debug emit debug symbols
@rem amalg amalgamated build
@rem static static linkage
2009-12-08 18:46:35 +00:00
@if not defined INCLUDE goto :FAIL
@setlocal
2019-12-08 17:52:41 +00:00
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK
@set DEBUGCFLAGS=
@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
2009-12-08 18:46:35 +00:00
@set LJLINK=link /nologo
@set LJMT=mt /nologo
2013-11-21 12:47:07 +00:00
@set LJLIB=lib /nologo /nodefaultlib
2009-12-08 18:46:35 +00:00
@set DASMDIR=..\dynasm
@set DASM=%DASMDIR%\dynasm.lua
2019-12-08 20:21:30 +00:00
@set DASC=vm_x64.dasc
@set LJDLLNAME=lua51.dll
@set LJLIBNAME=lua51.lib
2019-12-08 17:52:41 +00:00
@set BUILDTYPE=release
2021-03-26 17:14:59 +00:00
@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 lib_buffer.c
2009-12-08 18:46:35 +00:00
%LJCOMPILE% host\minilua.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD
if exist minilua.exe.manifest^
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
2009-12-08 18:46:35 +00:00
@set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU -D P64
@set LJARCH=x64
@minilua
@if errorlevel 8 goto :NO32
2019-12-08 20:21:30 +00:00
@set DASC=vm_x86.dasc
@set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU
@set LJARCH=x86
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
@goto :DA
:NO32
@if "%VSCMD_ARG_TGT_ARCH%" neq "arm64" goto :X64
@set DASC=vm_arm64.dasc
@set LJARCH=arm64
@goto :DA
:X64
@if "%1" neq "nogc64" goto :DA
@shift
2019-12-08 20:21:30 +00:00
@set DASC=vm_x86.dasc
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
:DA
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
@if errorlevel 1 goto :BAD
if exist ..\.git ( git show -s --format=%%ct >luajit_relver.txt ) else ( type ..\.relver >luajit_relver.txt )
minilua host\genversion.lua
%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
if exist buildvm.exe.manifest^
%LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD
buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
buildvm -m libdef -o lj_libdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
buildvm -m recdef -o lj_recdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
2012-06-08 18:54:47 +00:00
buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
@if "%1" neq "debug" goto :NODEBUG
@shift
2019-12-08 17:52:41 +00:00
@set BUILDTYPE=debug
@set LJCOMPILE=%LJCOMPILE% /Zi %DEBUGCFLAGS%
2019-12-08 17:58:50 +00:00
@set LJLINK=%LJLINK% /opt:ref /opt:icf /incremental:no
:NODEBUG
2019-12-08 17:52:41 +00:00
@set LJLINK=%LJLINK% /%BUILDTYPE%
2009-12-08 18:46:35 +00:00
@if "%1"=="amalg" goto :AMALGDLL
2010-03-15 17:50:59 +00:00
@if "%1"=="static" goto :STATIC
2013-11-21 12:47:07 +00:00
%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
@goto :MTDLL
2010-03-15 17:50:59 +00:00
:STATIC
2013-11-21 12:47:07 +00:00
%LJCOMPILE% lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
2010-03-15 17:50:59 +00:00
@goto :MTDLL
2009-12-08 18:46:35 +00:00
:AMALGDLL
2013-11-21 12:47:07 +00:00
%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
:MTDLL
if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
2009-12-08 18:46:35 +00:00
%LJCOMPILE% luajit.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
@if errorlevel 1 goto :BAD
2009-12-08 18:46:35 +00:00
if exist luajit.exe.manifest^
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
@del *.obj *.manifest minilua.exe buildvm.exe
@del host\buildvm_arch.h
@del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
@echo.
@echo === Successfully built LuaJIT for Windows/%LJARCH% ===
2009-12-08 18:46:35 +00:00
@goto :END
:BAD
@echo.
@echo *******************************************************
@echo *** Build FAILED -- Please check the error messages ***
@echo *******************************************************
2009-12-08 18:46:35 +00:00
@goto :END
:FAIL
2019-12-08 17:52:41 +00:00
@echo You must open a "Visual Studio Command Prompt" to run this script
2009-12-08 18:46:35 +00:00
:END