forked from microsoft/FFmpegInterop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildFFmpeg.bat
247 lines (205 loc) · 9.32 KB
/
BuildFFmpeg.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
@setlocal
@echo off
if "%1" == "/?" goto Usage
if "%~1" == "" goto Usage
:: Initialize build configuration
set BUILD.ARM=N
set BUILD.x86=N
set BUILD.x64=N
set BUILD.win10=N
set BUILD.win8.1=N
set BUILD.phone8.1=N
:: Iterate through arguments and set the right configuration
for %%a in (%*) do (
if /I "%%a"=="ARM" (
set BUILD.ARM=Y
) else if /I "%%a"=="x86" (
set BUILD.x86=Y
) else if /I "%%a"=="x64" (
set BUILD.x64=Y
) else if /I "%%a"=="win10" (
set BUILD.win10=Y
) else if /I "%%a"=="win8.1" (
set BUILD.win8.1=Y
) else if /I "%%a"=="phone8.1" (
set BUILD.phone8.1=Y
) else (
goto Usage
)
)
:: Set build all architecture if none are specified
if %BUILD.ARM%==N (
if %BUILD.x86%==N (
if %BUILD.x64%==N (
set BUILD.ARM=Y
set BUILD.x86=Y
set BUILD.x64=Y
)
)
)
:: Set build all platform if none are specified
if %BUILD.win10%==N (
if %BUILD.win8.1%==N (
if %BUILD.phone8.1%==N (
goto Usage
)
)
)
:: Verifying ffmpeg directory
echo Verifying ffmpeg directory...
pushd 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
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
if %BUILD.win10%==N goto Win8.1
:: Check for required tools
if not defined VS140COMNTOOLS (
echo:
echo VS140COMNTOOLS environment variable is not found. Check your Visual Studio 2015 installation
goto Cleanup
)
:: Get Windows 10 SDK version
for /F "tokens=3* delims= " %%V in ('reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0" /v ProductVersion /reg:32') do set UCRTSdkVer=%%V.0
:Win10x86
if %BUILD.x86%==N goto Win10x64
echo Building FFmpeg for Windows 10 apps x86...
echo:
setlocal
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86 store
set LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\ucrt\x86;;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\um\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x86;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x86
set LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib;
set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\ucrt;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\um;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\shared;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Win10 x86
endlocal
:Win10x64
if %BUILD.x64%==N goto Win10ARM
echo Building FFmpeg for Windows 10 apps x64...
echo:
setlocal
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64 store
set LIB=%VSINSTALLDIR%VC\lib\store\amd64;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\ucrt\x64;;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\um\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x64
set LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\amd64;%VSINSTALLDIR%VC\lib\amd64;
set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\ucrt;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\um;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\shared;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Win10 x64
endlocal
:Win10ARM
if %BUILD.ARM%==N goto Win8.1
echo Building FFmpeg for Windows 10 apps ARM...
echo:
setlocal
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86_arm store
set LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\ucrt\arm;;%UniversalCRTSdkDir%lib\%UCRTSdkVer%\um\arm;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\arm;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\arm
set LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM;
set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\ucrt;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\um;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\shared;%UniversalCRTSdkDir%Include\%UCRTSdkVer%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Win10 ARM
endlocal
:: Build and deploy Windows 8.1 library
:Win8.1
if %BUILD.win8.1%==N goto Phone8.1
:: Check for required tools
if not defined VS120COMNTOOLS (
echo:
echo VS120COMNTOOLS environment variable is not found. Check your Visual Studio 2013 installation
goto Cleanup
)
:Win8.1x86
if %BUILD.x86%==N goto Win8.1x64
echo Building FFmpeg for Windows 8.1 apps x86...
echo:
setlocal
call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86
set LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%WindowsSdkDir%lib\winv6.3\um\x86;;
set LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib;
set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Win8.1 x86
endlocal
:Win8.1x64
if %BUILD.x64%==N goto Win8.1ARM
echo Building FFmpeg for Windows 8.1 apps x64...
echo:
setlocal
call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x64
set LIB=%VSINSTALLDIR%VC\lib\store\amd64;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%WindowsSdkDir%lib\winv6.3\um\x64;;
set LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%VSINSTALLDIR%VC\lib\amd64;
set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Win8.1 x64
endlocal
:Win8.1ARM
if %BUILD.ARM%==N goto Phone8.1
echo Building FFmpeg for Windows 8.1 apps ARM...
echo:
setlocal
call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86_arm
set LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%WindowsSdkDir%lib\winv6.3\um\arm;;
set LIBPATH=%WindowsSdkDir%References\CommonConfiguration\Neutral;;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM;
set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%Include\um;%WindowsSdkDir%Include\shared;%WindowsSdkDir%Include\winrt;;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Win8.1 ARM
endlocal
:: Build and deploy Windows Phone 8.1 library
:Phone8.1
if %BUILD.phone8.1%==N goto Cleanup
:: Check for required tools
if not defined VS120COMNTOOLS (
echo:
echo VS120COMNTOOLS environment variable is not found. Check your Visual Studio 2013 installation
goto Cleanup
)
:Phone8.1ARM
if %BUILD.ARM%==N goto Phone8.1x86
echo Building FFmpeg for Windows Phone 8.1 apps ARM...
echo:
setlocal
call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86_arm
set LIB=%VSINSTALLDIR%VC\lib\store\ARM;%VSINSTALLDIR%VC\atlmfc\lib\ARM;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\lib\arm;;
set LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\ARM;%VSINSTALLDIR%VC\lib\ARM
set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\abi;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\mincore;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\minwin;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\wrl;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Phone8.1 ARM
endlocal
:Phone8.1x86
if %BUILD.x86%==N goto Cleanup
echo Building FFmpeg for Windows Phone 8.1 apps x86...
echo:
setlocal
call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86
set LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\lib\x86;;
set LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib
set INCLUDE=%VSINSTALLDIR%VC\INCLUDE;%VSINSTALLDIR%VC\ATLMFC\INCLUDE;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\abi;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\mincore;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\minwin;%WindowsSdkDir%..\..\Windows Phone Kits\8.1\Include\wrl;
%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Phone8.1 x86
endlocal
goto Cleanup
:: Display help message
:Usage
echo The correct usage is:
echo:
echo %0 [target platform] [architecture]
echo:
echo where
echo:
echo [target platform] is: win10 ^| win8.1 ^| phone8.1 (at least one)
echo [architecture] is: x86 ^| x64 ^| ARM (optional)
echo:
echo For example:
echo %0 win10 - Build for Windows 10 ARM, x64, and x86
echo %0 phone8.1 ARM - Build for Windows Phone 8.1 ARM only
echo %0 win8.1 x86 x64 - Build for Windows 8.1 x86 and x64 only
echo %0 phone8.1 win10 ARM - Build for Windows 10 and Windows Phone 8.1 ARM only
echo %0 win8.1 phone8.1 win10 - Build all architecture for all target platform
goto :eof
:Cleanup
@endlocal