-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
compile_bcc.bat
291 lines (226 loc) · 7.8 KB
/
compile_bcc.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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
@echo off
rem
rem $Id: compile_bcc.bat $
rem
:COMPILE_BCC
if "%HG_ROOT%" == "" goto ERROR1
if "%HG_HRB%" == "" goto ERROR1
if "%HG_BCC%" == "" goto ERROR1
if "%LIB_GUI%" == "" goto ERROR1
if "%LIB_HRB%" == "" goto ERROR1
if "%BIN_HRB%" == "" goto ERROR1
:CHECK
if "%1" == "" goto ERROR2
set HG_FILE=%1
if exist %1.prg goto CLEAN_EXE
set HG_FILE=%~n1
if /I "%~x1" == ".PRG" goto CLEAN_EXE
set HG_FILE=
goto ERROR3
:CLEAN_EXE
if exist %HG_FILE%.exe del %HG_FILE%.exe
if exist %HG_FILE%.exe goto ERROR4
if exist _temp.rc del _temp.rc
if exist _temp.rc goto ERROR5
if exist oohglog.txt del oohglog.txt
:PARSE_SWITCHES
set HG_C_FLAGS=
set HG_C_LIBS=
set HG_C_LOG=1^>nul
set HG_COMP_TYPE=STD
set HG_DEFINES=
set HG_EXTRA=
set HG_FILE=%HG_FILE%
set HG_NO_RUN=FALSE
set HG_PRG_LOG=
set HG_SEARCH=
set HG_USE_RC=TRUE
set HG_W_LIBS=
:LOOP_START
if "%2" == "" goto LOOP_END
if /I "%2" == "/C" goto SW_CONSOLE
if /I "%2" == "/D" goto SW_DEBUG
if /I "%2" == "/GTWIN" goto SW_CONSOLE
if /I "%2" == "/L" goto SW_USELOG
if /I "%2" == "/LOG" goto SW_USELOG
if /I "%2" == "/NORC" goto SW_NORC
if /I "%2" == "/NR" goto SW_NORUN
if /I "%2" == "/P" goto SW_PPO
if /I "%2" == "/S" goto SW_SILENT
if /I "%2" == "/SL" goto SW_SILENT
if /I "%2" == "/V" goto SW_VERBOSE
if /I "%2" == "/W3" goto SW_W3
if /I "%2" == "-C" goto SW_CONSOLE
if /I "%2" == "-D" goto SW_DEBUG
if /I "%2" == "-GTWIN" goto SW_CONSOLE
if /I "%2" == "-L" goto SW_USELOG
if /I "%2" == "-LOG" goto SW_USELOG
if /I "%2" == "-NORC" goto SW_NORC
if /I "%2" == "-NR" goto SW_NORUN
if /I "%2" == "-P" goto SW_PPO
if /I "%2" == "-S" goto SW_SILENT
if /I "%2" == "-SL" goto SW_SILENT
if /I "%2" == "-V" goto SW_VERBOSE
if /I "%2" == "-W3" goto SW_W3
set HG_EXTRA=%HG_EXTRA% %2
shift
goto LOOP_START
:SW_DEBUG
set HG_COMP_TYPE=DEBUG
set HG_DEFINES=-D_OOHG_CONSOLEMODE_
shift
goto LOOP_START
:SW_CONSOLE
set HG_COMP_TYPE=CONSOLE
set HG_DEFINES=-D_OOHG_CONSOLEMODE_
shift
goto LOOP_START
:SW_NORC
set HG_USE_RC=FALSE
shift
goto LOOP_START
:SW_PPO
set HG_EXTRA=%HG_EXTRA% -p
shift
goto LOOP_START
:SW_W3
set HG_EXTRA=%HG_EXTRA% -w3
shift
goto LOOP_START
:SW_NORUN
set HG_NO_RUN=TRUE
shift
goto LOOP_START
:SW_USELOG
set HG_PRG_LOG=-q 1^>^>oohglog.txt 2^>^>^&1
set HG_C_LOG=1^>^>oohglog.txt 2^>^>^&1
shift
goto LOOP_START
:SW_SILENT
set HG_PRG_LOG=1^>nul 2^>^&1
set HG_C_LOG=1^>nul 2^>^&1
set HG_C_FLAGS=-q
shift
goto LOOP_START
:SW_VERBOSE
set HG_PRG_LOG=
set HG_C_LOG=
shift
goto LOOP_START
:LOOP_END
set HG_SEARCH=-i%HG_ROOT%\resources;%HG_ROOT%\include;%HG_BCC%\include;
if not "%HG_INC_RC%" == "" set HG_SEARCH=%HG_SEARCH%;%HG_INC_RC%
echo #define oohgpath %HG_ROOT%\RESOURCES > _oohg_resconfig.h
if "%HG_USE_RC%" == "FALSE" goto WITHOUT_HG_RC
echo. > %HG_ROOT%\resources\filler
if exist %HG_FILE%.rc copy /b %HG_FILE%.rc + %HG_ROOT%\resources\filler + %HG_ROOT%\resources\oohg_bcc.rc _temp.rc %HG_C_LOG%
if not exist %HG_FILE%.rc copy /b %HG_ROOT%\resources\oohg_bcc.rc _temp.rc %HG_C_LOG%
if not exist _temp.rc echo COMPILE ERROR: Error creating file _temp.rc !!!
if not exist _temp.rc goto CLEANUP
"%HG_BCC%\bin\brc32.exe" -r %HG_SEARCH% _temp.rc %HG_C_LOG%
if errorlevel 1 goto CLEANUP
goto COMPILE_PRG
:WITHOUT_HG_RC
if not exist %HG_FILE%.rc goto COMPILE_PRG
copy /b %HG_FILE%.rc _temp.rc %HG_C_LOG%
if not exist _temp.rc echo COMPILE ERROR: Error creating file _temp.rc !!!
if not exist _temp.rc goto CLEANUP
%HG_BCC%\bin\brc32.exe -r %HG_SEARCH% _temp.rc %HG_C_LOG%
if errorlevel 1 goto CLEANUP
:COMPILE_PRG
if "%HG_COMP_TYPE%" == "DEBUG" echo OPTIONS NORUNATSTARTUP > init.cld
if "%HG_COMP_TYPE%" == "DEBUG" set %HG_EXTRA%=-b %HG_EXTRA%
set HG_SEARCH=-i%HG_HRB%\include;%HG_ROOT%\include;.
if not "%HG_INC_HRB%" == "" set HG_SEARCH=%HG_SEARCH%;%HG_INC_HRB%
%HG_HRB%\%BIN_HRB%\harbour %HG_FILE%.prg -n %HG_EXTRA% %HG_SEARCH% %HG_DEFINES% %HG_PRG_LOG%
if errorlevel 1 set HG_NO_RUN=TRUE
if errorlevel 1 goto CLEANUP
:COMPILE_C
set HG_SEARCH=-I%HG_HRB%\include;%HG_BCC%\include;%HG_ROOT%\include;%HG_INC_CCOMP%
%HG_BCC%\bin\bcc32 -c -O2 -tW -tWM -M -w %HG_SEARCH% -L%HG_BCC%\lib; %HG_FILE%.c %HG_C_LOG%
if errorlevel 1 set HG_NO_RUN=TRUE
if errorlevel 1 echo Error compiling %HG_FILE%.c! %HG_PRG_LOG%
if errorlevel 1 goto CLEANUP
if "%HG_FLAVOR%" == "HARBOUR" goto LIBS_HARBOUR
:LIBS_XHARBOUR
set HG_C_LIBS=gtgui gtwin
if "%HG_COMP_TYPE%" == "DEBUG" set HG_C_LIBS=gtwin gtgui debug
if "%HG_COMP_TYPE%" == "CONSOLE" set HG_C_LIBS=gtwin gtgui
set HG_C_LIBS=%HG_C_LIBS% rtl vmmt rdd codepage common ct dbfcdx dbffpt
set HG_C_LIBS=%HG_C_LIBS% dbfntx hbsix hsx lang macro pp %HG_ADDLIBS%
set HG_C_LIBS=%HG_C_LIBS% filemem libmisc hbmzip tip hbzebra
set HG_C_LIBS=%HG_C_LIBS% hbzip rddsql sevenzip
set HG_C_LIBS=%HG_C_LIBS% hbhpdf libharu png
goto LIBS_WINDOWS
:LIBS_HARBOUR
set HG_C_LIBS=gtgui gtwin
if "%HG_COMP_TYPE%" == "DEBUG" set HG_C_LIBS=gtwin gtgui hbdebug
if "%HG_COMP_TYPE%" == "CONSOLE" set HG_C_LIBS=gtwin gtgui
set HG_C_LIBS=%HG_C_LIBS% hbrtl hbvmmt hbrdd hbcpage hbcommon hbct rddcdx rddfpt
set HG_C_LIBS=%HG_C_LIBS% rddntx hbsix hbhsx hblang hbmacro hbpp %HG_ADDLIBS%
set HG_C_LIBS=%HG_C_LIBS% hbmemio hbmisc hbmzip hbtip hbzebra
set HG_C_LIBS=%HG_C_LIBS% rddsql hbziparc minizip
rem hbhpdf must precede hbwin png xhb
set HG_C_LIBS=%HG_C_LIBS% hbhpdf hpdf hbwin png xhb
:LIBS_WINDOWS
set HG_W_LIBS=cw32mt import32 user32 winspool gdi32 comctl32 comdlg32 shell32 ole32 oleaut32 uuid mpr wsock32 ws2_32 mapi32 winmm vfw32 msimg32 iphlpapi
:BUILD_RESPONSE_FILE:
echo c0w32.obj + > b32.bc
echo %HG_FILE%.obj, + >> b32.bc
echo %HG_FILE%.exe, + >> b32.bc
echo %HG_FILE%.map, + >> b32.bc
echo %HG_ROOT%\%LIB_GUI%\oohg.lib + >> b32.bc
echo %HG_ROOT%\%LIB_GUI%\bostaurus.lib + >> b32.bc
echo %HG_ROOT%\%LIB_GUI%\hbprinter.lib + >> b32.bc
echo %HG_ROOT%\%LIB_GUI%\miniprint.lib + >> b32.bc
for %%a in ( %HG_C_LIBS% ) do if exist %HG_HRB%\%LIB_HRB%\%%a.lib echo %HG_HRB%\%LIB_HRB%\%%a.lib + >> b32.bc
for %%a in ( %HG_W_LIBS% ) do echo %%a.lib + >> b32.bc
echo , , + >> b32.bc
if exist _temp.res echo _temp.res >> b32.bc
:LINK
set HG_SEARCH=-L%HG_BCC%\lib;%HG_BCC%\lib\psdk;
if not "%HG_COMP_TYPE%" == "DEBUG" set HG_C_FLAGS=-Gn -Tpe -aa %HG_C_FLAGS%
if "%HG_COMP_TYPE%" == "DEBUG" set HG_C_FLAGS=-Gn -Tpe -ap %HG_C_FLAGS%
%HG_BCC%\bin\ilink32.exe %HG_C_FLAGS% %HG_SEARCH% @b32.bc %HG_C_LOG%
:CLEANUP
if exist b32.bc del b32.bc
if exist %HG_FILE%.map del %HG_FILE%.map
if exist %HG_FILE%.obj del %HG_FILE%.obj
if exist %HG_FILE%.tds del %HG_FILE%.tds
if exist %HG_FILE%.c del %HG_FILE%.c
for %%a in ( _temp.* ) do del %%a
if exist _oohg_resconfig.h del _oohg_resconfig.h
set HG_C_FLAGS=
set HG_C_LIBS=
set HG_C_LOG=
set HG_DEFINES=
set HG_EXTRA=
set HG_PRG_LOG=
set HG_SEARCH=
set HG_USE_RC=
set HG_W_LIBS=
rem *** Run ***
if errorlevel 1 set HG_NO_RUN=TRUE
if "%HG_NO_RUN%" == "FALSE" if "%HG_COMP_TYPE%" == "CONSOLE" %HG_FILE%
if "%HG_NO_RUN%" == "FALSE" if not "%HG_COMP_TYPE%" == "CONSOLE" start %HG_FILE%
set HG_COMP_TYPE=
set HG_FILE=
set HG_NO_RUN=
if exist init.cld del init.cld
goto END
:ERROR1
echo This file must be called from COMPILE.BAT !!!
goto END
:ERROR2
echo COMPILE ERROR: No file specified !!!
goto END
:ERROR3
echo File %HG_FILE%.prg not found !!!
goto END
:ERROR4
echo COMPILE ERROR: Is %HG_FILE%.exe running ?
goto END
:ERROR5
echo Cant't delete _temp.rc file !!!
goto END
:END