2 REM ///////////////////////////////////////////////////////////////////////////
4 REM ///////////////////////////////////////////////////////////////////////////
5 set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build"
7 set "SLN_FNAME=x264_launcher_MSVC2019.sln"
9 REM ###############################################
10 REM # DO NOT MODIFY ANY LINES BELOW THIS LINE !!! #
11 REM ###############################################
13 REM ///////////////////////////////////////////////////////////////////////////
14 REM // Setup environment
15 REM ///////////////////////////////////////////////////////////////////////////
16 if exist "%QTVC_PATH%\bin\qtvars.bat" ( call "%QTVC_PATH%\bin\qtvars.bat" )
17 if exist "%QTVC_PATH%\bin\qtenv2.bat" ( call "%QTVC_PATH%\bin\qtenv2.bat" )
18 call "%MSVC_PATH%\vcvarsall.bat" x86
20 REM ///////////////////////////////////////////////////////////////////////////
21 REM // Check environment
22 REM ///////////////////////////////////////////////////////////////////////////
23 if "%VCINSTALLDIR%"=="" (
24 echo %%VCINSTALLDIR%% not specified. Please check your MSVC_PATH var!
27 if not exist "%VCToolsInstallDir%\bin\HostX86\x86\cl.exe" (
28 echo C++ compiler not found. Please check your MSVC_PATH var!
32 echo %%QTDIR%% not specified. Please check your QTDIR var!
35 if not exist "%QTDIR%\bin\moc.exe" (
36 echo Qt meta compiler not found. Please check your QTDIR var!
39 if not exist "%QTDIR%\include\QtCore\qglobal.h" (
40 echo %%QTDIR%% header files not found. Please check your QTDIR var!
43 if not exist "%JAVA_HOME%\bin\java.exe" (
44 echo Java runtime not found. Please check your JAVA_HOME var!
48 REM ///////////////////////////////////////////////////////////////////////////
49 REM // Get current date and time (in ISO format)
50 REM ///////////////////////////////////////////////////////////////////////////
53 if not exist "%~dp0\..\Prerequisites\MSYS\1.0\bin\date.exe" goto BuildError
54 for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\..\Prerequisites\MSYS\1.0\bin\date.exe" +ISODATE:%%Y-%%m-%%d') do (
55 if "%%a"=="ISODATE" set "ISO_DATE=%%b"
57 for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\..\Prerequisites\MSYS\1.0\bin\date.exe" +ISOTIME:%%T') do (
58 if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
60 if "%ISO_DATE%"=="" goto BuildError
61 if "%ISO_TIME%"=="" goto BuildError
63 REM ///////////////////////////////////////////////////////////////////////////
64 REM // Clean up temp files
65 REM ///////////////////////////////////////////////////////////////////////////
66 echo ---------------------------------------------------------------------
68 echo ---------------------------------------------------------------------
69 for %%i in (bin,obj,tmp) do (
70 del /Q /S /F "%~dp0\%%i\*.*"
73 REM ///////////////////////////////////////////////////////////////////////////
74 REM // Build the binaries
75 REM ///////////////////////////////////////////////////////////////////////////
76 echo ---------------------------------------------------------------------
78 echo ---------------------------------------------------------------------
79 MSBuild.exe /property:Configuration=release /property:Platform=win32 /target:clean "%~dp0\%SLN_FNAME%"
80 if not "%ERRORLEVEL%"=="0" goto BuildError
81 MSBuild.exe /property:Configuration=release /property:Platform=win32 /target:rebuild "%~dp0\%SLN_FNAME%"
82 if not "%ERRORLEVEL%"=="0" goto BuildError
84 REM ///////////////////////////////////////////////////////////////////////////
85 REM // Detect build number
86 REM ///////////////////////////////////////////////////////////////////////////
88 for /F "tokens=2,*" %%s in (%~dp0\src\version.h) do (
89 if "%%s"=="VER_X264_BUILD" set "BUILD_NO=%%~t"
91 if "%BUILD_NO%"=="" goto BuildError
93 REM ///////////////////////////////////////////////////////////////////////////
94 REM // Copy base files
95 REM ///////////////////////////////////////////////////////////////////////////
96 echo ---------------------------------------------------------------------
98 echo ---------------------------------------------------------------------
99 set "PACK_PATH=%TMP%\~%RANDOM%%RANDOM%.tmp"
101 mkdir "%PACK_PATH%\imageformats"
102 mkdir "%PACK_PATH%\toolset\common"
103 mkdir "%PACK_PATH%\toolset\x86"
104 mkdir "%PACK_PATH%\toolset\x64"
105 mkdir "%PACK_PATH%\toolset\x86\nvencc"
106 mkdir "%PACK_PATH%\toolset\x64\nvencc"
107 mkdir "%PACK_PATH%\sources"
108 copy "%~dp0\bin\Win32\Release\x264_launcher.exe" "%PACK_PATH%"
109 copy "%~dp0\bin\Win32\Release\MUtils32-?.dll" "%PACK_PATH%"
110 copy "%~dp0\res\toolset\*.txt" "%PACK_PATH%\toolset"
111 copy "%~dp0\res\toolset\common\*.exe" "%PACK_PATH%\toolset\common"
112 copy "%~dp0\res\toolset\common\*.gpg" "%PACK_PATH%\toolset\common"
113 copy "%~dp0\res\toolset\x86\*.exe" "%PACK_PATH%\toolset\x86"
114 copy "%~dp0\res\toolset\x86\*.dll" "%PACK_PATH%\toolset\x86"
115 copy "%~dp0\res\toolset\x64\*.exe" "%PACK_PATH%\toolset\x64"
116 copy "%~dp0\res\toolset\x64\*.dll" "%PACK_PATH%\toolset\x64"
117 copy "%~dp0\res\toolset\x86\nvencc\*.exe" "%PACK_PATH%\toolset\x86\nvencc\"
118 copy "%~dp0\res\toolset\x86\nvencc\*.dll" "%PACK_PATH%\toolset\x86\nvencc\"
119 copy "%~dp0\res\toolset\x64\nvencc\*.exe" "%PACK_PATH%\toolset\x64\nvencc\"
120 copy "%~dp0\res\toolset\x64\nvencc\*.dll" "%PACK_PATH%\toolset\x64\nvencc\"
121 copy "%~dp0\etc\sources\*.xz" "%PACK_PATH%\sources"
122 copy "%~dp0\etc\sources\*.txt" "%PACK_PATH%\sources"
123 copy "%~dp0\LICENSE.html" "%PACK_PATH%"
124 copy "%~dp0\*.txt" "%PACK_PATH%"
126 REM ///////////////////////////////////////////////////////////////////////////
127 REM // Copy dependencies
128 REM ///////////////////////////////////////////////////////////////////////////
129 if %TOOLS_VER% GEQ 142 (
130 set "PATH_REDIST_QT=%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%"
131 set "PATH_REDIST_VC=%~dp0\..\Prerequisites\MSVC\redist\vc\v%TOOLS_VER%"
133 set "PATH_REDIST_QT=%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp"
134 set "PATH_REDIST_VC=%~dp0\..\Prerequisites\MSVC\redist\vc\v%TOOLS_VER%_xp"
136 copy "%PATH_REDIST_VC%\x86\*.dll" "%PACK_PATH%"
137 copy "%PATH_REDIST_QT%\Shared\bin\QtCore4.dll" "%PACK_PATH%"
138 copy "%PATH_REDIST_QT%\Shared\bin\QtGui4.dll" "%PACK_PATH%"
139 copy "%PATH_REDIST_QT%\Shared\bin\QtSvg4.dll" "%PACK_PATH%"
140 copy "%PATH_REDIST_QT%\Shared\bin\QtXml4.dll" "%PACK_PATH%"
141 copy "%PATH_REDIST_QT%\Shared\plugins\imageformats\*.dll" "%PACK_PATH%\imageformats"
142 del "%PACK_PATH%\imageformats\*d4.dll" 2> NUL
143 if %TOOLS_VER% GEQ 140 (
144 copy "%~dp0\..\Prerequisites\MSVC\redist\ucrt\DLLs\x86\*.dll" "%PACK_PATH%"
147 REM ///////////////////////////////////////////////////////////////////////////
149 REM ///////////////////////////////////////////////////////////////////////////
150 "%~dp0\..\Prerequisites\Pandoc\pandoc.exe" --from markdown_github+pandoc_title_block+header_attributes+implicit_figures --to html5 --toc -N --standalone -H "%~dp0\etc\css\style.inc" "%~dp0\README.md" | "%JAVA_HOME%\bin\java.exe" -jar "%~dp0\..\Prerequisites\HTMLCompressor\bin\htmlcompressor-1.5.3.jar" --compress-css -o "%PACK_PATH%\README.html"
152 REM ///////////////////////////////////////////////////////////////////////////
153 REM // Cleanse binaries
154 REM ///////////////////////////////////////////////////////////////////////////
155 "..\Prerequisites\RichHeaderEraser\rchhdrrsr.exe" "%PACK_PATH%\*.exe" "%PACK_PATH%\MUtils32*.dll" "%PACK_PATH%\Qt*.dll"
157 :: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\x264_launcher.exe"
158 :: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\MUtils32-1.dll"
159 :: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\Qt*.dll"
161 REM ///////////////////////////////////////////////////////////////////////////
163 REM ///////////////////////////////////////////////////////////////////////////
164 attrib +R "%PACK_PATH%\*.exe"
165 attrib +R "%PACK_PATH%\*.dll"
166 attrib +R "%PACK_PATH%\*.txt"
167 attrib +R "%PACK_PATH%\*.html"
169 REM ///////////////////////////////////////////////////////////////////////////
170 REM // Setup install parameters
171 REM ///////////////////////////////////////////////////////////////////////////
172 mkdir "%~dp0\out" 2> NUL
173 set "OUT_PATH=%~dp0\out\x264_launcher.%ISO_DATE%"
175 if exist "%OUT_PATH%.exe" (
176 set "OUT_PATH=%OUT_PATH%.new"
177 goto GenerateOutfileName
179 if exist "%OUT_PATH%.sfx" (
180 set "OUT_PATH=%OUT_PATH%.new"
181 goto GenerateOutfileName
183 if exist "%OUT_PATH%.zip" (
184 set "OUT_PATH=%OUT_PATH%.new"
185 goto GenerateOutfileName
188 REM ///////////////////////////////////////////////////////////////////////////
190 REM ///////////////////////////////////////////////////////////////////////////
191 echo Simple x264/x265 Launcher - graphical front-end for x264 and x265 > "%PACK_PATH%\BUILD_TAG.txt"
192 echo Copyright (C) 2004-2020 LoRd_MuldeR ^<MuldeR2@GMX.de^> >> "%PACK_PATH%\BUILD_TAG.txt"
193 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
194 echo Build #%BUILD_NO%, created on %ISO_DATE% at %ISO_TIME% >> "%PACK_PATH%\BUILD_TAG.txt"
195 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
196 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
197 "%~dp0\..\Prerequisites\MSYS\1.0\bin\cat.exe" "%~dp0\etc\setup\build.nfo" >> "%PACK_PATH%\BUILD_TAG.txt"
199 REM ///////////////////////////////////////////////////////////////////////////
200 REM // Build the installer
201 REM ///////////////////////////////////////////////////////////////////////////
202 "%~dp0\..\Prerequisites\NSIS\makensis.exe" "/DX264_DATE=%ISO_DATE%" "/DX264_BUILD=%BUILD_NO%" "/DX264_OUTPUT_FILE=%OUT_PATH%.sfx" "/DX264_SOURCE_PATH=%PACK_PATH%" "%~dp0\etc\setup\setup.nsi"
203 if not "%ERRORLEVEL%"=="0" goto BuildError
205 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.sfx"
206 if not "%ERRORLEVEL%"=="0" goto BuildError
208 call "%~dp0\..\Prerequisites\SevenZip\7zSDex.cmd" "%OUT_PATH%.sfx" "%OUT_PATH%.exe" "Simple x264/x265 Launcher" "x264-setup-r%BUILD_NO%"
209 if not "%ERRORLEVEL%"=="0" goto BuildError
211 set "VERPATCH_PRODUCT=Simple x264/x265 Launcher (Setup)"
212 set "VERPATCH_FILEVER=%ISO_DATE:-=.%.%BUILD_NO%"
213 "%~dp0\..\Prerequisites\VerPatch\verpatch.exe" "%OUT_PATH%.exe" "%VERPATCH_FILEVER%" /pv "%VERPATCH_FILEVER%" /fn /s desc "%VERPATCH_PRODUCT%" /s product "%VERPATCH_PRODUCT%" /s title "x264 Launcher Installer SFX" /s copyright "Copyright (C) 2004-2020 LoRd_MuldeR" /s company "Free Software Foundation"
214 if not "%ERRORLEVEL%"=="0" goto BuildError
216 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.exe"
217 if not "%ERRORLEVEL%"=="0" goto BuildError
219 attrib +R "%OUT_PATH%.exe"
220 attrib +R "%OUT_PATH%.sfx"
222 REM ///////////////////////////////////////////////////////////////////////////
223 REM // Build ZIP package
224 REM ///////////////////////////////////////////////////////////////////////////
226 "%~dp0\..\Prerequisites\InfoZip\zip.exe" -r -9 -z "%OUT_PATH%.zip" "*.*" < "%PACK_PATH%\BUILD_TAG.txt"
229 if not "%ERRORLEVEL%"=="0" goto BuildError
230 attrib +R "%OUT_PATH%.zip"
232 REM ///////////////////////////////////////////////////////////////////////////
234 REM ///////////////////////////////////////////////////////////////////////////
235 rmdir /Q /S "%PACK_PATH%"
237 REM ///////////////////////////////////////////////////////////////////////////
239 REM ///////////////////////////////////////////////////////////////////////////
241 echo Build completed.
246 REM ///////////////////////////////////////////////////////////////////////////
248 REM ///////////////////////////////////////////////////////////////////////////
251 echo Build has failed !!!