-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathz_build.bat
352 lines (314 loc) · 18.3 KB
/
z_build.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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
@echo off
setlocal enabledelayedexpansion
REM ///////////////////////////////////////////////////////////////////////////
REM // Set Paths
REM ///////////////////////////////////////////////////////////////////////////
set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
set "TOOLS_VER=141"
set "SLN_SUFFX=VS2017"
REM ###############################################
REM # DO NOT MODIFY ANY LINES BELOW THIS LINE !!! #
REM ###############################################
REM ///////////////////////////////////////////////////////////////////////////
REM // Check environment
REM ///////////////////////////////////////////////////////////////////////////
if not exist "%MSVC_PATH%\vcvarsall.bat" (
if not exist "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" (
echo MSVC compiler not found. Please check your MSVC_PATH var^^!
goto BuildError
)
)
if not exist "%QTDIR%\bin\moc.exe" (
echo Qt could not be found. Please check your QTDIR var^^!
goto BuildError
)
if not exist "%QTDIR%\include\QtCore\qglobal.h" (
echo Qt could not be found. Please check your QTDIR var^^!
goto BuildError
)
if not exist "%JAVA_HOME%\bin\java.exe" (
echo JDK could not be found. Please check your JAVA_HOME var^^!
goto BuildError
)
if not exist "%JAVA_HOME%\lib\tools.jar" (
echo JDK could not be found. Please check your JAVA_HOME var^^!
goto BuildError
)
if not exist "%JAVA_HOME%\include\jni.h" (
echo JDK could not be found. Please check your JAVA_HOME var^^!
goto BuildError
)
if not exist "%~dp0\..\Prerequisites\README.txt" (
echo Prerequisites not found. Repair your build environment^^!
goto BuildError
)
REM ///////////////////////////////////////////////////////////////////////////
REM // Setup environment
REM ///////////////////////////////////////////////////////////////////////////
set "ANT_HOME=%~dp0\..\Prerequisites\Ant"
set "PATH=%QTDIR%\bin;%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%"
if exist "%MSVC_PATH%\vcvarsall.bat" (
call "%MSVC_PATH%\vcvarsall.bat" x86
) else (
if exist "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" (
call "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" x86
)
)
if not exist "%VCINSTALLDIR%\bin\cl.exe" (
if not exist "%VCToolsInstallDir%\bin\Hostx64\x86\cl.exe" (
echo MSVC compiler not found. Please check your MSVC_PATH var^^!
goto BuildError
)
)
REM ///////////////////////////////////////////////////////////////////////////
REM // Get current date and time (in ISO format)
REM ///////////////////////////////////////////////////////////////////////////
set "ISO_DATE="
set "ISO_TIME="
if not exist "%~dp0\..\Prerequisites\GnuWin32\date.exe" goto BuildError
for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\..\Prerequisites\GnuWin32\date.exe" +ISODATE:%%Y-%%m-%%d') do (
if "%%a"=="ISODATE" set "ISO_DATE=%%b"
)
for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\..\Prerequisites\GnuWin32\date.exe" +ISOTIME:%%T') do (
if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
)
if "%ISO_DATE%"=="" goto BuildError
if "%ISO_TIME%"=="" goto BuildError
REM ///////////////////////////////////////////////////////////////////////////
REM // Detect version number
REM ///////////////////////////////////////////////////////////////////////////
set "VER_MAJOR="
set "VER_MINOR="
set "VER_PATCH="
for /F "tokens=1,2,3" %%a in (%~dp0\DynamicAudioNormalizerShared\res\version.inc) do (
if "%%a"=="#define" (
if "%%b"=="VER_DYNAUDNORM_MAJOR" set "VER_MAJOR=%%c"
if "%%b"=="VER_DYNAUDNORM_MINOR_HI" set "VER_MINOR=%%c!VER_MINOR!"
if "%%b"=="VER_DYNAUDNORM_MINOR_LO" set "VER_MINOR=!VER_MINOR!%%c"
if "%%b"=="VER_DYNAUDNORM_PATCH" set "VER_PATCH=%%c"
)
)
if "%VER_MAJOR%"=="" goto BuildError
if "%VER_MINOR%"=="" goto BuildError
if "%VER_PATCH%"=="" goto BuildError
REM ///////////////////////////////////////////////////////////////////////////
REM // Clean Binaries
REM ///////////////////////////////////////////////////////////////////////////
for /d %%d in (%~dp0\bin\*) do (rmdir /S /Q "%%~d")
for /d %%d in (%~dp0\obj\*) do (rmdir /S /Q "%%~d")
REM ///////////////////////////////////////////////////////////////////////////
REM // Build the binaries
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
for %%p in (Win32, x64) do (
echo ---------------------------------------------------------------------
echo BEGIN BUILD [%%p/Release_%%c]
echo ---------------------------------------------------------------------
MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:clean "%~dp0\DynamicAudioNormalizer_%SLN_SUFFX%.sln"
if not "!ERRORLEVEL!"=="0" goto BuildError
MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:rebuild "%~dp0\DynamicAudioNormalizer_%SLN_SUFFX%.sln"
if not "!ERRORLEVEL!"=="0" goto BuildError
MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:build "%~dp0\DynamicAudioNormalizer_%SLN_SUFFX%.sln"
if not "!ERRORLEVEL!"=="0" goto BuildError
)
)
call "%ANT_HOME%\bin\ant.bat" -buildfile "%~dp0\DynamicAudioNormalizerJNI\build.xml"
if not "!ERRORLEVEL!"=="0" goto BuildError
REM ///////////////////////////////////////////////////////////////////////////
REM // Copy program files
REM ///////////////////////////////////////////////////////////////////////////
set "PACK_PATH=%TMP%\~%RANDOM%%RANDOM%.tmp"
mkdir "%PACK_PATH%"
for %%c in (DLL, Static) do (
echo ---------------------------------------------------------------------
echo BEGIN PACKAGING [Release_%%c]
echo ---------------------------------------------------------------------
mkdir "%PACK_PATH%\%%c"
mkdir "%PACK_PATH%\%%c\x64"
mkdir "%PACK_PATH%\%%c\img"
mkdir "%PACK_PATH%\%%c\img\dyauno"
mkdir "%PACK_PATH%\%%c\include"
mkdir "%PACK_PATH%\%%c\samples"
mkdir "%PACK_PATH%\%%c\samples\python"
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerCLI.exe" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerGUI.exe" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerPYD.pyd" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\x64\.\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerPYD.pyd" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerVST.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\x64\.\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerVST.dll" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerWA5.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerPYD\include\*.py" "%PACK_PATH%\%%c\include"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerPYD\samples\*.py" "%PACK_PATH%\%%c\samples\python"
if not "!ERRORLEVEL!"=="0" goto BuildError
if /I "%%c"=="DLL" (
mkdir "%PACK_PATH%\%%c\redist"
mkdir "%PACK_PATH%\%%c\samples\delphi"
mkdir "%PACK_PATH%\%%c\samples\dotNet"
mkdir "%PACK_PATH%\%%c\samples\java"
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerAPI.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerAPI.lib" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\Win32\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerNET.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\x64\.\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerAPI.dll" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\x64\.\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerAPI.lib" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\bin\x64\.\v%TOOLS_VER%_xp\Release_%%c\DynamicAudioNormalizerNET.dll" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerAPI\include\*.h" "%PACK_PATH%\%%c\include"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerPAS\include\*.pas" "%PACK_PATH%\%%c\include"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerJNI\out\*.jar" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\LibSndFile\bin\Win32\libsndfile-1.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\LibMpg123\bin\Win32\libmpg123.v%TOOLS_VER%_xp.dll" "%PACK_PATH%\%%c\libmpg123.dll"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\XiphAudioLibs\bin\Win32\libopus.v%TOOLS_VER%_xp.dll" "%PACK_PATH%\%%c\libopus.dll"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\XiphAudioLibs\bin\Win32\libopusfile.v%TOOLS_VER%_xp.dll" "%PACK_PATH%\%%c\libopusfile.dll"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\XiphAudioLibs\bin\Win32\libogg.v%TOOLS_VER%_xp.dll" "%PACK_PATH%\%%c\libogg.dll"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtGui4.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtCore4.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerNET\samples\*.cs" "%PACK_PATH%\%%c\samples\dotNet"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerNET\samples\*.vb" "%PACK_PATH%\%%c\samples\dotNet"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerPAS\src\*.pas" "%PACK_PATH%\%%c\samples\delphi"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerPAS\src\*.dfm" "%PACK_PATH%\%%c\samples\delphi"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\DynamicAudioNormalizerJNI\samples\com\muldersoft\dynaudnorm\samples\*.java" "%PACK_PATH%\%%c\samples\java"
if not "!ERRORLEVEL!"=="0" goto BuildError
if %TOOLS_VER% GEQ 140 (
if %TOOLS_VER% GEQ 141 (
copy "%VCToolsRedistDir%\x86\Microsoft.VC%TOOLS_VER%.CRT\*.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%VCToolsRedistDir%\x64\Microsoft.VC%TOOLS_VER%.CRT\*.dll" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%VCToolsRedistDir%\vcredist_*.exe" "%PACK_PATH%\%%c\redist"
if not "!ERRORLEVEL!"=="0" goto BuildError
) else (
copy "%MSVC_PATH%\redist\x86\Microsoft.VC%TOOLS_VER%.CRT\*.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%MSVC_PATH%\redist\x64\Microsoft.VC%TOOLS_VER%.CRT\*.dll" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%MSVC_PATH%\redist\1033\vcredist_*.exe" "%PACK_PATH%\%%c\redist"
if not "!ERRORLEVEL!"=="0" goto BuildError
)
copy "%~dp0\..\Prerequisites\MSVC\redist\ucrt\DLLs\x86\*.dll" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\..\Prerequisites\MSVC\redist\ucrt\DLLs\x64\*.dll" "%PACK_PATH%\%%c\x64"
if not "!ERRORLEVEL!"=="0" goto BuildError
)
)
copy "%~dp0\LICENSE-LGPL.html" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\LICENSE-GPL2.html" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\LICENSE-GPL3.html" "%PACK_PATH%\%%c"
if not "!ERRORLEVEL!"=="0" goto BuildError
copy "%~dp0\img\dyauno\*.png" "%PACK_PATH%\%%c\img\dyauno"
if not "!ERRORLEVEL!"=="0" goto BuildError
"%~dp0\..\Prerequisites\Pandoc\pandoc.exe" --from markdown_github+pandoc_title_block+header_attributes+implicit_figures --to html5 --toc -N --standalone -H "%~dp0\..\Prerequisites\Pandoc\css\github-pandoc.inc" "%~dp0\README.md" | "%JAVA_HOME%\bin\java.exe" -jar "%~dp0\..\Prerequisites\HTMLCompressor\bin\htmlcompressor-1.5.3.jar" --compress-css -o "%PACK_PATH%\%%c\README.html"
if not "!ERRORLEVEL!"=="0" goto BuildError
)
REM ///////////////////////////////////////////////////////////////////////////
REM // Compress
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (Static) do (
for %%i in (DynamicAudioNormalizerCLI.exe,DynamicAudioNormalizerGUI.exe,DynamicAudioNormalizerPYD.pyd,DynamicAudioNormalizerVST.dll,DynamicAudioNormalizerWA5.dll) do (
"%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\%%c\%%~i"
if not "!ERRORLEVEL!"=="0" goto BuildError
)
for %%i in (DynamicAudioNormalizerPYD.pyd,DynamicAudioNormalizerVST.dll) do (
"%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\%%c\x64\%%~i"
if not "!ERRORLEVEL!"=="0" goto BuildError
)
)
REM ///////////////////////////////////////////////////////////////////////////
REM // Create version tag
REM ///////////////////////////////////////////////////////////////////////////
echo Dynamic Audio Normalizer> "%PACK_PATH%\BUILD_TAG"
echo Copyright (c) 2014-2019 LoRd_MuldeR ^<[email protected]^>. Some rights reserved.>> "%PACK_PATH%\BUILD_TAG"
echo.>> "%PACK_PATH%\BUILD_TAG"
echo Version %VER_MAJOR%.%VER_MINOR%-%VER_PATCH%. Built on %ISO_DATE%, at %ISO_TIME%>> "%PACK_PATH%\BUILD_TAG"
echo.>> "%PACK_PATH%\BUILD_TAG"
cl.exe 2>&1 | "%~dp0\..\Prerequisites\GnuWin32\head.exe" -n1 | "%~dp0\..\Prerequisites\GnuWin32\sed.exe" -e "/^$/d" -e "s/^/Compiler version: /">> "%PACK_PATH%\BUILD_TAG"
ver 2>&1 | "%~dp0\..\Prerequisites\GnuWin32\sed.exe" -e "/^$/d" -e "s/^/Build platform: /">> "%PACK_PATH%\BUILD_TAG"
echo.>> "%PACK_PATH%\BUILD_TAG"
echo This library is free software; you can redistribute it and/or>> "%PACK_PATH%\BUILD_TAG"
echo modify it under the terms of the GNU Lesser General Public>> "%PACK_PATH%\BUILD_TAG"
echo License as published by the Free Software Foundation; either>> "%PACK_PATH%\BUILD_TAG"
echo version 2.1 of the License, or (at your option) any later version.>> "%PACK_PATH%\BUILD_TAG"
echo.>> "%PACK_PATH%\BUILD_TAG"
echo This library is distributed in the hope that it will be useful,>> "%PACK_PATH%\BUILD_TAG"
echo but WITHOUT ANY WARRANTY; without even the implied warranty of>> "%PACK_PATH%\BUILD_TAG"
echo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU>> "%PACK_PATH%\BUILD_TAG"
echo Lesser General Public License for more details.>> "%PACK_PATH%\BUILD_TAG"
REM ///////////////////////////////////////////////////////////////////////////
REM // Attributes
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
attrib +R "%PACK_PATH%\%%c\*"
attrib +R "%PACK_PATH%\%%c\x64\*"
attrib +R "%PACK_PATH%\%%c\img\dyauno\*"
if /I "%%c"=="DLL" (
attrib +R "%PACK_PATH%\%%c\include\*"
)
)
REM ///////////////////////////////////////////////////////////////////////////
REM // Generate outfile name
REM ///////////////////////////////////////////////////////////////////////////
mkdir "%~dp0\out" 2> NUL
set "OUT_NAME=DynamicAudioNormalizer.%ISO_DATE%"
:CheckOutName
for %%c in (DLL, Static) do (
if exist "%~dp0\out\%OUT_NAME%.%%c.zip" (
set "OUT_NAME=%OUT_NAME%.new"
goto CheckOutName
)
)
REM ///////////////////////////////////////////////////////////////////////////
REM // Build the package
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
copy "%PACK_PATH%\BUILD_TAG" "%PACK_PATH%\%%c"
pushd "%PACK_PATH%\%%c"
"%~dp0\..\Prerequisites\GnuWin32\zip.exe" -9 -r -z "%~dp0\out\%OUT_NAME%.%%c.zip" "*.*" < "%PACK_PATH%\BUILD_TAG"
popd
attrib +R "%~dp0\out\%OUT_NAME%.%%c.zip"
)
REM Clean up!
rmdir /Q /S "%PACK_PATH%"
REM ///////////////////////////////////////////////////////////////////////////
REM // COMPLETE
REM ///////////////////////////////////////////////////////////////////////////
echo.
echo Build completed.
echo.
pause
goto:eof
REM ///////////////////////////////////////////////////////////////////////////
REM // FAILED
REM ///////////////////////////////////////////////////////////////////////////
:BuildError
echo.
echo Build has failed ^^!^^!^^!
echo.
pause