forked from Pharap/CompilingLua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compile.bat
73 lines (54 loc) · 1.52 KB
/
Compile.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
::
:: Compiles Lua
::
::
:: Set up environment
::
:: Start local variable scope
@SETLOCAL
:: Locate 'vcvarsall.bat'
@IF NOT "%VS120COMNTOOLS%"=="" @SET VSVARSALL=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat
@IF NOT "%VS140COMNTOOLS%"=="" @SET VSVARSALL=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat
@IF "%VSVARSALL%"=="" @GOTO ENDSETUP
:: Identify the target architecture
@IF NOT "%PROCESSOR_ARCHITECTURE%"=="" (
@IF "%PROCESSOR_ARCHITECTURE%"=="x86" @SET ARCH=x86
@IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" @SET ARCH=amd64
)
@IF "%ARCH%"=="" @GOTO ENDSCRIPT
:: Call the setup script
@CALL "%VSVARSALL%" %ARCH%
@ECHO ON
:ENDSETUP
::
:: Process files
::
:: Move down into 'src'
@PUSHD src
:: Clean up files from previous builds
@IF EXIST *.o @DEL *.o
@IF EXIST *.obj @DEL *.obj
@IF EXIST *.dll @DEL *.dll
@IF EXIST *.exe @DEL *.exe
:: Compile all .c files into .obj
@CL /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
:: Rename two special files
@REN lua.obj lua.o
@REN luac.obj luac.o
:: Link up all the other .objs into a .lib and .dll file
@LINK /DLL /IMPLIB:lua.lib /OUT:lua.dll *.obj
:: Link lua into an .exe
@LINK /OUT:lua.exe lua.o lua.lib
:: Create a static .lib
@LIB /OUT:lua-static.lib *.obj
:: Link luac into an .exe
@LINK /OUT:luac.exe luac.o lua-static.lib
:: Move back up out of 'src'
@POPD
:: Copy the library and executable files out from 'src'
@COPY /Y src\lua.exe lua.exe
@COPY /Y src\luac.exe luac.exe
@COPY /Y src\lua.dll lua.dll
:ENDSCRIPT
:: End local variable scope
@ENDLOCAL