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!
42 if not exist "%JAVA_HOME%\bin\java.exe" (
43 echo Java runtime not found. Please check your JAVA_HOME var!
47 REM ///////////////////////////////////////////////////////////////////////////
48 REM // Get current date and time (in ISO format)
49 REM ///////////////////////////////////////////////////////////////////////////
52 if not exist "%~dp0\..\Prerequisites\GnuWin32\date.exe" BuildError
53 for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\..\Prerequisites\GnuWin32\date.exe" +ISODATE:%%Y-%%m-%%d') do (
54 if "%%a"=="ISODATE" set "ISO_DATE=%%b"
56 for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\..\Prerequisites\GnuWin32\date.exe" +ISOTIME:%%T') do (
57 if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
59 if "%ISO_DATE%"=="" goto BuildError
60 if "%ISO_TIME%"=="" goto BuildError
62 REM ///////////////////////////////////////////////////////////////////////////
63 REM // Clean up temp files
64 REM ///////////////////////////////////////////////////////////////////////////
65 echo ---------------------------------------------------------------------
67 echo ---------------------------------------------------------------------
68 for %%i in (bin,obj,tmp) do (
69 del /Q /S /F "%~dp0\%%i\*.*"
72 REM ///////////////////////////////////////////////////////////////////////////
73 REM // Build the binaries
74 REM ///////////////////////////////////////////////////////////////////////////
75 echo ---------------------------------------------------------------------
77 echo ---------------------------------------------------------------------
78 MSBuild.exe /property:Configuration=release /property:Platform=win32 /target:clean "%~dp0\x264_launcher_MSVC2017.sln"
79 if not "%ERRORLEVEL%"=="0" goto BuildError
80 MSBuild.exe /property:Configuration=release /property:Platform=win32 /target:rebuild "%~dp0\x264_launcher_MSVC2017.sln"
81 if not "%ERRORLEVEL%"=="0" goto BuildError
83 REM ///////////////////////////////////////////////////////////////////////////
84 REM // Detect build number
85 REM ///////////////////////////////////////////////////////////////////////////
87 for /F "tokens=2,*" %%s in (%~dp0\src\version.h) do (
88 if "%%s"=="VER_X264_BUILD" set "BUILD_NO=%%~t"
90 if "%BUILD_NO%"=="" goto BuildError
92 REM ///////////////////////////////////////////////////////////////////////////
93 REM // Copy base files
94 REM ///////////////////////////////////////////////////////////////////////////
95 echo ---------------------------------------------------------------------
97 echo ---------------------------------------------------------------------
98 set "PACK_PATH=%TMP%\~%RANDOM%%RANDOM%.tmp"
100 mkdir "%PACK_PATH%\imageformats"
101 mkdir "%PACK_PATH%\toolset\common"
102 mkdir "%PACK_PATH%\toolset\x86"
103 mkdir "%PACK_PATH%\toolset\x64"
104 mkdir "%PACK_PATH%\toolset\x86\nvencc"
105 mkdir "%PACK_PATH%\toolset\x64\nvencc"
106 mkdir "%PACK_PATH%\sources"
107 copy "%~dp0\bin\Win32\Release\x264_launcher.exe" "%PACK_PATH%"
108 copy "%~dp0\bin\Win32\Release\MUtils32-?.dll" "%PACK_PATH%"
109 copy "%~dp0\bin\Win32\Release\toolset\common\*.exe" "%PACK_PATH%\toolset\common"
110 copy "%~dp0\bin\Win32\Release\toolset\common\*.gpg" "%PACK_PATH%\toolset\common"
111 copy "%~dp0\bin\Win32\Release\toolset\x86\*.exe" "%PACK_PATH%\toolset\x86"
112 copy "%~dp0\bin\Win32\Release\toolset\x86\*.dll" "%PACK_PATH%\toolset\x86"
113 copy "%~dp0\bin\Win32\Release\toolset\x64\*.exe" "%PACK_PATH%\toolset\x64"
114 copy "%~dp0\bin\Win32\Release\toolset\x64\*.dll" "%PACK_PATH%\toolset\x64"
115 copy "%~dp0\bin\Win32\Release\toolset\x86\nvencc\*.exe" "%PACK_PATH%\toolset\x86\nvencc\"
116 copy "%~dp0\bin\Win32\Release\toolset\x86\nvencc\*.dll" "%PACK_PATH%\toolset\x86\nvencc\"
117 copy "%~dp0\bin\Win32\Release\toolset\x64\nvencc\*.exe" "%PACK_PATH%\toolset\x64\nvencc\"
118 copy "%~dp0\bin\Win32\Release\toolset\x64\nvencc\*.dll" "%PACK_PATH%\toolset\x64\nvencc\"
119 copy "%~dp0\etc\sources\*.xz" "%PACK_PATH%\sources"
120 copy "%~dp0\LICENSE.html" "%PACK_PATH%"
121 copy "%~dp0\*.txt" "%PACK_PATH%"
123 REM ///////////////////////////////////////////////////////////////////////////
124 REM // Copy dependencies
125 REM ///////////////////////////////////////////////////////////////////////////
126 copy "%~dp0\..\Prerequisites\MSVC\redist\vc\v%TOOLS_VER%_xp\x86\*.dll" "%PACK_PATH%"
127 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtCore4.dll" "%PACK_PATH%"
128 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtGui4.dll" "%PACK_PATH%"
129 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtSvg4.dll" "%PACK_PATH%"
130 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtXml4.dll" "%PACK_PATH%"
131 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtXml4.dll" "%PACK_PATH%"
132 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\plugins\imageformats\*.dll" "%PACK_PATH%\imageformats"
133 del "%PACK_PATH%\imageformats\*d4.dll" 2> NUL
134 if %TOOLS_VER% GEQ 140 (
135 copy "%~dp0\..\Prerequisites\MSVC\redist\ucrt\DLLs\x86\*.dll" "%PACK_PATH%"
138 REM ///////////////////////////////////////////////////////////////////////////
140 REM ///////////////////////////////////////////////////////////////////////////
141 "%~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"
143 REM ///////////////////////////////////////////////////////////////////////////
145 REM ///////////////////////////////////////////////////////////////////////////
146 "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\x264_launcher.exe"
147 "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\MUtils32-1.dll"
148 "%~dp0\..\Prerequisites\UPX\upx.exe" --best "%PACK_PATH%\Qt*.dll"
150 REM ///////////////////////////////////////////////////////////////////////////
152 REM ///////////////////////////////////////////////////////////////////////////
153 attrib +R "%PACK_PATH%\*.exe"
154 attrib +R "%PACK_PATH%\*.dll"
155 attrib +R "%PACK_PATH%\*.txt"
156 attrib +R "%PACK_PATH%\*.html"
158 REM ///////////////////////////////////////////////////////////////////////////
159 REM // Setup install parameters
160 REM ///////////////////////////////////////////////////////////////////////////
161 mkdir "%~dp0\out" 2> NUL
162 set "OUT_PATH=%~dp0\out\x264_launcher.%ISO_DATE%"
164 if exist "%OUT_PATH%.exe" (
165 set "OUT_PATH=%OUT_PATH%.new"
166 goto GenerateOutfileName
168 if exist "%OUT_PATH%.sfx" (
169 set "OUT_PATH=%OUT_PATH%.new"
170 goto GenerateOutfileName
172 if exist "%OUT_PATH%.zip" (
173 set "OUT_PATH=%OUT_PATH%.new"
174 goto GenerateOutfileName
177 REM ///////////////////////////////////////////////////////////////////////////
179 REM ///////////////////////////////////////////////////////////////////////////
180 echo Simple x264/x265 Launcher - graphical front-end for x264 and x265 > "%PACK_PATH%\BUILD_TAG.txt"
181 echo Copyright (C) 2004-2019 LoRd_MuldeR ^<MuldeR2@GMX.de^> >> "%PACK_PATH%\BUILD_TAG.txt"
182 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
183 echo Build #%BUILD_NO%, created on %ISO_DATE% at %ISO_TIME% >> "%PACK_PATH%\BUILD_TAG.txt"
184 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
185 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
186 "%~dp0\..\Prerequisites\GnuWin32\cat.exe" "%~dp0\etc\setup\build.nfo" >> "%PACK_PATH%\BUILD_TAG.txt"
188 REM ///////////////////////////////////////////////////////////////////////////
189 REM // Build the installer
190 REM ///////////////////////////////////////////////////////////////////////////
191 "%~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"
192 if not "%ERRORLEVEL%"=="0" goto BuildError
194 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.sfx"
195 if not "%ERRORLEVEL%"=="0" goto BuildError
197 call "%~dp0\..\Prerequisites\SevenZip\7zSD.cmd" "%OUT_PATH%.sfx" "%OUT_PATH%.exe" "Simple x264/x265 Launcher" "x264_launcher-setup-r%BUILD_NO%"
198 if not "%ERRORLEVEL%"=="0" goto BuildError
200 set "VERPATCH_PRODUCT=Simple x264/x265 Launcher (Setup)"
201 set "VERPATCH_FILEVER=%ISO_DATE:-=.%.%BUILD_NO%"
202 "%~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"
203 if not "%ERRORLEVEL%"=="0" goto BuildError
205 "%~dp0\..\Prerequisites\NSIS\peheader.exe" "%OUT_PATH%.exe"
206 if not "%ERRORLEVEL%"=="0" goto BuildError
208 attrib +R "%OUT_PATH%.exe"
209 attrib +R "%OUT_PATH%.sfx"
211 REM ///////////////////////////////////////////////////////////////////////////
212 REM // Build ZIP package
213 REM ///////////////////////////////////////////////////////////////////////////
215 "%~dp0\..\Prerequisites\GnuWin32\zip.exe" -r -9 -z "%OUT_PATH%.zip" "*.*" < "%PACK_PATH%\BUILD_TAG.txt"
218 if not "%ERRORLEVEL%"=="0" goto BuildError
219 attrib +R "%OUT_PATH%.zip"
221 REM ///////////////////////////////////////////////////////////////////////////
223 REM ///////////////////////////////////////////////////////////////////////////
224 rmdir /Q /S "%PACK_PATH%"
226 REM ///////////////////////////////////////////////////////////////////////////
228 REM ///////////////////////////////////////////////////////////////////////////
230 echo Build completed.
235 REM ///////////////////////////////////////////////////////////////////////////
237 REM ///////////////////////////////////////////////////////////////////////////
240 echo Build has failed !!!