Skip to content

Commit a6e4c9e

Browse files
committed
fix luabind building for Windows????? also remove *.bat from .gitignore
1 parent eca9a8b commit a6e4c9e

File tree

10 files changed

+995
-1
lines changed

10 files changed

+995
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ luac.out
8181
*.i*86
8282
*.x86_64
8383
*.hex
84-
*.bat
8584
CortexCommand
8685
CortexCommand_debug
8786
CortexCommand.AppImage
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@rem This will be executed as a post-build job when building the static lib in VS.
2+
3+
@if not defined INCLUDE goto :FAIL
4+
5+
cd %~dp0\src\
6+
7+
@setlocal
8+
@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
9+
@set LJLINK=link /nologo
10+
@set LJMT=mt /nologo
11+
@set LJLIBNAMESTEM=..\_Bin\luajit-
12+
@set LJLIBNAMEEXT=.lib
13+
@set BUILDTYPE=release
14+
15+
@rem Call minilua to determine what the architecture is.
16+
@minilua
17+
@if errorlevel 8 (
18+
@if "%1"=="debug" (@set BUILDTYPE=debug)
19+
@if "%1"=="debug-release" (@set BUILDTYPE=debug-release)
20+
) else (
21+
@if "%1"=="" (@set BUILDTYPE=release-32)
22+
@if "%1"=="debug" (@set BUILDTYPE=debug-32)
23+
@if "%1"=="debug-release" (@set BUILDTYPE=debug-release-32)
24+
)
25+
26+
@set LJLIBNAME=%LJLIBNAMESTEM%%BUILDTYPE%%LJLIBNAMEEXT%
27+
28+
%LJCOMPILE% luajit.c
29+
@if errorlevel 1 goto :BAD
30+
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
31+
@if errorlevel 1 goto :BAD
32+
if exist luajit.exe.manifest^
33+
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
34+
35+
@del *.lib *.obj *.exp *.manifest *.exe
36+
@del host\buildvm_arch.h
37+
@del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
38+
39+
@echo.
40+
@echo === Successfully complete post-build job for Windows/%LJARCH% ===
41+
42+
@goto :END
43+
:BAD
44+
@echo.
45+
@echo *******************************************************
46+
@echo *** Build FAILED -- Please check the error messages ***
47+
@echo *******************************************************
48+
@goto :END
49+
:FAIL
50+
@echo You must open a "Visual Studio Command Prompt" to run this script
51+
:END
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
@rem This will be executed as a pre-build job when building the static lib in VS.
2+
3+
@if not defined INCLUDE goto :FAIL
4+
5+
cd %~dp0\src\
6+
7+
@setlocal
8+
@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
9+
@set LJLINK=link /nologo
10+
@set LJMT=mt /nologo
11+
@set DASMDIR=../dynasm
12+
@set DASM=%DASMDIR%\dynasm.lua
13+
@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
14+
15+
%LJCOMPILE% host\minilua.c
16+
@if errorlevel 1 goto :BAD
17+
%LJLINK% /out:minilua.exe minilua.obj
18+
@if errorlevel 1 goto :BAD
19+
if exist minilua.exe.manifest^
20+
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
21+
22+
@set LJARCH=x64
23+
@set DASC=vm_x64.dasc
24+
@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64
25+
26+
@rem Call minilua to determine what the architecture is.
27+
@minilua
28+
@if errorlevel 8 goto :X64
29+
@set LJARCH=x86
30+
@set DASC=vm_x86.dasc
31+
@set DASMFLAGS=-D WIN -D JIT -D FFI
32+
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
33+
:X64
34+
@if "%1" neq "nogc64" goto :GC64
35+
@shift
36+
@set DASC=vm_x86.dasc
37+
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
38+
:GC64
39+
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
40+
@if errorlevel 1 goto :BAD
41+
42+
%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
43+
@if errorlevel 1 goto :BAD
44+
%LJLINK% /out:buildvm.exe buildvm*.obj
45+
@if errorlevel 1 goto :BAD
46+
if exist buildvm.exe.manifest^
47+
%LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
48+
49+
buildvm -m peobj -o lj_vm.obj
50+
@if errorlevel 1 goto :BAD
51+
buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
52+
@if errorlevel 1 goto :BAD
53+
buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
54+
@if errorlevel 1 goto :BAD
55+
buildvm -m libdef -o lj_libdef.h %ALL_LIB%
56+
@if errorlevel 1 goto :BAD
57+
buildvm -m recdef -o lj_recdef.h %ALL_LIB%
58+
@if errorlevel 1 goto :BAD
59+
buildvm -m vmdef -o jit/vmdef.lua %ALL_LIB%
60+
@if errorlevel 1 goto :BAD
61+
buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
62+
@if errorlevel 1 goto :BAD
63+
64+
@echo.
65+
@echo === Successfully complete pre-build job for Windows/%LJARCH% ===
66+
67+
@goto :END
68+
:BAD
69+
@echo.
70+
@echo *******************************************************
71+
@echo *** Build FAILED -- Please check the error messages ***
72+
@echo *******************************************************
73+
@goto :END
74+
:FAIL
75+
@echo You must open a "Visual Studio Command Prompt" to run this script
76+
:END
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
@rem Script to build LuaJIT with MSVC.
2+
@rem Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
3+
@rem
4+
@rem Open a "Visual Studio Command Prompt" (either x86 or x64).
5+
@rem Then cd to this directory and run this script. Use the following
6+
@rem options (in order), if needed. The default is a dynamic release build.
7+
@rem
8+
@rem nogc64 disable LJ_GC64 mode for x64
9+
@rem debug emit debug symbols
10+
@rem amalg amalgamated build
11+
@rem static static linkage
12+
13+
@if not defined INCLUDE goto :FAIL
14+
15+
@setlocal
16+
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_ASSERT
17+
@set DEBUGCFLAGS=
18+
@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
19+
@set LJDYNBUILD=/DLUA_BUILD_AS_DLL /MD
20+
@set LJDYNBUILD_DEBUG=/DLUA_BUILD_AS_DLL /MDd
21+
@set LJCOMPILETARGET=/Zi
22+
@set LJLINKTYPE=/DEBUG /RELEASE
23+
@set LJLINKTYPE_DEBUG=/DEBUG
24+
@set LJLINKTARGET=/OPT:REF /OPT:ICF /INCREMENTAL:NO
25+
@set LJLINK=link /nologo
26+
@set LJMT=mt /nologo
27+
@set LJLIB=lib /nologo /nodefaultlib
28+
@set DASMDIR=..\dynasm
29+
@set DASM=%DASMDIR%\dynasm.lua
30+
@set DASC=vm_x64.dasc
31+
@set LJDLLNAME=lua51.dll
32+
@set LJLIBNAME=lua51.lib
33+
@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
34+
35+
@setlocal
36+
@call :SETHOSTVARS
37+
%LJCOMPILE% host\minilua.c
38+
@if errorlevel 1 goto :BAD
39+
%LJLINK% /out:minilua.exe minilua.obj
40+
@if errorlevel 1 goto :BAD
41+
if exist minilua.exe.manifest^
42+
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
43+
@endlocal
44+
45+
@set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU -D P64
46+
@set LJARCH=x64
47+
@minilua
48+
@if errorlevel 8 goto :NO32
49+
@set DASC=vm_x86.dasc
50+
@set DASMFLAGS=-D WIN -D JIT -D FFI -D ENDIAN_LE -D FPU
51+
@set LJARCH=x86
52+
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
53+
@goto :DA
54+
:NO32
55+
@if "%VSCMD_ARG_TGT_ARCH%" neq "arm64" goto :X64
56+
@set DASC=vm_arm64.dasc
57+
@set DASMTARGET=-D LUAJIT_TARGET=LUAJIT_ARCH_ARM64
58+
@set LJARCH=arm64
59+
@goto :DA
60+
:X64
61+
@if "%1" neq "nogc64" goto :DA
62+
@shift
63+
@set DASC=vm_x86.dasc
64+
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
65+
:DA
66+
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
67+
@if errorlevel 1 goto :BAD
68+
69+
if exist ..\.git ( git show -s --format=%%ct >luajit_relver.txt ) else ( type ..\.relver >luajit_relver.txt )
70+
minilua host\genversion.lua
71+
72+
@setlocal
73+
@call :SETHOSTVARS
74+
%LJCOMPILE% /I "." /I %DASMDIR% %DASMTARGET% host\buildvm*.c
75+
@if errorlevel 1 goto :BAD
76+
%LJLINK% /out:buildvm.exe buildvm*.obj
77+
@if errorlevel 1 goto :BAD
78+
if exist buildvm.exe.manifest^
79+
%LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
80+
@endlocal
81+
82+
buildvm -m peobj -o lj_vm.obj
83+
@if errorlevel 1 goto :BAD
84+
buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
85+
@if errorlevel 1 goto :BAD
86+
buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
87+
@if errorlevel 1 goto :BAD
88+
buildvm -m libdef -o lj_libdef.h %ALL_LIB%
89+
@if errorlevel 1 goto :BAD
90+
buildvm -m recdef -o lj_recdef.h %ALL_LIB%
91+
@if errorlevel 1 goto :BAD
92+
buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
93+
@if errorlevel 1 goto :BAD
94+
buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
95+
@if errorlevel 1 goto :BAD
96+
97+
@if "%1" neq "debug" goto :NODEBUG
98+
@shift
99+
@set LJCOMPILE=%LJCOMPILE% %DEBUGCFLAGS%
100+
@set LJDYNBUILD=%LJDYNBUILD_DEBUG%
101+
@set LJLINKTYPE=%LJLINKTYPE_DEBUG%
102+
:NODEBUG
103+
@set LJCOMPILE=%LJCOMPILE% %LJCOMPILETARGET%
104+
@set LJLINK=%LJLINK% %LJLINKTYPE% %LJLINKTARGET%
105+
@if "%1"=="amalg" goto :AMALGDLL
106+
@if "%1"=="static" goto :STATIC
107+
%LJCOMPILE% %LJDYNBUILD% lj_*.c lib_*.c
108+
@if errorlevel 1 goto :BAD
109+
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
110+
@if errorlevel 1 goto :BAD
111+
@goto :MTDLL
112+
:STATIC
113+
%LJCOMPILE% lj_*.c lib_*.c
114+
@if errorlevel 1 goto :BAD
115+
%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
116+
@if errorlevel 1 goto :BAD
117+
@goto :MTDLL
118+
:AMALGDLL
119+
%LJCOMPILE% %LJDYNBUILD% ljamalg.c
120+
@if errorlevel 1 goto :BAD
121+
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
122+
@if errorlevel 1 goto :BAD
123+
:MTDLL
124+
if exist %LJDLLNAME%.manifest^
125+
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
126+
127+
%LJCOMPILE% luajit.c
128+
@if errorlevel 1 goto :BAD
129+
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
130+
@if errorlevel 1 goto :BAD
131+
if exist luajit.exe.manifest^
132+
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
133+
134+
@del *.obj *.manifest minilua.exe buildvm.exe
135+
@del host\buildvm_arch.h
136+
@del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
137+
@echo.
138+
@echo === Successfully built LuaJIT for Windows/%LJARCH% ===
139+
140+
@goto :END
141+
:SETHOSTVARS
142+
@if "%VSCMD_ARG_HOST_ARCH%_%VSCMD_ARG_TGT_ARCH%" equ "x64_arm64" (
143+
call "%VSINSTALLDIR%Common7\Tools\VsDevCmd.bat" -arch=%VSCMD_ARG_HOST_ARCH% -no_logo
144+
echo on
145+
)
146+
@goto :END
147+
:BAD
148+
@echo.
149+
@echo *******************************************************
150+
@echo *** Build FAILED -- Please check the error messages ***
151+
@echo *******************************************************
152+
@goto :END
153+
:FAIL
154+
@echo You must open a "Visual Studio Command Prompt" to run this script
155+
:END

0 commit comments

Comments
 (0)