-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildFFmpeg_VS2017.bat
341 lines (263 loc) · 11.2 KB
/
BuildFFmpeg_VS2017.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
@setlocal
@pushd %~dp0
@echo off
:: Checking that we are running from a clean non-dev cmd
if defined VSINSTALLDIR (
echo:
echo This script must be run from a clean cmd environment.
echo Do NOT run from VisualStudio Command Prompt such as "ARM Cross Tools Command Prompt".
echo:
echo Found variable: VSINSTALLDIR
goto Cleanup
)
if defined INCLUDE (
echo:
echo This script must be run from a clean cmd environment.
echo Do NOT run from VisualStudio Command Prompt such as "ARM Cross Tools Command Prompt".
echo:
echo Found variable: INCLUDE
goto Cleanup
)
if defined LIB (
echo:
echo This script must be run from a clean cmd environment.
echo Do NOT run from VisualStudio Command Prompt such as "ARM Cross Tools Command Prompt".
echo:
echo Found variable: LIB
goto Cleanup
)
if defined LIBPATH (
echo:
echo This script must be run from a clean cmd environment.
echo Do NOT run from VisualStudio Command Prompt such as "ARM Cross Tools Command Prompt".
echo:
echo Found variable: LIBPATH
goto Cleanup
)
echo:
echo Searching VS Installation folder...
set VSInstallerFolder="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
if %PROCESSOR_ARCHITECTURE%==x86 set VSInstallerFolder="%ProgramFiles%\Microsoft Visual Studio\Installer"
pushd %VSInstallerFolder%
for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set VSLATESTDIR=%%i
)
popd
echo VS Installation folder: %VSLATESTDIR%
if not exist "%VSLATESTDIR%\VC\Auxiliary\Build\vcvarsall.bat" (
echo:
echo VSInstallDir not found or not installed correctly.
goto Cleanup
)
echo:
echo Checking CPU architecture...
if %PROCESSOR_ARCHITECTURE%==x86 (
set Comp_x86=x86 uwp 10.0.15063.0
set Comp_x64=x86_amd64 uwp 10.0.15063.0
set Comp_ARM=x86_arm uwp 10.0.15063.0
set Comp_ARM64=x86_arm64 uwp 10.0.15063.0
) else (
set Comp_x86=amd64_x86 uwp 10.0.15063.0
set Comp_x64=amd64 uwp 10.0.15063.0
set Comp_ARM=amd64_arm uwp 10.0.15063.0
set Comp_ARM64=amd64_arm64 uwp 10.0.15063.0
)
:: Export full current PATH from environment into MSYS2
set MSYS2_PATH_TYPE=inherit
:: Verifying ffmpeg directory
echo Verifying ffmpeg directory...
pushd %~dp0\ffmpeg
if not exist configure (
echo:
echo configure is not found in ffmpeg folder. Ensure this folder is populated with ffmpeg snapshot
goto Cleanup
)
popd
:: Check for required tools
echo:
echo Checking for MSYS2...
if not defined MSYS2_BIN (
if exist C:\msys64\usr\bin\bash.exe set MSYS2_BIN="C:\msys64\usr\bin\bash.exe"
)
if not defined MSYS2_BIN (
if exist C:\msys\usr\bin\bash.exe set MSYS2_BIN="C:\msys\usr\bin\bash.exe"
)
if defined MSYS2_BIN (
if exist %MSYS2_BIN% goto Win10
)
echo:
echo MSYS2 is needed. Set it up properly and provide the executable path in MSYS2_BIN environment variable. E.g.
echo:
echo set MSYS2_BIN="C:\msys64\usr\bin\bash.exe"
echo:
echo See https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT#PrerequisitesandFirstTimeSetupInstructions
goto Cleanup
:: Build and deploy Windows 10 library
:Win10
set OnePlatform=1
if "%1" == "" (
echo:
echo Building FFmpeg for all platforms
set OnePlatform=0
goto Win10x86
)
if %1 == x86 goto Win10x86
if %1 == x64 goto Win10x64
if %1 == ARM goto Win10ARM
if %1 == ARM64 goto Win10ARM64
echo Invalid argument: %1
goto Cleanup
:Win10x86
echo:
echo Building FFmpeg for Windows 10 apps x86...
echo:
setlocal
call "%VSLATESTDIR%\VC\Auxiliary\Build\vcvarsall.bat" %Comp_x86%
set ARCH=x86
:: Build libs
set libs=Libs\Build\%ARCH%
md %libs%\lib
md %libs%\licenses
md %libs%\include
rd /S /Q %libs%\build
md %libs%\build
msbuild Libs\zlib\SMP\libzlib.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libzlib\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libzlib\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.lib %libs%\lib\zlib.lib
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.pdb %libs%\lib\zlib.pdb
msbuild Libs\bzip2\SMP\libbz2.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libbz2\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libbz2\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.lib %libs%\lib\bz2.lib
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.pdb %libs%\lib\bz2.pdb
msbuild Libs\libiconv\SMP\libiconv.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libiconv\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libiconv\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.lib %libs%\lib\iconv.lib
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.pdb %libs%\lib\iconv.pdb
set LIB=%LIB%;%~dp0%libs%\lib
set INCLUDE=%INCLUDE%;%~dp0%libs%\include
:: Build ffmpeg
%MSYS2_BIN% --login -x "%~dp0FFmpegConfig.sh" Win10 %ARCH% || goto error
for /r ffmpeg\Output\Windows10\%ARCH% %%f in (*.pdb) do copy /Y "%%f" ffmpeg\Build\Windows10\%ARCH%\bin\
endlocal
if %OnePlatform% == 1 goto Cleanup
:Win10x64
echo:
echo Building FFmpeg for Windows 10 apps x64...
echo:
setlocal
call "%VSLATESTDIR%\VC\Auxiliary\Build\vcvarsall.bat" %Comp_x64%
set ARCH=x64
:: Build libs
set libs=Libs\Build\%ARCH%
md %libs%\lib
md %libs%\licenses
md %libs%\include
rd /S /Q %libs%\build
md %libs%\build
msbuild Libs\zlib\SMP\libzlib.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libzlib\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libzlib\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.lib %libs%\lib\zlib.lib
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.pdb %libs%\lib\zlib.pdb
msbuild Libs\bzip2\SMP\libbz2.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libbz2\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libbz2\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.lib %libs%\lib\bz2.lib
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.pdb %libs%\lib\bz2.pdb
msbuild Libs\libiconv\SMP\libiconv.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libiconv\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libiconv\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.lib %libs%\lib\iconv.lib
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.pdb %libs%\lib\iconv.pdb
set LIB=%LIB%;%~dp0%libs%\lib
set INCLUDE=%INCLUDE%;%~dp0%libs%\include
:: Build ffmpeg
%MSYS2_BIN% --login -x "%~dp0FFmpegConfig.sh" Win10 %ARCH% || goto error
for /r ffmpeg\Output\Windows10\%ARCH% %%f in (*.pdb) do copy /Y "%%f" ffmpeg\Build\Windows10\%ARCH%\bin\
endlocal
if %OnePlatform% == 1 goto Cleanup
:Win10ARM
echo:
echo Building FFmpeg for Windows 10 apps ARM...
echo:
setlocal
call "%VSLATESTDIR%\VC\Auxiliary\Build\vcvarsall.bat" %Comp_ARM%
set ARCH=ARM
:: Build libs
set libs=Libs\Build\%ARCH%
md %libs%\lib
md %libs%\licenses
md %libs%\include
rd /S /Q %libs%\build
md %libs%\build
msbuild Libs\zlib\SMP\libzlib.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libzlib\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libzlib\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.lib %libs%\lib\zlib.lib
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.pdb %libs%\lib\zlib.pdb
msbuild Libs\bzip2\SMP\libbz2.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libbz2\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libbz2\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.lib %libs%\lib\bz2.lib
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.pdb %libs%\lib\bz2.pdb
msbuild Libs\libiconv\SMP\libiconv.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libiconv\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libiconv\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.lib %libs%\lib\iconv.lib
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.pdb %libs%\lib\iconv.pdb
set LIB=%LIB%;%~dp0%libs%\lib
set INCLUDE=%INCLUDE%;%~dp0%libs%\include
:: Build ffmpeg
%MSYS2_BIN% --login -x "%~dp0FFmpegConfig.sh" Win10 %ARCH% || goto error
for /r ffmpeg\Output\Windows10\%ARCH% %%f in (*.pdb) do copy /Y "%%f" ffmpeg\Build\Windows10\%ARCH%\bin\
endlocal
if %OnePlatform% == 1 goto Cleanup
:Win10ARM64
echo:
echo Building FFmpeg for Windows 10 apps ARM64...
echo:
setlocal
call "%VSLATESTDIR%\VC\Auxiliary\Build\vcvarsall.bat" %Comp_ARM64%
set ARCH=ARM64
:: Build libs
set libs=Libs\Build\%ARCH%
md %libs%\lib
md %libs%\licenses
md %libs%\include
rd /S /Q %libs%\build
md %libs%\build
msbuild Libs\zlib\SMP\libzlib.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libzlib\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libzlib\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.lib %libs%\lib\zlib.lib
copy /Y %libs%\build\libzlib\lib\%ARCH%\libzlib_winrt.pdb %libs%\lib\zlib.pdb
msbuild Libs\bzip2\SMP\libbz2.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libbz2\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libbz2\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.lib %libs%\lib\bz2.lib
copy /Y %libs%\build\libbz2\lib\%ARCH%\libbz2_winrt.pdb %libs%\lib\bz2.pdb
msbuild Libs\libiconv\SMP\libiconv.vcxproj -p:OutDir="%~dp0%libs%\build\\";Configuration=ReleaseWinRT;Platform=%ARCH% || goto error
for /r %libs%\build\libiconv\include %%f in (*.h) do copy /Y "%%f" %libs%\include\
for /r %libs%\build\libiconv\licenses %%f in (*.*) do copy /Y "%%f" %libs%\licenses\
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.lib %libs%\lib\iconv.lib
copy /Y %libs%\build\libiconv\lib\%ARCH%\libiconv_winrt.pdb %libs%\lib\iconv.pdb
set LIB=%LIB%;%~dp0%libs%\lib
set INCLUDE=%INCLUDE%;%~dp0%libs%\include
:: Build ffmpeg
%MSYS2_BIN% --login -x "%~dp0FFmpegConfig.sh" Win10 %ARCH% || goto error
for /r ffmpeg\Output\Windows10\%ARCH% %%f in (*.pdb) do copy /Y "%%f" ffmpeg\Build\Windows10\%ARCH%\bin\
endlocal
if %OnePlatform% == 1 goto Cleanup
if %errorlevel% == 0 goto Cleanup
:error
echo:
echo Build failed with error %errorlevel%.
popd
endlocal
exit /b
:Cleanup
@popd
@endlocal