-
Notifications
You must be signed in to change notification settings - Fork 98
/
make-vc.cmd
265 lines (216 loc) · 5.79 KB
/
make-vc.cmd
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
@REM
@REM make-vc.cmd to build Lanes on Visual C++ 2005/08
@REM
@REM Requires: Windows XP or later (cmd.exe)
@REM Visual C++ 2005/2008 (Express)
@REM LuaBinaries 5.1.3 or Lua for Windows 5.1.3
@REM
@setlocal
@set LUA_PATH=src\?.lua;tests\?.lua
@if not "%LUA51%"=="" (
@goto LUA_OK
)
@REM *** Lua for Windows >=5.1.3.14 (%LUA_DEV%) ***
@REM
@if exist "%LUA_DEV%\lua.exe" (
@set LUA51=%LUA_DEV%
@goto LUA_OK
)
@REM *** Lua for Windows (default path) ***
@REM
@if exist "%ProgramFiles%\Lua\5.1\lua.exe" (
@set LUA51=%ProgramFiles:~0,2%\Progra~1\Lua\5.1
@goto LUA_OK
)
@REM *** LuaBinaries (default path) ***
@REM
@if exist "%ProgramFiles%\Lua5.1\lua5.1.exe" (
@set LUA51=%ProgramFiles:~0,2%\Progra~1\Lua5.1
@goto LUA_OK
)
goto ERR_NOLUA
:LUA_OK
@REM ---
@REM %LUA_EXE% = %LUA51%\lua[5.1].exe
@REM %LUAC_EXE% = %LUA51%\luac[5.1].exe
@REM %LUA_LIB% = %LUA51%[\lib]
@REM ---
@set LUA_EXE=%LUA51%\lua5.1.exe
@if exist "%LUA_EXE%" goto LUA_EXE_OK
@set LUA_EXE=%LUA51%\lua.exe
@if exist "%LUA_EXE%" goto LUA_EXE_OK
@echo "Cannot find %LUA51%\lua[5.1].exe
@goto EXIT
:LUA_EXE_OK
@set LUAC_EXE=%LUA51%\luac5.1.exe
@if exist "%LUAC_EXE%" goto LUAC_EXE_OK
@set LUAC_EXE=%LUA51%\luac.exe
@if exist "%LUAC_EXE%" goto LUAC_EXE_OK
@echo "Cannot find %LUA51%\luac[5.1].exe
@goto EXIT
:LUAC_EXE_OK
@if "%1"=="" goto BUILD
@if "%1"=="clean" goto CLEAN
@if "%1"=="test" goto TEST
@if "%1"=="launchtest" goto LAUNCHTEST
@if "%1"=="perftest" goto PERFTEST
@if "%1"=="perftest-plain" goto PERFTEST-PLAIN
@if "%1"=="stress" goto STRESS
@if "%1"=="basic" goto BASIC
@if "%1"=="fifo" goto FIFO
@if "%1"=="keeper" goto KEEPER
@if "%1"=="atomic" goto ATOMIC
@if "%1"=="cyclic" goto CYCLIC
@if "%1"=="timer" goto TIMER
@if "%1"=="recursive" goto RECURSIVE
@if "%1"=="fibonacci" goto FIBONACCI
@if "%1"=="hangtest" goto HANGTEST
@if "%1"=="require" goto REQUIRE
@echo Unknown target: %1
@echo.
@goto EXIT
:BUILD
@REM LuaBinaries:
@REM The current build system does not show 'lanes/core.dll' to
@REM be dependent on more than 'KERNEL32.DLL'. Good.
@REM
@REM Lua for Windows:
@REM Depends on KERNEL32.DLL and LUA5.1.DLL. Good?
@set LUA_LIB=%LUA51%
@if exist "%LUA_LIB%\lua5.1.lib" (
@echo.
@echo ***
@echo *** Using Lua from: %LUA51%
@echo ***
@echo.
@goto LUA_LIB_OK
)
@set LUA_LIB=%LUA51%\lib
@if exist "%LUA_LIB%\lua5.1.lib" (
@echo.
@echo ***
@echo *** Using Lua from: %LUA51%
@echo ***
@echo.
@goto LUA_LIB_OK
)
@echo Cannot find %LUA51%\[lib\]lua5.1.lib
@goto EXIT
:LUA_LIB_OK
@if "%VCINSTALLDIR%"=="" goto ERR_NOVC
@REM
@REM Win32 (Visual C++ 2005/08 Express) build commands
@REM
@REM MS itself has warnings in stdlib.h (4255), winbase.h (4668), several (4820, 4826)
@REM 4054: "type cast from function pointer to data pointer"
@REM 4127: "conditional expression is constant"
@REM 4711: ".. selected for automatic inline expansion"
@REM
@set WARN=/Wall /wd4054 /wd4127 /wd4255 /wd4668 /wd4711 /wd4820 /wd4826
@REM /LDd: debug DLL
@REM /O2 /LD: release DLL
@REM
@set FLAGS=/O2 /LD
cl %WARN% %FLAGS% /I "%LUA51%\include" /Felanes\core.dll src\*.cpp "%LUA_LIB%\lua5.1.lib"
@REM cl %WARN% %FLAGS% /I "%LUA51%\include" /Felanes\core.dll src\*.cpp "%LUA_LIB%\lua5.1.lib" /link /NODEFAULTLIB:libcmt
@del lanes\core.lib
@del lanes\core.exp
@goto EXIT
:CLEAN
if exist lanes\*.dll del lanes\*.dll
if exist delme del delme
@goto EXIT
:TEST
@REM "make test" does not automatically build/update the dll. We're NOT a makefile. :!
@REM
"%LUA_EXE%" tests\basic.lua
@IF errorlevel 1 goto EXIT
"%LUA_EXE%" tests\fifo.lua
@IF errorlevel 1 goto EXIT
"%LUA_EXE%" tests\keeper.lua
@IF errorlevel 1 goto EXIT
"%LUA_EXE%" tests\fibonacci.lua
@IF errorlevel 1 goto EXIT
"%LUA_EXE%" tests\timer.lua
@IF errorlevel 1 goto EXIT
"%LUA_EXE%" tests\atomic.lua
@IF errorlevel 1 goto EXIT
"%LUA_EXE%" tests\cyclic.lua
@IF errorlevel 1 goto EXIT
"%LUA_EXE%" tests\recursive.lua
@IF errorlevel 1 goto EXIT
@goto EXIT
:BASIC
"%LUA_EXE%" tests\basic.lua
@goto EXIT
:FIFO
"%LUA_EXE%" tests\fifo.lua
@goto EXIT
:KEEPER
"%LUA_EXE%" tests\keeper.lua
@goto EXIT
:ATOMIC
"%LUA_EXE%" tests\atomic.lua
@goto EXIT
:CYCLIC
"%LUA_EXE%" tests\cyclic.lua
@goto EXIT
:TIMER
"%LUA_EXE%" tests\timer.lua
@goto EXIT
:RECURSIVE
"%LUA_EXE%" tests\recursive.lua
@goto EXIT
:FIBONACCI
"%LUA_EXE%" tests\fibonacci.lua
@goto EXIT
:HANGTEST
"%LUA_EXE%" tests\hangtest.lua
@goto EXIT
:REQUIRE
"%LUA_EXE%" -e "require'lanes'"
@goto EXIT
REM ---
REM NOTE: 'timeit' is a funny thing; it does _not_ work with quoted
REM long paths, but it _does_ work without the quotes. I have no idea,
REM how it knows the spaces in paths apart from spaces in between
REM arguments.
:LAUNCHTEST
timeit %LUA_EXE% tests\launchtest.lua %2 %3 %4
@goto EXIT
:PERFTEST
timeit %LUA_EXE% tests\perftest.lua %2 %3 %4
@goto EXIT
:PERFTEST-PLAIN
timeit %LUA_EXE% tests\perftest.lua --plain %2 %3 %4
@goto EXIT
:STRESS
"%LUA_EXE%" tests\test.lua
"%LUA_EXE%" tests\perftest.lua 100
"%LUA_EXE%" tests\perftest.lua 50 -prio=-1,0
"%LUA_EXE%" tests\perftest.lua 50 -prio=0,-1
"%LUA_EXE%" tests\perftest.lua 50 -prio=0,2
"%LUA_EXE%" tests\perftest.lua 50 -prio=2,0
@echo All seems okay!
@goto EXIT
REM ---
:ERR_NOLUA
@echo ***
@echo *** Please set LUA51 to point to either LuaBinaries or
@echo *** Lua for Windows directory.
@echo ***
@echo *** http://luabinaries.luaforge.net/download.html
@echo *** lua5_1_2_Win32_dll8_lib
@echo *** lua5_1_2_Win32_bin
@echo ***
@echo *** http://luaforge.net/frs/?group_id=377&release_id=1138
@echo ***
@echo.
@goto EXIT
:ERR_NOVC
@echo ***
@echo *** VCINSTALLDIR not defined; please run 'setup-vc'
@echo ***
@echo.
@goto EXIT
:EXIT