-
Notifications
You must be signed in to change notification settings - Fork 167
/
zipArtifacts.bat
324 lines (276 loc) · 8.91 KB
/
zipArtifacts.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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
@echo off
@setlocal enabledelayedexpansion
set platform=%1
set configuration=%2
if "%platform%" == "Win32" (
@rem OK
) else if "%platform%" == "x64" (
@rem OK
) else (
call :showhelp %0
exit /b 1
)
if "%configuration%" == "Release" (
@rem OK
) else if "%configuration%" == "Debug" (
@rem OK
) else (
call :showhelp %0
exit /b 1
)
if "%platform%" == "x64" (
set ALPHA=1
) else (
set ALPHA=0
)
set ZIP_CMD=%~dp0tools\zip\zip.bat
set LIST_ZIP_CMD=%~dp0tools\zip\listzip.bat
@rem for GIT_TAG_NAME
call %~dp0sakura\githash.bat %~dp0sakura_core
@rem ----------------------------------------------------------------
@rem prepare environment variable
@rem ----------------------------------------------------------------
@echo checking CI_REPO_NAME %CI_REPO_NAME%
set BUILD_ACCOUNT=
if "%CI_REPO_NAME%" == "sakura-editor/sakura" (
set BUILD_ACCOUNT=
) else if "%CI_REPO_NAME%" == "" (
set BUILD_ACCOUNT=
) else (
set BUILD_ACCOUNT=%CI_ACCOUNT_NAME%
)
@echo checking CI_BUILD_NUMBER %CI_BUILD_NUMBER%
if not "%CI_BUILD_NUMBER%" == "" (
set BUILD_NUMBER=build%CI_BUILD_NUMBER%
) else (
set BUILD_NUMBER=buildLocal
)
@echo checking GIT_TAG_NAME %GIT_TAG_NAME%
if not "%GIT_TAG_NAME%" == "" (
@rem replace '/' with '_'
set TEMP_NAME1=!GIT_TAG_NAME:/=_!
@echo TEMP_NAME1 = !TEMP_NAME1!
@rem replace ' ' with '_'
set TEMP_NAME2=!TEMP_NAME1: =_!
@echo TEMP_NAME2 = !TEMP_NAME2!
@rem replace ' ' with '_'
set TAG_NAME=tag-!TEMP_NAME2!
@echo TAG_NAME = !TEMP_NAME2!
)
@echo checking GITHUB_PR_NUMBER %GITHUB_PR_NUMBER%
if not "%GITHUB_PR_NUMBER%" == "" (
set PR_NAME=PR%GITHUB_PR_NUMBER%
)
@echo hash name
set SHORTHASH=%GIT_SHORT_COMMIT_HASH%
if "%ALPHA%" == "1" (
set RELEASE_PHASE=alpha
) else (
set RELEASE_PHASE=
)
@rem ----------------------------------------------------------------
@rem build BASENAME
@rem ----------------------------------------------------------------
set BASENAME=sakura
@echo adding BUILD_ACCOUNT
if not "%BUILD_ACCOUNT%" == "" (
set BASENAME=%BASENAME%-%BUILD_ACCOUNT%
)
@echo BASENAME = %BASENAME%
@echo adding TAG_NAME
if not "%TAG_NAME%" == "" (
set BASENAME=%BASENAME%-%TAG_NAME%
)
@echo BASENAME = %BASENAME%
@echo adding PR_NAME
if not "%PR_NAME%" == "" (
set BASENAME=%BASENAME%-%PR_NAME%
)
@echo BASENAME = %BASENAME%
@echo adding BUILD_NUMBER
if not "%BUILD_NUMBER%" == "" (
set BASENAME=%BASENAME%-%BUILD_NUMBER%
)
@echo BASENAME = %BASENAME%
@echo adding SHORTHASH
if not "%SHORTHASH%" == "" (
set BASENAME=%BASENAME%-%SHORTHASH%
)
@echo BASENAME = %BASENAME%
@echo adding platform and configuration
set BASENAME=%BASENAME%-%platform%-%configuration%
@echo BASENAME = %BASENAME%
@echo adding RELEASE_PHASE
if not "%RELEASE_PHASE%" == "" (
set BASENAME=%BASENAME%-%RELEASE_PHASE%
)
@echo BASENAME = %BASENAME%
@rem ---------------------- BASENAME ---------------------------------
@rem "sakura"
@rem BUILD_ACCOUNT: (option) APPVEYOR_ACCOUNT_NAME
@rem TAG_NAME : (option) tag Name
@rem PR_NAME : (option) PRxxx (xxx is a PR number)
@rem BUILD_NUMBER : (option) buildYYY or "buildLocal" (YYY is build number)
@rem SHORTHASH : (option) hash or "buildLocal" (hash is leading 8 charactors)
@rem platform : Platform ("Win32" or "x64")
@rem configuration: Configuration ("Debug" or "Release")
@rem RELEASE_PHASE: (option) "alpha" (x64 build only)
@rem ----------------------------------------------------------------
@rem ----------------------------------------------------------------
@rem build WORKDIR
@rem ----------------------------------------------------------------
set WORKDIR=%BASENAME%
set RELDIR_LOG=Log
set RELDIR_EXE=EXE
set RELDIR_DEV=DEV
set RELDIR_INST=Installer
set RELDIR_ASM=Asm
set WORKDIR_LOG=%WORKDIR%\%RELDIR_LOG%
set WORKDIR_EXE=%WORKDIR%\%RELDIR_EXE%
set WORKDIR_DEV=%WORKDIR%\%RELDIR_DEV%
set WORKDIR_INST=%WORKDIR%\%RELDIR_INST%
set WORKDIR_ASM=%WORKDIR%\%RELDIR_ASM%
set OUTFILE=%~dp0%BASENAME%-All.zip
set OUTFILE_LOG=%~dp0%BASENAME%-Log.zip
set OUTFILE_ASM=%~dp0%BASENAME%-Asm.zip
set OUTFILE_INST=%~dp0%BASENAME%-Installer.zip
set OUTFILE_EXE=%~dp0%BASENAME%-Exe.zip
set OUTFILE_DEV=%~dp0%BASENAME%-Dev.zip
@rem cleanup for local testing
if exist "%OUTFILE%" (
del %OUTFILE%
)
if exist "%OUTFILE_LOG%" (
del %OUTFILE_LOG%
)
if exist "%OUTFILE_ASM%" (
del %OUTFILE_ASM%
)
if exist "%OUTFILE_INST%" (
del %OUTFILE_INST%
)
if exist "%OUTFILE_EXE%" (
del %OUTFILE_EXE%
)
if exist "%OUTFILE_DEV%" (
del %OUTFILE_DEV%
)
if exist "%WORKDIR%" (
rmdir /s /q "%WORKDIR%"
)
if exist "%WORKDIR_ASM%" (
rmdir /s /q "%WORKDIR_ASM%"
)
mkdir %WORKDIR%
mkdir %WORKDIR_LOG%
mkdir %WORKDIR_EXE%
mkdir %WORKDIR_EXE%\license\
mkdir %WORKDIR_EXE%\license\bregonig\
mkdir %WORKDIR_EXE%\license\ctags\
mkdir %WORKDIR_DEV%
mkdir %WORKDIR_INST%
copy /Y /B %platform%\%configuration%\sakura.exe %WORKDIR_EXE%\
copy /Y /B %platform%\%configuration%\*.dll %WORKDIR_EXE%\
copy /Y /B %platform%\%configuration%\*.pdb %WORKDIR_DEV%\
: LICENSE
copy /Y .\LICENSE %WORKDIR_EXE%\license\ > NUL
: bregonig
set INSTALLER_RESOURCES_BRON=%~dp0installer\temp\bron
copy /Y %INSTALLER_RESOURCES_BRON%\*.txt %WORKDIR_EXE%\license\bregonig\
: ctags.exe
set INSTALLER_RESOURCES_CTAGS=%~dp0installer\temp\ctags
copy /Y /B %INSTALLER_RESOURCES_CTAGS%\ctags.exe %WORKDIR_EXE%\
copy /Y /B %INSTALLER_RESOURCES_CTAGS%\README.md %WORKDIR_EXE%\license\ctags\
copy /Y /B %INSTALLER_RESOURCES_CTAGS%\license\*.* %WORKDIR_EXE%\license\ctags\
copy /Y /B help\macro\macro.chm %WORKDIR_EXE%\
copy /Y /B help\plugin\plugin.chm %WORKDIR_EXE%\
copy /Y /B help\sakura\sakura.chm %WORKDIR_EXE%\
copy /Y /B html\sakura-doxygen.chm %WORKDIR_DEV%\
copy /Y /B html\sakura-doxygen.chi %WORKDIR_DEV%\
copy /Y /B installer\Output-%platform%\*.exe %WORKDIR_INST%\
copy /Y msbuild-%platform%-%configuration%.log %WORKDIR_LOG%\
copy /Y msbuild-%platform%-%configuration%.log.csv %WORKDIR_LOG%\
if exist "msbuild-%platform%-%configuration%.log.xlsx" (
copy /Y /B "msbuild-%platform%-%configuration%.log.xlsx" %WORKDIR_LOG%\
)
set ISS_LOG_FILE=iss-%platform%-%configuration%.log
if exist "%ISS_LOG_FILE%" (
copy /Y /B "%ISS_LOG_FILE%" %WORKDIR_LOG%\
)
copy /Y sakura_core\githash.h %WORKDIR_LOG%\
if exist "cppcheck-install.log" (
copy /Y "cppcheck-install.log" %WORKDIR_LOG%\
)
if exist "cppcheck-%platform%-%configuration%.xml" (
copy /Y "cppcheck-%platform%-%configuration%.xml" %WORKDIR_LOG%\
)
if exist "cppcheck-%platform%-%configuration%.log" (
copy /Y "cppcheck-%platform%-%configuration%.log" %WORKDIR_LOG%\
)
if exist "doxygen-%platform%-%configuration%.log" (
copy /Y "doxygen-%platform%-%configuration%.log" %WORKDIR_LOG%\
)
if exist "set_appveyor_env.bat" (
copy /Y "set_appveyor_env.bat" %WORKDIR_LOG%\
)
set HASHFILE=sha256.txt
if exist "%HASHFILE%" (
del %HASHFILE%
)
call calc-hash.bat %HASHFILE% %WORKDIR%\
if exist "%HASHFILE%" (
copy /Y %HASHFILE% %WORKDIR%\
)
copy /Y installer\warning.txt %WORKDIR%\
if "%ALPHA%" == "1" (
copy /Y installer\warning-alpha.txt %WORKDIR%\
)
@rem temporally disable to zip all files to a file to workaround #514.
@rem pushd %WORKDIR% && call %ZIP_CMD% %OUTFILE% . && popd
pushd %WORKDIR_LOG% && call %ZIP_CMD% %OUTFILE_LOG% . && popd
@rem copy text files for warning after zipping %OUTFILE% because %WORKDIR% is the parent directory of %WORKDIR_EXE% and %WORKDIR_INST%.
if "%ALPHA%" == "1" (
copy /Y installer\warning-alpha.txt %WORKDIR_EXE%\
copy /Y installer\warning-alpha.txt %WORKDIR_INST%\
)
copy /Y installer\warning.txt %WORKDIR_EXE%\
copy /Y installer\warning.txt %WORKDIR_INST%\
pushd %WORKDIR_INST% && call %ZIP_CMD% %OUTFILE_INST% . && popd
pushd %WORKDIR_EXE% && call %ZIP_CMD% %OUTFILE_EXE% . && popd
pushd %WORKDIR_DEV% && call %ZIP_CMD% %OUTFILE_DEV% . && popd
@echo start zip asm
mkdir %WORKDIR_ASM%
copy /Y build\%platform%\%configuration%\sakura_core\*.asm %WORKDIR_ASM%\ > NUL
pushd %WORKDIR_ASM% && call %ZIP_CMD% %OUTFILE_ASM% . && popd
@echo end zip asm
if exist "%WORKDIR%" (
rmdir /s /q "%WORKDIR%"
)
if exist "%WORKDIR_ASM%" (
rmdir /s /q "%WORKDIR_ASM%"
)
@echo start generate MD5 hash
set CMD_FIND=%SystemRoot%\System32\find.exe
certutil -hashfile %OUTFILE_EXE% MD5 | %CMD_FIND% /v "MD5" | %CMD_FIND% /v "CertUtil" > %OUTFILE_EXE%.md5
certutil -hashfile %OUTFILE_INST% MD5 | %CMD_FIND% /v "MD5" | %CMD_FIND% /v "CertUtil" > %OUTFILE_INST%.md5
@echo end generate MD5 hash
exit /b 0
@rem ------------------------------------------------------------------------------
@rem show help
@rem see http://orangeclover.hatenablog.com/entry/20101004/1286120668
@rem ------------------------------------------------------------------------------
:showhelp
@echo off
@echo usage
@echo %~nx1 platform configuration
@echo.
@echo parameter
@echo platform : Win32 or x64
@echo configuration : Release or Debug
@echo.
@echo example
@echo %~nx1 Win32 Release
@echo %~nx1 Win32 Debug
@echo %~nx1 x64 Release
@echo %~nx1 x64 Debug
exit /b 0