2 REM ///////////////////////////////////////////////////////////////////////////
4 REM ///////////////////////////////////////////////////////////////////////////
5 set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
8 REM ###############################################
9 REM # DO NOT MODIFY ANY LINES BELOW THIS LINE !!! #
10 REM ###############################################
12 REM ///////////////////////////////////////////////////////////////////////////
13 REM // Setup environment
14 REM ///////////////////////////////////////////////////////////////////////////
15 if exist "%QTVC_PATH%\bin\qtvars.bat" ( call "%QTVC_PATH%\bin\qtvars.bat" )
16 if exist "%QTVC_PATH%\bin\qtenv2.bat" ( call "%QTVC_PATH%\bin\qtenv2.bat" )
17 call "%MSVC_PATH%\vcvarsall.bat" x86
19 REM ///////////////////////////////////////////////////////////////////////////
20 REM // Check environment
21 REM ///////////////////////////////////////////////////////////////////////////
22 if "%VCINSTALLDIR%"=="" (
23 echo %%VCINSTALLDIR%% not specified. Please check your MSVC_PATH var!
26 if not exist "%VCToolsInstallDir%\bin\HostX86\x86\cl.exe" (
27 echo C++ compiler not found. Please check your MSVC_PATH var!
31 echo %%QTDIR%% not specified. Please check your QTDIR var!
34 if not exist "%QTDIR%\bin\moc.exe" (
35 echo Qt meta compiler not found. Please check your QTDIR var!
38 if not exist "%QTDIR%\include\QtCore\qglobal.h" (
39 echo %%QTDIR%% header files not found. Please check your QTDIR var!
43 REM ///////////////////////////////////////////////////////////////////////////
44 REM // Get current date and time (in ISO format)
45 REM ///////////////////////////////////////////////////////////////////////////
48 if not exist "%~dp0\..\Prerequisites\GnuWin32\date.exe" BuildError
49 for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\..\Prerequisites\GnuWin32\date.exe" +ISODATE:%%Y-%%m-%%d') do (
50 if "%%a"=="ISODATE" set "ISO_DATE=%%b"
52 for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\..\Prerequisites\GnuWin32\date.exe" +ISOTIME:%%T') do (
53 if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
55 if "%ISO_DATE%"=="" goto BuildError
56 if "%ISO_TIME%"=="" goto BuildError
58 REM ///////////////////////////////////////////////////////////////////////////
59 REM // Clean up temp files
60 REM ///////////////////////////////////////////////////////////////////////////
61 echo ---------------------------------------------------------------------
63 echo ---------------------------------------------------------------------
64 for %%i in (bin,obj,tmp) do (
65 del /Q /S /F "%~dp0\%%i\*.*"
68 REM ///////////////////////////////////////////////////////////////////////////
69 REM // Build the binaries
70 REM ///////////////////////////////////////////////////////////////////////////
71 echo ---------------------------------------------------------------------
73 echo ---------------------------------------------------------------------
74 MSBuild.exe /property:Configuration=release /property:Platform=win32 /target:clean "%~dp0\x264_launcher_MSVC2017.sln"
75 if not "%ERRORLEVEL%"=="0" goto BuildError
76 MSBuild.exe /property:Configuration=release /property:Platform=win32 /target:rebuild "%~dp0\x264_launcher_MSVC2017.sln"
77 if not "%ERRORLEVEL%"=="0" goto BuildError
79 REM ///////////////////////////////////////////////////////////////////////////
80 REM // Detect build number
81 REM ///////////////////////////////////////////////////////////////////////////
83 for /F "tokens=2,*" %%s in (%~dp0\src\version.h) do (
84 if "%%s"=="VER_X264_BUILD" set "BUILD_NO=%%~t"
86 if "%BUILD_NO%"=="" goto BuildError
88 REM ///////////////////////////////////////////////////////////////////////////
89 REM // Copy base files
90 REM ///////////////////////////////////////////////////////////////////////////
91 echo ---------------------------------------------------------------------
93 echo ---------------------------------------------------------------------
94 set "PACK_PATH=%TMP%\~%RANDOM%%RANDOM%.tmp"
96 mkdir "%PACK_PATH%\imageformats"
97 mkdir "%PACK_PATH%\toolset\x86"
98 mkdir "%PACK_PATH%\toolset\x64"
99 mkdir "%PACK_PATH%\toolset\common"
100 mkdir "%PACK_PATH%\sources"
101 copy "%~dp0\bin\Win32\Release\x264_launcher.exe" "%PACK_PATH%"
102 copy "%~dp0\bin\Win32\Release\MUtils32-?.dll" "%PACK_PATH%"
103 copy "%~dp0\bin\Win32\Release\toolset\x86\*.exe" "%PACK_PATH%\toolset\x86"
104 copy "%~dp0\bin\Win32\Release\toolset\x86\*.dll" "%PACK_PATH%\toolset\x86"
105 copy "%~dp0\bin\Win32\Release\toolset\x64\*.exe" "%PACK_PATH%\toolset\x64"
106 copy "%~dp0\bin\Win32\Release\toolset\x64\*.dll" "%PACK_PATH%\toolset\x64"
107 copy "%~dp0\bin\Win32\Release\toolset\common\*.exe" "%PACK_PATH%\toolset\common"
108 copy "%~dp0\bin\Win32\Release\toolset\common\*.gpg" "%PACK_PATH%\toolset\common"
109 copy "%~dp0\etc\sources\*.xz" "%PACK_PATH%\sources"
110 copy "%~dp0\LICENSE.html" "%PACK_PATH%"
111 copy "%~dp0\*.txt" "%PACK_PATH%"
113 REM ///////////////////////////////////////////////////////////////////////////
114 REM // Copy dependencies
115 REM ///////////////////////////////////////////////////////////////////////////
116 copy "%~dp0\..\Prerequisites\MSVC\redist\vc\v%TOOLS_VER%_xp\x86\*.dll" "%PACK_PATH%"
117 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtCore4.dll" "%PACK_PATH%"
118 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtGui4.dll" "%PACK_PATH%"
119 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtSvg4.dll" "%PACK_PATH%"
120 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtXml4.dll" "%PACK_PATH%"
121 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtXml4.dll" "%PACK_PATH%"
122 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\plugins\imageformats\*.dll" "%PACK_PATH%\imageformats"
123 del "%PACK_PATH%\imageformats\*d4.dll" 2> NUL
124 if %TOOLS_VER% GEQ 140 (
125 copy "%~dp0\..\Prerequisites\MSVC\redist\ucrt\DLLs\x86\*.dll" "%PACK_PATH%"
128 REM ///////////////////////////////////////////////////////////////////////////
130 REM ///////////////////////////////////////////////////////////////////////////
131 "%~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" --output "%PACK_PATH%\README.html" "%~dp0\README.md"
133 REM ///////////////////////////////////////////////////////////////////////////
135 REM ///////////////////////////////////////////////////////////////////////////
136 "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\x264_launcher.exe"
137 "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\MUtils32-1.dll"
138 "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\Qt*.dll"
140 REM ///////////////////////////////////////////////////////////////////////////
142 REM ///////////////////////////////////////////////////////////////////////////
143 attrib +R "%PACK_PATH%\*.exe"
144 attrib +R "%PACK_PATH%\*.dll"
145 attrib +R "%PACK_PATH%\*.txt"
146 attrib +R "%PACK_PATH%\*.html"
148 REM ///////////////////////////////////////////////////////////////////////////
149 REM // Setup install parameters
150 REM ///////////////////////////////////////////////////////////////////////////
151 mkdir "%~dp0\out" 2> NUL
152 set "OUT_PATH=%~dp0\out\x264_launcher.%ISO_DATE%"
154 if exist "%OUT_PATH%.exe" (
155 set "OUT_PATH=%OUT_PATH%.new"
156 goto GenerateOutfileName
158 if exist "%OUT_PATH%.sfx" (
159 set "OUT_PATH=%OUT_PATH%.new"
160 goto GenerateOutfileName
162 if exist "%OUT_PATH%.zip" (
163 set "OUT_PATH=%OUT_PATH%.new"
164 goto GenerateOutfileName
167 REM ///////////////////////////////////////////////////////////////////////////
169 REM ///////////////////////////////////////////////////////////////////////////
170 echo Simple x264/x265 Launcher - graphical front-end for x264 and x265 > "%PACK_PATH%\BUILD_TAG.txt"
171 echo Copyright (C) 2004-2018 LoRd_MuldeR ^<MuldeR2@GMX.de^> >> "%PACK_PATH%\BUILD_TAG.txt"
172 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
173 echo Build #%BUILD_NO%, created on %ISO_DATE% at %ISO_TIME% >> "%PACK_PATH%\BUILD_TAG.txt"
174 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
175 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
176 "%~dp0\..\Prerequisites\GnuWin32\cat.exe" "%~dp0\etc\setup\build.nfo" >> "%PACK_PATH%\BUILD_TAG.txt"
178 REM ///////////////////////////////////////////////////////////////////////////
179 REM // Build the installer
180 REM ///////////////////////////////////////////////////////////////////////////
181 "%~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"
182 if not "%ERRORLEVEL%"=="0" goto BuildError
184 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.sfx"
185 if not "%ERRORLEVEL%"=="0" goto BuildError
187 call "%~dp0\..\Prerequisites\SevenZip\7zSD.cmd" "%OUT_PATH%.sfx" "%OUT_PATH%.exe" "Simple x264/x265 Launcher" "x264_launcher-setup-r%BUILD_NO%"
188 if not "%ERRORLEVEL%"=="0" goto BuildError
190 set "VERPATCH_PRODUCT=Simple x264/x265 Launcher (Setup)"
191 set "VERPATCH_FILEVER=%ISO_DATE:-=.%.%BUILD_NO%"
192 "%~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-2018 LoRd_MuldeR" /s company "Free Software Foundation"
193 if not "%ERRORLEVEL%"=="0" goto BuildError
195 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.exe"
196 if not "%ERRORLEVEL%"=="0" goto BuildError
198 attrib +R "%OUT_PATH%.exe"
199 attrib +R "%OUT_PATH%.sfx"
201 REM ///////////////////////////////////////////////////////////////////////////
202 REM // Build ZIP package
203 REM ///////////////////////////////////////////////////////////////////////////
205 "%~dp0\..\Prerequisites\GnuWin32\zip.exe" -r -9 -z "%OUT_PATH%.zip" "*.*" < "%PACK_PATH%\BUILD_TAG.txt"
208 if not "%ERRORLEVEL%"=="0" goto BuildError
209 attrib +R "%OUT_PATH%.zip"
211 REM ///////////////////////////////////////////////////////////////////////////
213 REM ///////////////////////////////////////////////////////////////////////////
214 rmdir /Q /S "%PACK_PATH%"
216 REM ///////////////////////////////////////////////////////////////////////////
218 REM ///////////////////////////////////////////////////////////////////////////
220 echo Build completed.
225 REM ///////////////////////////////////////////////////////////////////////////
227 REM ///////////////////////////////////////////////////////////////////////////
230 echo Build has failed !!!