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\GnuWin32\date.exe" BuildError
54 for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\..\Prerequisites\GnuWin32\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\GnuWin32\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 ///////////////////////////////////////////////////////////////////////////
154 REM ///////////////////////////////////////////////////////////////////////////
155 :: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\x264_launcher.exe"
156 :: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\MUtils32-1.dll"
157 :: "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\Qt*.dll"
159 REM ///////////////////////////////////////////////////////////////////////////
161 REM ///////////////////////////////////////////////////////////////////////////
162 attrib +R "%PACK_PATH%\*.exe"
163 attrib +R "%PACK_PATH%\*.dll"
164 attrib +R "%PACK_PATH%\*.txt"
165 attrib +R "%PACK_PATH%\*.html"
167 REM ///////////////////////////////////////////////////////////////////////////
168 REM // Setup install parameters
169 REM ///////////////////////////////////////////////////////////////////////////
170 mkdir "%~dp0\out" 2> NUL
171 set "OUT_PATH=%~dp0\out\x264_launcher.%ISO_DATE%"
173 if exist "%OUT_PATH%.exe" (
174 set "OUT_PATH=%OUT_PATH%.new"
175 goto GenerateOutfileName
177 if exist "%OUT_PATH%.sfx" (
178 set "OUT_PATH=%OUT_PATH%.new"
179 goto GenerateOutfileName
181 if exist "%OUT_PATH%.zip" (
182 set "OUT_PATH=%OUT_PATH%.new"
183 goto GenerateOutfileName
186 REM ///////////////////////////////////////////////////////////////////////////
188 REM ///////////////////////////////////////////////////////////////////////////
189 echo Simple x264/x265 Launcher - graphical front-end for x264 and x265 > "%PACK_PATH%\BUILD_TAG.txt"
190 echo Copyright (C) 2004-2019 LoRd_MuldeR ^<MuldeR2@GMX.de^> >> "%PACK_PATH%\BUILD_TAG.txt"
191 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
192 echo Build #%BUILD_NO%, created on %ISO_DATE% at %ISO_TIME% >> "%PACK_PATH%\BUILD_TAG.txt"
193 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
194 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
195 "%~dp0\..\Prerequisites\GnuWin32\cat.exe" "%~dp0\etc\setup\build.nfo" >> "%PACK_PATH%\BUILD_TAG.txt"
197 REM ///////////////////////////////////////////////////////////////////////////
198 REM // Build the installer
199 REM ///////////////////////////////////////////////////////////////////////////
200 "%~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"
201 if not "%ERRORLEVEL%"=="0" goto BuildError
203 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.sfx"
204 if not "%ERRORLEVEL%"=="0" goto BuildError
206 call "%~dp0\..\Prerequisites\SevenZip\7zSD.cmd" "%OUT_PATH%.sfx" "%OUT_PATH%.exe" "Simple x264/x265 Launcher" "x264_launcher-setup-r%BUILD_NO%"
207 if not "%ERRORLEVEL%"=="0" goto BuildError
209 set "VERPATCH_PRODUCT=Simple x264/x265 Launcher (Setup)"
210 set "VERPATCH_FILEVER=%ISO_DATE:-=.%.%BUILD_NO%"
211 "%~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-2019 LoRd_MuldeR" /s company "Free Software Foundation"
212 if not "%ERRORLEVEL%"=="0" goto BuildError
214 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.exe"
215 if not "%ERRORLEVEL%"=="0" goto BuildError
217 attrib +R "%OUT_PATH%.exe"
218 attrib +R "%OUT_PATH%.sfx"
220 REM ///////////////////////////////////////////////////////////////////////////
221 REM // Build ZIP package
222 REM ///////////////////////////////////////////////////////////////////////////
224 "%~dp0\..\Prerequisites\GnuWin32\zip.exe" -r -9 -z "%OUT_PATH%.zip" "*.*" < "%PACK_PATH%\BUILD_TAG.txt"
227 if not "%ERRORLEVEL%"=="0" goto BuildError
228 attrib +R "%OUT_PATH%.zip"
230 REM ///////////////////////////////////////////////////////////////////////////
232 REM ///////////////////////////////////////////////////////////////////////////
233 rmdir /Q /S "%PACK_PATH%"
235 REM ///////////////////////////////////////////////////////////////////////////
237 REM ///////////////////////////////////////////////////////////////////////////
239 echo Build completed.
244 REM ///////////////////////////////////////////////////////////////////////////
246 REM ///////////////////////////////////////////////////////////////////////////
249 echo Build has failed !!!