vcpkg/ports/luajit/004-fix-build-path-and-crt-linkage.patch

140 lines
5.4 KiB
Diff
Raw Normal View History

diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index d323d8d..6e61150 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -15,19 +15,20 @@
@setlocal
@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
+@set SOURCEDIR=%1
+@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline /I%SOURCEDIR%
@set LJLINK=link /nologo
@set LJMT=mt /nologo
@set LJLIB=lib /nologo /nodefaultlib
-@set DASMDIR=..\dynasm
+@set DASMDIR=%SOURCEDIR%\..\dynasm
@set DASM=%DASMDIR%\dynasm.lua
-@set DASC=vm_x64.dasc
+@set DASC=%SOURCEDIR%\vm_x64.dasc
@set LJDLLNAME=lua51.dll
@set LJLIBNAME=lua51.lib
@set BUILDTYPE=release
-@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
+@set ALL_LIB=%SOURCEDIR%\lib_base.c %SOURCEDIR%\lib_math.c %SOURCEDIR%\lib_bit.c %SOURCEDIR%\lib_string.c %SOURCEDIR%\lib_table.c %SOURCEDIR%\lib_io.c %SOURCEDIR%\lib_os.c %SOURCEDIR%\lib_package.c %SOURCEDIR%\lib_debug.c %SOURCEDIR%\lib_jit.c %SOURCEDIR%\lib_ffi.c %SOURCEDIR%\lib_buffer.c
-%LJCOMPILE% host\minilua.c
+%LJCOMPILE% %SOURCEDIR%\host\minilua.c /Fdminilua.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD
@@ -38,20 +39,20 @@ if exist minilua.exe.manifest^
@set LJARCH=x64
@minilua
@if errorlevel 8 goto :X64
-@set DASC=vm_x86.dasc
+@set DASC=%SOURCEDIR%\vm_x86.dasc
@set DASMFLAGS=-D WIN -D JIT -D FFI
@set LJARCH=x86
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
:X64
@if "%1" neq "nogc64" goto :GC64
@shift
-@set DASC=vm_x86.dasc
+@set DASC=%SOURCEDIR%\vm_x86.dasc
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
:GC64
-minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
+minilua %DASM% -LN %DASMFLAGS% -o %SOURCEDIR%\host\buildvm_arch.h %DASC%
@if errorlevel 1 goto :BAD
-%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
+%LJCOMPILE% /I "." /I %DASMDIR% %SOURCEDIR%\host\buildvm*.c /Fdbuildvm.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
@@ -60,41 +61,44 @@ if exist buildvm.exe.manifest^
buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD
-buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
+buildvm -m bcdef -o %SOURCEDIR%\lj_bcdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
+buildvm -m ffdef -o %SOURCEDIR%\lj_ffdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m libdef -o lj_libdef.h %ALL_LIB%
+buildvm -m libdef -o %SOURCEDIR%\lj_libdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m recdef -o lj_recdef.h %ALL_LIB%
+buildvm -m recdef -o %SOURCEDIR%\lj_recdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
+buildvm -m vmdef -o %SOURCEDIR%\jit\vmdef.lua %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
+buildvm -m folddef -o %SOURCEDIR%\lj_folddef.h %SOURCEDIR%\lj_opt_fold.c
@if errorlevel 1 goto :BAD
-@if "%1" neq "debug" goto :NODEBUG
+@if "%2"=="static" set CRT_LINKAGE=/MT
+@if "%2"=="dynamic" set CRT_LINKAGE=/MD
+@set LJLINK=%LJLINK% /debug
+@if "%3" neq "debug" goto :NODEBUG
@shift
@set BUILDTYPE=debug
@set LJCOMPILE=%LJCOMPILE% /Zi %DEBUGCFLAGS%
-@set LJLINK=%LJLINK% /opt:ref /opt:icf /incremental:no
+@set CRT_LINKAGE=%CRT_LINKAGE%d
:NODEBUG
@set LJLINK=%LJLINK% /%BUILDTYPE%
-@if "%1"=="amalg" goto :AMALGDLL
-@if "%1"=="static" goto :STATIC
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+@if "%3"=="amalg" goto :AMALGDLL
+@if "%3"=="static" goto :STATIC
+%LJCOMPILE% %CRT_LINKAGE% /DLUA_BUILD_AS_DLL %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:STATIC
-%LJCOMPILE% lj_*.c lib_*.c
+%LJCOMPILE% %CRT_LINKAGE% %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:AMALGDLL
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL %SOURCEDIR%\ljamalg.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
@@ -102,7 +106,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
-%LJCOMPILE% luajit.c
+%LJCOMPILE% %CRT_LINKAGE% %SOURCEDIR%\luajit.c /Fdluajit.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
@if errorlevel 1 goto :BAD
@@ -110,8 +114,8 @@ 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
+@del %SOURCEDIR%\host\buildvm_arch.h
+@del %SOURCEDIR%\lj_bcdef.h %SOURCEDIR%\lj_ffdef.h %SOURCEDIR%\lj_libdef.h %SOURCEDIR%\lj_recdef.h %SOURCEDIR%\lj_folddef.h
@echo.
@echo === Successfully built LuaJIT for Windows/%LJARCH% ===
@@ -124,4 +128,5 @@ if exist luajit.exe.manifest^
@goto :END
:FAIL
@echo You must open a "Visual Studio Command Prompt" to run this script
+exit 1
:END