Skip to content

Commit b3b35ea

Browse files
authored
Improve Compile.bat
This script should hopefully now play nicely with 64-bit configurations.
1 parent 3407010 commit b3b35ea

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

Compile.bat

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,72 @@
22
:: Compiles Lua
33
::
44

5-
@REM Move down into src
5+
::
6+
:: Set up environment
7+
::
8+
9+
:: Start local variable scope
10+
@SETLOCAL
11+
12+
:: Locate 'vcvarsall.bat'
13+
@IF NOT "%VS120COMNTOOLS%"=="" @SET VSVARSALL=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat
14+
@IF NOT "%VS140COMNTOOLS%"=="" @SET VSVARSALL=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat
15+
@IF "%VSVARSALL%"=="" @GOTO ENDSETUP
16+
17+
:: Identify the target architecture
18+
@IF NOT "%PROCESSOR_ARCHITECTURE%"=="" (
19+
@IF "%PROCESSOR_ARCHITECTURE%"=="x86" @SET ARCH=x86
20+
@IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" @SET ARCH=amd64
21+
)
22+
@IF "%ARCH%"=="" @GOTO ENDSCRIPT
23+
24+
:: Call the setup script
25+
@CALL "%VSVARSALL%" %ARCH%
26+
@ECHO ON
27+
28+
:ENDSETUP
29+
30+
::
31+
:: Process files
32+
::
33+
34+
:: Move down into 'src'
635
@PUSHD src
736

8-
@REM Clean up files from previous builds
9-
@DEL *.obj *.o *.dll *.exe
37+
:: Clean up files from previous builds
38+
@IF EXIST *.o @DEL *.o
39+
@IF EXIST *.obj @DEL *.obj
40+
@IF EXIST *.dll @DEL *.dll
41+
@IF EXIST *.exe @DEL *.exe
1042

11-
@REM Compile all .c files into .obj
43+
:: Compile all .c files into .obj
1244
@CL /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
1345

14-
@REM Rename two special files
46+
:: Rename two special files
1547
@REN lua.obj lua.o
1648
@REN luac.obj luac.o
1749

18-
@REM Link up all the other .objs into a .lib and .dll file
50+
:: Link up all the other .objs into a .lib and .dll file
1951
@LINK /DLL /IMPLIB:lua.lib /OUT:lua.dll *.obj
2052

21-
@REM Link lua into an .exe
53+
:: Link lua into an .exe
2254
@LINK /OUT:lua.exe lua.o lua.lib
2355

24-
@REM Create a static .lib
56+
:: Create a static .lib
2557
@LIB /OUT:lua-static.lib *.obj
2658

27-
@REM Link luac into an .exe
59+
:: Link luac into an .exe
2860
@LINK /OUT:luac.exe luac.o lua-static.lib
2961

62+
:: Move back up out of 'src'
3063
@POPD
3164

32-
@REM Copy the library and executable files out from 'src'
65+
:: Copy the library and executable files out from 'src'
3366
@COPY /Y src\lua.exe lua.exe
3467
@COPY /Y src\luac.exe luac.exe
35-
@COPY /Y src\lua.dll lua.dll
68+
@COPY /Y src\lua.dll lua.dll
69+
70+
:ENDSCRIPT
71+
72+
:: End local variable scope
73+
@ENDLOCAL

0 commit comments

Comments
 (0)