-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild64.bat
195 lines (157 loc) · 7.13 KB
/
build64.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
@ECHO OFF
TITLE Building in 64 bits...
rem *******************************************************************************
rem SYNTAX
rem *******************************************************************************
rem build [ /n ] [ /d ] [ /c ] <program.prg> | <project.hbp> [<hbmk2 params>]
rem
rem /n no run after build
rem /d enabled debugger
rem /c console mode
rem
rem
rem This batch file passes information to hbmk2 to make possible an easy (zero
rem configuration build of HMG applications).
rem
rem You can achieve a customized build passing parameters directly to hbmk2.
rem Please, take a look at hbmk2 help:
rem
rem hbmk2 --help
rem *******************************************************************************
rem SET DEFAULT OPTIONS
rem *******************************************************************************
SET gtdrivers=-gtgui -gtwin
SET runafterbuild=.t.
SET debug=
rem ******************************************************************************
rem DELETE FILES FROM PREVIOUS BUILD
rem ******************************************************************************
if exist build.log del build.log
if exist error.log del error.log
if exist init.cld del init.cld
rem ******************************************************************************
rem SET HMGPATH
rem ******************************************************************************
rem
rem Using %~dp0 the HMGPATH is automatically set to current (hmg) folder making it
rem portable (zero config)
SET HMGPATH=%~dp0
rem ******************************************************************************
rem SET BINARIES PATHS
rem ******************************************************************************
SET PATH=%HMGPATH%\harbour-64\bin;%HMGPATH%\mingw-64\bin;%PATH%
rem *******************************************************************************
rem PROCESS PARAMETERS
rem *******************************************************************************
rem
rem /n no run after build
rem /d enabled debugger
rem /c console mode
if "%1"=="" goto VERSION
if /I [%1]==[/n] set runafterbuild=.f.
if /I [%1]==[/n] shift
rem if /I [%1]==[/d] set gtdrivers=-gtwin -gtgui
if /I [%1]==[/d] set debug=-b
rem if /I [%1]==[/d] echo options norunatstartup > init.cld
if /I [%1]==[/d] shift
if /I [%1]==[/c] set gtdrivers=-gtwin -gtgui
if /I [%1]==[/c] shift
rem In case ViewError.exe be not found in the environment setted, will be cutted off:
if not "%ViewError%"=="" if not exist %ViewError%\ViewError.exe SET ViewError=
rem ******************************************************************************
rem Attempt to delete EXE and report if it been executed
rem ******************************************************************************
:CHECKEXE
if exist "%~n1.exe" del "%~n1.exe"
if not exist "%~n1.exe" goto COMPILE_RES
if "%ViewError%"=="" echo x=MSGBOX("%~n1.exe is currently running."+chr(13)+chr(10)+"Close it and try again.",0," ERROR at trying to compile") > %temp%\TEMPmessage.vbs
if "%ViewError%"=="" call %temp%\TEMPmessage.vbs
if exist %temp%\TEMPmessage.vbs del %temp%\TEMPmessage.vbs /f /q
echo Operating System: cannot open output file %~n1.exe: Permission denied > error.log
echo HMG_IDE_NoRunApp >> error.log
if not "%ViewError%"=="" goto VIEWERROR
goto END
rem ******************************************************************************
rem COMPILE RESOURCES
rem ******************************************************************************
:COMPILE_RES
if exist build.log del build.log
echo #define HMGRPATH %HmgPath%\RESOURCES > _hmg_resconfig.h
COPY /b %HMGPATH%\resources\hmg64.rc+"%~n1.rc"+%HMGPATH%\resources\filler _temp.rc >NUL
windres -i _temp.rc -o _temp.o >windres.log 2>&1
rem *******************************************************************************
rem SET PROJECT OUTPUT FILE NAME
rem *******************************************************************************
rem
rem The first parameter sent to hbmk2 is -o%~n1.exe. I've added to it create the
rem application with the project basename (<projectname.hbp> specified by the user.
rem *******************************************************************************
rem SET DEFAULT CONFIGURATION FILE
rem *******************************************************************************
rem
rem The second parameter sent to hbmk2 is the hmg.hbc script to set config required.
rem *******************************************************************************
rem SET QUIET MODE
rem *******************************************************************************
rem
rem The third parameter sent to hbmk2 is -q (Harbour quiet mode)
rem ******************************************************************************
rem CALL HBMK2
rem ******************************************************************************
rem -ldflag="-pthread -static-libgcc -static-libstdc++ -static -lpthread" --> for gcc.exe link pthread library in static mode
rem -trace --> for show execute command line
HBMK2 -ldflag="-pthread -static-libgcc -static-libstdc++ -static -lpthread" -mt -o"%~n1" %HMGPATH%\hmg64.hbc %gtdrivers% %debug% -q %1 %2 %3 %4 %5 %6 %7 %8 >hbmk.log 2>&1
rem ******************************************************************************
rem CREATE LOGS
rem ******************************************************************************
if errorlevel 1 if exist windres.log copy /a windres.log+hbmk.log error.log >nul
if errorlevel 1 if not exist windres.log copy /a hbmk.log error.log >nul
if errorlevel 0 if exist windres.log copy /a windres.log+hbmk.log build.log >nul
if errorlevel 0 if not exist windres.log copy /a hbmk.log build.log >nul
if exist error.log goto ERROR
goto CLEANUP
rem ******************************************************************************
rem COMPILING ERRORS
rem ******************************************************************************
:ERROR
if not "%ViewError%"=="" echo HMG_IDE_NoRunApp >> error.log
goto VIEWERROR
rem ******************************************************************************
rem CLEANUP
rem ******************************************************************************
:CLEANUP
if exist windres.log del windres.log
if exist hbmk.log del hbmk.log
if exist _hmg_resconfig.h del _hmg_resconfig.h
if exist _temp.rc del _temp.rc
if exist _temp.o del _temp.o
rem ******************************************************************************
rem SHOW LOG
rem ******************************************************************************
:VIEWERROR
if not exist error.log goto RUNAPP
if not "%ViewError%"=="" %ViewError%\ViewError.exe error.log %HmgPath% %1 64
if [%runafterbuild%]==[.f.] goto END
if "%ViewError%"=="" TYPE error.log
rem if "%ViewError%"=="" PAUSE
goto END
rem ******************************************************************************
rem RUN APPLICATION
rem ******************************************************************************
:VERSION
ECHO.
ECHO.
ECHO Build [ /n ] [ /d ] [ /c ] <program.prg> | <project.hbp> [<hbmk2 params>]
ECHO.
ECHO.
PAUSE
GOTO END
:OTHER
SET /p "OTHER=" <dat
COPY "%~n1".exe %other%
if errorlevel 1 goto END
CD /D %other%
:RUNAPP
if [%runafterbuild%]==[.f.] goto END
if exist "%~n1".exe "%~n1".exe
:END