forked from Aleksoid1978/MPC-BE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bat
653 lines (534 loc) · 22.5 KB
/
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
@ECHO OFF
REM (C) 2009-2022 see Authors.txt
REM
REM This file is part of MPC-BE.
REM
REM MPC-BE is free software; you can redistribute it and/or modify
REM it under the terms of the GNU General Public License as published by
REM the Free Software Foundation; either version 3 of the License, or
REM (at your option) any later version.
REM
REM MPC-BE is distributed in the hope that it will be useful,
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
REM GNU General Public License for more details.
REM
REM You should have received a copy of the GNU General Public License
REM along with this program. If not, see <http://www.gnu.org/licenses/>.
SETLOCAL ENABLEDELAYEDEXPANSION
CD /D %~dp0
SET ARG=%*
SET ARG=%ARG:/=%
SET ARG=%ARG:-=%
SET ARGB=0
SET ARGBC=0
SET ARGC=0
SET ARGCOMP=0
SET ARGCL=0
SET ARGD=0
SET ARGF=0
SET ARGM=0
SET ARGPL=0
SET ARGPA=0
SET ARGIN=0
SET ARGZI=0
SET ARGPDB=0
SET INPUT=0
SET ARGSIGN=0
IF /I "%ARG%" == "?" GOTO ShowHelp
FOR %%A IN (%ARG%) DO (
IF /I "%%A" == "help" GOTO ShowHelp
IF /I "%%A" == "GetVersion" ENDLOCAL & CALL :SubGetVersion & EXIT /B
IF /I "%%A" == "Build" SET "BUILDTYPE=Build" & SET /A ARGB+=1
IF /I "%%A" == "Clean" SET "BUILDTYPE=Clean" & SET /A ARGB+=1 & SET /A ARGCL+=1
IF /I "%%A" == "Rebuild" SET "BUILDTYPE=Rebuild" & SET /A ARGB+=1
IF /I "%%A" == "Both" SET "BUILDPLATFORM=Both" & SET /A ARGPL+=1
IF /I "%%A" == "Win32" SET "BUILDPLATFORM=Win32" & SET /A ARGPL+=1
IF /I "%%A" == "x86" SET "BUILDPLATFORM=Win32" & SET /A ARGPL+=1
IF /I "%%A" == "x64" SET "BUILDPLATFORM=x64" & SET /A ARGPL+=1
IF /I "%%A" == "All" SET "CONFIG=All" & SET /A ARGC+=1
IF /I "%%A" == "Main" SET "CONFIG=Main" & SET /A ARGC+=1 & SET /A ARGM+=1
IF /I "%%A" == "Filters" SET "CONFIG=Filters" & SET /A ARGC+=1 & SET /A ARGF+=1
IF /I "%%A" == "MPCBE" SET "CONFIG=MPCBE" & SET /A ARGC+=1
IF /I "%%A" == "MPC-BE" SET "CONFIG=MPCBE" & SET /A ARGC+=1
IF /I "%%A" == "Resource" SET "CONFIG=Resources" & SET /A ARGC+=1 & SET /A ARGD+=1
IF /I "%%A" == "Resources" SET "CONFIG=Resources" & SET /A ARGC+=1 & SET /A ARGD+=1
IF /I "%%A" == "Debug" SET "BUILDCFG=Debug" & SET /A ARGBC+=1 & SET /A ARGD+=1
IF /I "%%A" == "Release" SET "BUILDCFG=Release" & SET /A ARGBC+=1
IF /I "%%A" == "VS2017" SET "COMPILER=VS2017" & SET /A ARGCOMP+=1
IF /I "%%A" == "VS2022" SET "COMPILER=VS2022" & SET /A ARGCOMP+=1
IF /I "%%A" == "Packages" SET "PACKAGES=True" & SET /A ARGPA+=1 & SET /A ARGCL+=1 & SET /A ARGD+=1 & SET /A ARGF+=1 & SET /A ARGM+=1
IF /I "%%A" == "Installer" SET "INSTALLER=True" & SET /A ARGIN+=1 & SET /A ARGCL+=1 & SET /A ARGD+=1 & SET /A ARGF+=1 & SET /A ARGM+=1
IF /I "%%A" == "Zip" SET "ZIP=True" & SET /A ARGZI+=1 & SET /A ARGCL+=1 & SET /A ARGM+=1
IF /I "%%A" == "PDB" SET "PDB=True" & SET /A ARGPDB+=1
IF /I "%%A" == "Sign" SET "SIGN=True" & SET /A ARGSIGN+=1
)
REM pre-build checks
IF NOT EXIST "revision.h" CALL "update_revision.cmd"
IF EXIST "environments.bat" CALL "environments.bat"
IF NOT DEFINED MPCBE_MINGW GOTO MissingVar
IF NOT DEFINED MPCBE_MSYS GOTO MissingVar
FOR %%X IN (%*) DO SET /A INPUT+=1
SET /A VALID=%ARGB%+%ARGPL%+%ARGC%+%ARGBC%+%ARGPA%+%ARGIN%+%ARGZI%+%ARGSIGN%+%ARGCOMP%+%ARGPDB%
IF %VALID% NEQ %INPUT% GOTO UnsupportedSwitch
IF %ARGB% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGB% == 0 (SET "BUILDTYPE=Build")
IF %ARGPL% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGPL% == 0 (SET "BUILDPLATFORM=Both")
IF %ARGC% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGC% == 0 (SET "CONFIG=MPCBE")
IF %ARGBC% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGBC% == 0 (SET "BUILDCFG=Release")
IF %ARGPA% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGPA% == 0 (SET "PACKAGES=False")
IF %ARGIN% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGIN% == 0 (SET "INSTALLER=False")
IF %ARGZI% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGZI% == 0 (SET "ZIP=False")
IF %ARGCOMP% GTR 1 (GOTO UnsupportedSwitch)
IF %ARGCL% GTR 1 (GOTO UnsupportedSwitch)
IF %ARGD% GTR 1 (GOTO UnsupportedSwitch)
IF %ARGF% GTR 1 (GOTO UnsupportedSwitch)
IF %ARGM% GTR 1 (GOTO UnsupportedSwitch)
IF /I "%PACKAGES%" == "True" SET "INSTALLER=True" & SET "ZIP=True"
IF NOT EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" GOTO MissingVar
SET "PARAMS=-property installationPath -requires Microsoft.Component.MSBuild Microsoft.VisualStudio.Component.VC.ATLMFC Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
IF /I "%COMPILER%" == "VS2017" (
SET "PARAMS=%PARAMS% -version [15.0,16.0^)"
) ELSE IF /I "%COMPILER%" == "VS2022" (
SET "PARAMS=%PARAMS% -latest -prerelease -version [,17.0)"
) ELSE (
SET "PARAMS=%PARAMS% -latest"
)
SET "VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" %PARAMS%"
FOR /f "delims=" %%A IN ('!VSWHERE!') DO SET "VCVARS=%%A\Common7\Tools\vsdevcmd.bat"
IF NOT EXIST "%VCVARS%" GOTO MissingVar
SET "BIN=_bin"
IF /I "%SIGN%" == "True" (
IF NOT EXIST "%~dp0contrib\signinfo.txt" (
ECHO WARNING: signinfo.txt not found.
SET "SIGN=False"
)
)
:Start
REM Check if the %LOG_DIR% folder exists otherwise MSBuild will fail
SET "LOG_DIR=%BIN%\logs"
IF NOT EXIST "%LOG_DIR%" MD "%LOG_DIR%"
CALL :SubDetectWinArch
SET "MSBUILD_SWITCHES=/nologo /consoleloggerparameters:Verbosity=minimal /maxcpucount /nodeReuse:true"
SET START_TIME=%TIME%
SET START_DATE=%DATE%
IF /I "%BUILDPLATFORM%" == "Win32" (GOTO Win32) ELSE IF /I "%BUILDPLATFORM%" == "x64" (GOTO x64)
:Win32
CALL "%VCVARS%" -no_logo -arch=x86
REM again set the source directory (fix possible bug in VS2017)
CD /D %~dp0
IF /I "%CONFIG%" == "Filters" (
CALL :SubFilters Win32
IF /I "%ZIP%" == "True" CALL :SubCreatePackages Filters Win32
GOTO x64
)
IF /I "%CONFIG%" == "Resources" CALL :SubResources Win32 && GOTO x64
CALL :SubMPCBE Win32
IF /I "%CONFIG%" == "Main" GOTO x64
CALL :SubResources Win32
IF /I "%INSTALLER%" == "True" CALL :SubCreateInstaller Win32
IF /I "%ZIP%" == "True" CALL :SubCreatePackages MPC-BE Win32
IF /I "%CONFIG%" == "All" (
CALL :SubFilters Win32
IF /I "%ZIP%" == "True" CALL :SubCreatePackages Filters Win32
)
:x64
IF /I "%BUILDPLATFORM%" == "Win32" GOTO End
CALL "%VCVARS%" -no_logo -arch=amd64
REM again set the source directory (fix possible bug in VS2017)
CD /D %~dp0
IF /I "%CONFIG%" == "Filters" (
CALL :SubFilters x64
IF /I "%ZIP%" == "True" CALL :SubCreatePackages Filters x64
GOTO END
)
IF /I "%CONFIG%" == "Resources" CALL :SubResources x64 && GOTO END
CALL :SubMPCBE x64
IF /I "%CONFIG%" == "Main" GOTO End
CALL :SubResources x64
IF /I "%INSTALLER%" == "True" CALL :SubCreateInstaller x64
IF /I "%ZIP%" == "True" CALL :SubCreatePackages MPC-BE x64
IF /I "%CONFIG%" == "All" (
CALL :SubFilters x64
IF /I "%ZIP%" == "True" CALL :SubCreatePackages Filters x64
)
:End
TITLE Compiling MPC-BE [FINISHED]
SET END_TIME=%TIME%
CALL :SubGetDuration
CALL :SubMsg "INFO" "Compilation started on %START_DATE%-%START_TIME% and completed on %DATE%-%END_TIME% [%DURATION%]"
ENDLOCAL
EXIT /B
:SubFilters
TITLE Compiling MPC-BE Filters - %BUILDCFG% Filter^|%1...
MSBuild.exe mpc-be.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration="%BUILDCFG% Filter";Platform=%1^
/flp1:LogFile=%LOG_DIR%\filters_errors_%BUILDCFG%_%1.log;errorsonly;Verbosity=diagnostic^
/flp2:LogFile=%LOG_DIR%\filters_warnings_%BUILDCFG%_%1.log;warningsonly;Verbosity=diagnostic
IF %ERRORLEVEL% NEQ 0 (
CALL :SubMsg "ERROR" "mpc-be.sln %BUILDCFG% Filter %1 - Compilation failed!"
) ELSE (
CALL :SubMsg "INFO" "mpc-be.sln %BUILDCFG% Filter %1 compiled successfully"
)
IF /I "%1" == "Win32" (
SET "DIR=%BIN%\Filters_x86"
) ELSE (
SET "DIR=%BIN%\Filters_x64"
)
IF /I "%SIGN%" == "True" (
CALL :SubSign %DIR% *.ax
)
EXIT /B
:SubMPCBE
TITLE Compiling MPC-BE - %BUILDCFG%^|%1...
MSBuild.exe mpc-be.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration=%BUILDCFG%;Platform=%1^
/flp1:LogFile=%LOG_DIR%\mpc-be_errors_%BUILDCFG%_%1.log;errorsonly;Verbosity=diagnostic^
/flp2:LogFile=%LOG_DIR%\mpc-be_warnings_%BUILDCFG%_%1.log;warningsonly;Verbosity=diagnostic
IF %ERRORLEVEL% NEQ 0 (
CALL :SubMsg "ERROR" "mpc-be.sln %BUILDCFG% %1 - Compilation failed!"
) ELSE (
CALL :SubMsg "INFO" "mpc-be.sln %BUILDCFG% %1 compiled successfully"
)
TITLE Compiling mpciconlib - %BUILDCFG%^|%1...
MSBuild.exe mpciconlib.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration=%BUILDCFG%;Platform=%1^
/flp1:LogFile=%LOG_DIR%\mpciconlib_errors_%BUILDCFG%_%1.log;errorsonly;Verbosity=diagnostic^
/flp2:LogFile=%LOG_DIR%\mpciconlib_warnings_%BUILDCFG%_%1.log;warningsonly;Verbosity=diagnostic
IF %ERRORLEVEL% NEQ 0 (
CALL :SubMsg "ERROR" "mpciconlib.sln %BUILDCFG% %1 - Compilation failed!"
) ELSE (
CALL :SubMsg "INFO" "mpciconlib.sln %BUILDCFG% %1 compiled successfully"
)
IF /I "%1" == "Win32" (
SET "DIR=%BIN%\mpc-be_x86"
) ELSE (
SET "DIR=%BIN%\mpc-be_x64"
)
IF /I "%SIGN%" == "True" (
CALL :SubSign %DIR% mpc-be*.exe
CALL :SubSign %DIR% mpciconlib*.dll
)
TITLE Compiling MPCBEShellExt - %BUILDCFG%...
MSBuild.exe MPCBEShellExt.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration=%BUILDCFG%;Platform=Win32
IF %ERRORLEVEL% NEQ 0 (
CALL :SubMsg "ERROR" "MPCBEShellExt.sln %BUILDCFG% Win32 - Compilation failed!"
) ELSE (
CALL :SubMsg "INFO" "MPCBEShellExt.sln %BUILDCFG% Win32 compiled successfully"
)
SET "DIR=%BIN%\mpc-be_x86"
IF /I "%SIGN%" == "True" (
CALL :SubSign %DIR% MPCBEShellExt.dll
)
MSBuild.exe MPCBEShellExt.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration=%BUILDCFG%;Platform=x64
IF %ERRORLEVEL% NEQ 0 (
CALL :SubMsg "ERROR" "MPCBEShellExt.sln %BUILDCFG% x64 - Compilation failed!"
) ELSE (
CALL :SubMsg "INFO" "MPCBEShellExt.sln %BUILDCFG% x64 compiled successfully"
)
SET "DIR=%BIN%\mpc-be_x64"
IF /I "%SIGN%" == "True" (
CALL :SubSign %DIR% MPCBEShellExt64.dll
)
EXIT /B
:SubResources
IF /I "%BUILDCFG%" == "Debug" (
CALL :SubMsg "WARNING" "/debug was used, resources will not be built."
EXIT /B
)
FOR %%A IN ("Armenian" "Basque" "Belarusian" "Catalan" "Chinese Simplified"
"Chinese Traditional" "Czech" "Croatian" "Dutch" "French" "German" "Greek" "Hebrew" "Hungarian"
"Italian" "Japanese" "Korean" "Polish" "Portuguese" "Romanian" "Russian" "Slovak" "Spanish"
"Swedish" "Turkish" "Ukrainian"
) DO (
TITLE Compiling mpcresources - %%~A^|%1...
MSBuild.exe mpcresources.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration="Release %%~A";Platform=%1
IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Compilation failed!"
)
IF /I "%1" == "Win32" (
SET "DIR=%BIN%\mpc-be_x86\Lang"
) ELSE (
SET "DIR=%BIN%\mpc-be_x64\Lang"
)
IF /I "%SIGN%" == "True" (
CALL :SubSign %DIR% mpcresources.??.dll
)
EXIT /B
:SubSign
IF %ERRORLEVEL% NEQ 0 EXIT /B
REM %1 is a path
REM %2 is mask of the files to sign
PUSHD "%~1"
SET FILES=
FOR /F "delims=" %%A IN ('DIR "%2" /b') DO (
IF "!FILES!" == "" (
SET FILES=%%A
) ELSE (
SET FILES=!FILES! %%A
)
)
CALL "%~dp0contrib\sign.cmd" %FILES% || (CALL :SubMsg "ERROR" "Problem signing %FILES%" & GOTO Break)
CALL :SubMsg "INFO" "%2 signed successfully."
:Break
POPD
EXIT /B
:SubCreateInstaller
IF "%~1" == "Win32" (SET ISDefs=/DWin32Build) ELSE (SET ISDefs=)
IF /I "%SIGN%" == "True" SET ISDefsSign=/DSign
CALL :SubDetectInnoSetup
IF NOT DEFINED InnoSetupPath (
CALL :SubMsg "WARNING" "Inno Setup wasn't found, the %1 installer wasn't built"
EXIT /B
)
TITLE Compiling %1 installer...
"%InnoSetupPath%\iscc.exe" /Q /O"%BIN%" "distrib\mpc-be_setup.iss" %ISDefs% %ISDefsSign%
IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Compilation failed!"
CALL :SubMsg "INFO" "%1 installer successfully built"
CALL :SubGetVersion
IF /I "%~1" == "Win32" (
SET ARCH=x86
) ELSE (
SET ARCH=x64
)
EXIT /B
:SubCreatePackages
CALL :SubDetectSevenzipPath
CALL :SubGetVersion
IF NOT DEFINED SEVENZIP (
CALL :SubMsg "WARNING" "7-Zip wasn't found, the %1 %2 package wasn't built"
EXIT /B
)
IF /I "%~1" == "Filters" (SET "NAME=standalone_filters-mpc-be") ELSE (SET "NAME=MPC-BE")
IF /I "%~2" == "Win32" (
SET ARCH=x86
) ELSE (
SET ARCH=x64
)
PUSHD "%BIN%"
SET PackagesOut=Packages
IF NOT EXIST "%PackagesOut%\%MPCBE_VER%" MD "%PackagesOut%\%MPCBE_VER%"
SET "PCKG_NAME=%NAME%.%MPCBE_VER%.%ARCH%"
SET "ZIP_NAME=%NAME%.%MPCBE_VER%%SUFFIX_GIT%.%ARCH%"
IF EXIST "%PackagesOut%\%MPCBE_VER%\%ZIP_NAME%.7z" DEL "%PackagesOut%\%MPCBE_VER%\%ZIP_NAME%.7z"
IF EXIST "%PCKG_NAME%" RD /Q /S "%PCKG_NAME%"
TITLE Copying %PCKG_NAME%...
IF NOT EXIST "%PCKG_NAME%" MD "%PCKG_NAME%"
IF /I "%NAME%" == "MPC-BE" (
IF NOT EXIST "%PCKG_NAME%\Lang" MD "%PCKG_NAME%\Lang"
IF NOT EXIST "%PCKG_NAME%\Shaders" MD "%PCKG_NAME%\Shaders"
IF NOT EXIST "%PCKG_NAME%\Shaders11" MD "%PCKG_NAME%\Shaders11"
IF /I "%ARCH%" == "x64" (
COPY /Y /V "%~1_%ARCH%\mpc-be64.exe" "%PCKG_NAME%\mpc-be64.exe" >NUL
COPY /Y /V "%~1_%ARCH%\MPCBEShellExt64.dll" "%PCKG_NAME%\MPCBEShellExt64.dll" >NUL
COPY /Y /V "..\distrib\DirectX\x64\d3dcompiler_47.dll" "%PCKG_NAME%\d3dcompiler_47.dll" >NUL
COPY /Y /V "..\distrib\DirectX\x64\d3dx9_43.dll" "%PCKG_NAME%\d3dx9_43.dll" >NUL
COPY /Y /V "..\distrib\VisualElements\mpc-be64.VisualElementsManifest.xml" "%PCKG_NAME%" >NUL
) ELSE (
COPY /Y /V "%~1_%ARCH%\mpc-be.exe" "%PCKG_NAME%\mpc-be.exe" >NUL
COPY /Y /V "%~1_%ARCH%\MPCBEShellExt.dll" "%PCKG_NAME%\MPCBEShellExt.dll" >NUL
COPY /Y /V "..\distrib\DirectX\x86\d3dcompiler_47.dll" "%PCKG_NAME%\d3dcompiler_47.dll" >NUL
COPY /Y /V "..\distrib\DirectX\x86\d3dx9_43.dll" "%PCKG_NAME%\d3dx9_43.dll" >NUL
COPY /Y /V "..\distrib\VisualElements\mpc-be.VisualElementsManifest.xml" "%PCKG_NAME%" >NUL
)
COPY /Y /V "%~1_%ARCH%\mpciconlib.dll" "%PCKG_NAME%\mpciconlib.dll" >NUL
COPY /Y /V "%~1_%ARCH%\Lang\mpcresources.??.dll" "%PCKG_NAME%\Lang\mpcresources.??.dll" >NUL
COPY /Y /V "..\distrib\Shaders\*.hlsl" "%PCKG_NAME%\Shaders\*.hlsl" >NUL
COPY /Y /V "..\distrib\Shaders11\*.hlsl" "%PCKG_NAME%\Shaders11\*.hlsl" >NUL
COPY /Y /V "..\distrib\VisualElements\*.png" "%PCKG_NAME%" >NUL
) ELSE (
COPY /Y /V "%~1_%ARCH%\*.ax" "%PCKG_NAME%\*.ax" >NUL
)
COPY /Y /V "..\docs\COPYING.txt" "%PCKG_NAME%" >NUL
COPY /Y /V "..\docs\Authors.txt" "%PCKG_NAME%" >NUL
COPY /Y /V "..\docs\Authors mpc-hc team.txt" "%PCKG_NAME%" >NUL
COPY /Y /V "..\docs\Changelog.txt" "%PCKG_NAME%" >NUL
COPY /Y /V "..\docs\Changelog.Rus.txt" "%PCKG_NAME%" >NUL
COPY /Y /V "..\docs\Readme.txt" "%PCKG_NAME%" >NUL
IF /I "%NAME%" == "MPC-BE" (
IF /I "%INSTALLER%" == "True" (
TITLE Creating archive %ZIP_NAME%-installer.zip...
START "7z" /B /WAIT "%SEVENZIP%" a -tzip "%PackagesOut%\%MPCBE_VER%\%ZIP_NAME%-installer.zip" "%PCKG_NAME%.exe" -mx9
IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Unable to create %ZIP_NAME%-installer.zip!"
CALL :SubMsg "INFO" "%ZIP_NAME%-installer.zip successfully created"
)
)
TITLE Creating archive %ZIP_NAME%.7z...
START "7z" /B /WAIT "%SEVENZIP%" a -t7z "%PackagesOut%\%MPCBE_VER%\%ZIP_NAME%.7z" "%PCKG_NAME%"^
-m0=lzma -mx9 -mmt -ms=on
IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Unable to create %ZIP_NAME%.7z!"
CALL :SubMsg "INFO" "%ZIP_NAME%.7z successfully created"
IF EXIST "%PCKG_NAME%" RD /Q /S "%PCKG_NAME%"
IF /I "%NAME%" == "MPC-BE" IF /I "%PDB%" == "True" (
TITLE Creating archive %ZIP_NAME%-pdb.7z...
IF /I "%ARCH%" == "x64" (
START "7z" /B /WAIT "%SEVENZIP%" a -t7z "%PackagesOut%\%MPCBE_VER%\%ZIP_NAME%-pdb.7z" "%~1_%ARCH%\mpc-be64.pdb"^
-m0=lzma -mx9 -mmt -ms=on
) ELSE (
START "7z" /B /WAIT "%SEVENZIP%" a -t7z "%PackagesOut%\%MPCBE_VER%\%ZIP_NAME%-pdb.7z" "%~1_%ARCH%\mpc-be.pdb"^
-m0=lzma -mx9 -mmt -ms=on
)
)
POPD
EXIT /B
:SubGetVersion
REM Get the version
SET VerMajor=0
SET VerMinor=0
SET VerPatch=0
SET REVNUM=0
FOR /F "tokens=3,4 delims= " %%A IN (
'FINDSTR /I /L /C:"define MPC_VERSION_MAJOR" "include\Version.h"') DO (SET "VerMajor=%%A")
FOR /F "tokens=3,4 delims= " %%A IN (
'FINDSTR /I /L /C:"define MPC_VERSION_MINOR" "include\Version.h"') DO (SET "VerMinor=%%A")
FOR /F "tokens=3,4 delims= " %%A IN (
'FINDSTR /I /L /C:"define MPC_VERSION_PATCH" "include\Version.h"') DO (SET "VerPatch=%%A")
FOR /F "tokens=3,4 delims= " %%A IN (
'FINDSTR /I /L /C:"define MPC_VERSION_STATUS" "include\Version.h"') DO (SET "VERRELEASE=%%A")
FOR /F "tokens=3,4 delims= " %%A IN (
'FINDSTR /I /L /C:"define REV_NUM" "revision.h"') DO (SET "REVNUM=%%A")
FOR /F "tokens=3,4 delims= " %%A IN (
'FINDSTR /I /L /C:"define REV_DATE" "revision.h"') DO (SET "REVDATE=%%A")
FOR /F "tokens=3,4 delims= " %%A IN (
'FINDSTR /I /L /C:"define REV_HASH" "revision.h"') DO (SET "REVHASH=%%A")
SET MPCBE_VER=%VerMajor%.%VerMinor%.%VerPatch%.%REVNUM%
SET "SUFFIX_GIT=_git%REVDATE%-%REVHASH%"
IF /I "%VERRELEASE%" == "1" (
IF /I "%REVNUM%" == "0" (
SET MPCBE_VER=%VerMajor%.%VerMinor%.%VerPatch%
)
SET "SUFFIX_GIT="
)
EXIT /B
:SubDetectWinArch
IF DEFINED PROGRAMFILES(x86) (SET x64_type=amd64) ELSE (SET x64_type=x86_amd64)
EXIT /B
:SubDetectInnoSetup
REM Detect if we are running on 64bit WIN and use Wow6432Node, and set the path
REM of Inno Setup accordingly
IF /I "%x64_type%" == "amd64" (
SET "U_=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
) ELSE (
SET "U_=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
)
FOR /F "delims=" %%A IN (
'REG QUERY "%U_%\Inno Setup 6_is1" /v "Inno Setup: App Path" 2^>Nul ^|FIND "REG_SZ"') DO (
SET "InnoSetupPath=%%A" & CALL :SubInnoSetupPath %%InnoSetupPath:*Z=%%
)
EXIT /B
:SubDetectSevenzipPath
IF EXIST "%PROGRAMFILES%\7za.exe" (SET "SEVENZIP=%PROGRAMFILES%\7za.exe" & EXIT /B)
IF EXIST "7za.exe" (SET "SEVENZIP=7za.exe" & EXIT /B)
FOR %%A IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:A")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
FOR %%A IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:A")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
IF /I "%x64_type%" == "amd64" (
FOR /F "delims=" %%A IN (
'REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>Nul ^| FIND "REG_SZ"') DO (
SET "SEVENZIP_REG=%%A" & CALL :SubSevenzipPath %%SEVENZIP_REG:*REG_SZ=%%
)
)
FOR /F "delims=" %%A IN (
'REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v "Path" 2^>Nul ^| FIND "REG_SZ"') DO (
SET "SEVENZIP_REG=%%A" & CALL :SubSevenzipPath %%SEVENZIP_REG:*REG_SZ=%%
)
EXIT /B
:ShowHelp
TITLE %~nx0 Help
ECHO.
ECHO Usage:
ECHO %~nx0 [Clean^|Build^|Rebuild] [x86^|x64^|Both] [Main^|Resources^|MPCBE^|Filters^|All] [Debug^|Release] [Packages^|Installer^|Zip] [Sign]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO Debug only applies to mpc-be.sln.
ECHO The arguments are not case sensitive and can be ommitted.
ECHO. & ECHO.
ECHO Executing %~nx0 without any arguments will use the default ones:
ECHO "%~nx0 Build Both Release"
ECHO. & ECHO.
ECHO Examples:
ECHO %~nx0 x86 Resources -Builds the x86 resources
ECHO %~nx0 Resources -Builds both x86 and x64 resources
ECHO %~nx0 x86 -Builds x86 Main exe and the x86 resources
ECHO %~nx0 x86 Debug -Builds x86 Main Debug exe and x86 resources
ECHO %~nx0 x86 Filters -Builds x86 Filters
ECHO %~nx0 x86 All -Builds x86 Main exe, x86 Filters and the x86 resources
ECHO %~nx0 x86 Packages -Builds x86 Main exe, x86 resources and creates the installer and the .7z package
ECHO %~nx0 x86 Sign -Builds x86 Main exe and the x86 resources and signing output files
ECHO.
ENDLOCAL
EXIT /B
:MissingVar
COLOR 0C
TITLE Compiling MPC-BE [ERROR]
ECHO Not all build dependencies were found.
ECHO.
ECHO See "docs\Compilation.txt" for more information.
ECHO. & ECHO.
ECHO Press any key to exit...
PAUSE >NUL
ENDLOCAL
EXIT /B
:UnsupportedSwitch
ECHO.
ECHO Unsupported commandline switch!
ECHO.
ECHO "build.bat %*"
ECHO.
ECHO Run "%~nx0 help" for details about the commandline switches.
CALL :SubMsg "ERROR" "Compilation failed!"
:SubInnoSetupPath
SET InnoSetupPath=%*
EXIT /B
:SubSevenzipPath
SET "SEVENZIP=%*\7z.exe"
EXIT /B
:SubMsg
ECHO. & ECHO ------------------------------
IF /I "%~1" == "ERROR" (
CALL :SubColorText "0C" "[%~1]" & ECHO %~2
) ELSE IF /I "%~1" == "INFO" (
CALL :SubColorText "0A" "[%~1]" & ECHO %~2
) ELSE IF /I "%~1" == "WARNING" (
CALL :SubColorText "0E" "[%~1]" & ECHO %~2
)
ECHO ------------------------------ & ECHO.
IF /I "%~1" == "ERROR" (
ECHO Press any key to close this window...
PAUSE >NUL
ENDLOCAL
EXIT
) ELSE (
EXIT /B
)
:SubColorText
FOR /F "tokens=1,2 delims=#" %%A IN (
'"PROMPT #$H#$E# & ECHO ON & FOR %%B IN (1) DO REM"') DO (
SET "DEL=%%A")
<NUL SET /p ".=%DEL%" > "%~2"
FINDSTR /v /a:%1 /R ".18" "%~2" NUL
DEL "%~2" > NUL 2>&1
EXIT /B
:SubGetDuration
SET START_TIME=%START_TIME: =%
SET END_TIME=%END_TIME: =%
FOR /F "tokens=1-4 delims=:.," %%A IN ("%START_TIME%") DO (
SET /A "STARTTIME=(100%%A %% 100) * 360000 + (100%%B %% 100) * 6000 + (100%%C %% 100) * 100 + (100%%D %% 100)"
)
FOR /F "tokens=1-4 delims=:.," %%A IN ("%END_TIME%") DO (
SET /A "ENDTIME=(100%%A %% 100) * 360000 + (100%%B %% 100) * 6000 + (100%%C %% 100) * 100 + (100%%D %% 100)"
)
SET /A DURATION=%ENDTIME%-%STARTTIME%
IF %ENDTIME% LSS %STARTTIME% SET /A "DURATION+=24 * 360000"
SET /A DURATIONH=%DURATION% / 360000
SET /A DURATIONM=(%DURATION% - %DURATIONH%*360000) / 6000
SET /A DURATIONS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000) / 100
SET /A DURATIONHS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000 - %DURATIONS%*100)*10
IF %DURATIONH% EQU 0 (SET DURATIONH=) ELSE (SET DURATIONH=%DURATIONH%h )
IF %DURATIONM% EQU 0 (SET DURATIONM=) ELSE (SET DURATIONM=%DURATIONM%m )
IF %DURATIONS% EQU 0 (SET DURATIONS=) ELSE (SET DURATIONS=%DURATIONS%s )
IF %DURATIONHS% EQU 0 (SET DURATIONHS=) ELSE (SET DURATIONHS=%DURATIONHS%ms)
SET "DURATION=%DURATIONH%%DURATIONM%%DURATIONS%%DURATIONHS%"
EXIT /B