OSDN Git Service

Bump x265 version.
[x264-launcher/x264-launcher.git] / z_build.bat
1 @echo off
2 REM ///////////////////////////////////////////////////////////////////////////
3 REM // Set Paths
4 REM ///////////////////////////////////////////////////////////////////////////
5 set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
6 set "WSDK_PATH=C:\Program Files (x86)\Windows Kits\10"
7 set "NSIS_PATH=C:\Program Files\NSIS\Unicode"
8 set "UPX3_PATH=C:\Program Files\UPX"
9 set "PDOC_PATH=C:\Program Files\Pandoc"
10 set "TOOLS_VER=140"
11
12 REM ###############################################
13 REM # DO NOT MODIFY ANY LINES BELOW THIS LINE !!! #
14 REM ###############################################
15
16 REM ///////////////////////////////////////////////////////////////////////////
17 REM // Setup environment
18 REM ///////////////////////////////////////////////////////////////////////////
19 call "%MSVC_PATH%\vcvarsall.bat" x86
20
21 REM ///////////////////////////////////////////////////////////////////////////
22 REM // Check environment
23 REM ///////////////////////////////////////////////////////////////////////////
24 if "%VCINSTALLDIR%"=="" (
25         echo %%VCINSTALLDIR%% not specified. Please check your MSVC_PATH var!
26         goto BuildError
27 )
28 if "%QTDIR%"=="" (
29         echo %%QTDIR%% not specified. Please check your MSVC_PATH var!
30         goto BuildError
31 )
32 if not exist "%VCINSTALLDIR%\bin\cl.exe" (
33         echo C++ compiler not found. Please check your MSVC_PATH var!
34         goto BuildError
35 )
36 if not exist "%PDOC_PATH%\pandoc.exe" (
37         echo Pandoc binary could not be found. Please check your PDOC_PATH var!
38         goto BuildError
39 )
40
41 REM ///////////////////////////////////////////////////////////////////////////
42 REM // Get current date and time (in ISO format)
43 REM ///////////////////////////////////////////////////////////////////////////
44 set "ISO_DATE="
45 set "ISO_TIME="
46 if not exist "%~dp0\etc\date.exe" BuildError
47 for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\etc\date.exe" +ISODATE:%%Y-%%m-%%d') do (
48         if "%%a"=="ISODATE" set "ISO_DATE=%%b"
49 )
50 for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\etc\date.exe" +ISOTIME:%%T') do (
51         if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
52 )
53 if "%ISO_DATE%"=="" goto BuildError
54 if "%ISO_TIME%"=="" goto BuildError
55
56 REM ///////////////////////////////////////////////////////////////////////////
57 REM // Clean up temp files
58 REM ///////////////////////////////////////////////////////////////////////////
59 echo ---------------------------------------------------------------------
60 echo CLEAN UP
61 echo ---------------------------------------------------------------------
62 for %%i in (bin,obj,tmp) do (
63         del /Q /S /F "%~dp0\%%i\*.*"
64 )
65
66 REM ///////////////////////////////////////////////////////////////////////////
67 REM // Build the binaries
68 REM ///////////////////////////////////////////////////////////////////////////
69 echo ---------------------------------------------------------------------
70 echo BEGIN BUILD
71 echo ---------------------------------------------------------------------
72 MSBuild.exe /property:Configuration=release /target:clean   "%~dp0\x264_launcher_MSVC2015.sln"
73 if not "%ERRORLEVEL%"=="0" goto BuildError
74 MSBuild.exe /property:Configuration=release /target:rebuild "%~dp0\x264_launcher_MSVC2015.sln"
75 if not "%ERRORLEVEL%"=="0" goto BuildError
76
77 REM ///////////////////////////////////////////////////////////////////////////
78 REM // Detect build number
79 REM ///////////////////////////////////////////////////////////////////////////
80 set "BUILD_NO="
81 for /F "tokens=2,*" %%s in (%~dp0\src\version.h) do (
82         if "%%s"=="VER_X264_BUILD" set "BUILD_NO=%%~t"
83 )
84 if "%BUILD_NO%"=="" goto BuildError
85
86 REM ///////////////////////////////////////////////////////////////////////////
87 REM // Copy base files
88 REM ///////////////////////////////////////////////////////////////////////////
89 echo ---------------------------------------------------------------------
90 echo BEGIN PACKAGING
91 echo ---------------------------------------------------------------------
92 set "PACK_PATH=%TMP%\~%RANDOM%%RANDOM%.tmp"
93 mkdir "%PACK_PATH%"
94 mkdir "%PACK_PATH%\imageformats"
95 mkdir "%PACK_PATH%\toolset\x86"
96 mkdir "%PACK_PATH%\toolset\x64"
97 mkdir "%PACK_PATH%\toolset\common"
98 mkdir "%PACK_PATH%\sources"
99 copy "%~dp0\bin\Win32\Release\x264_launcher.exe"    "%PACK_PATH%"
100 copy "%~dp0\bin\Win32\Release\MUtils32-?.dll"       "%PACK_PATH%"
101 copy "%~dp0\bin\Win32\Release\toolset\x86\*.exe"    "%PACK_PATH%\toolset\x86"
102 copy "%~dp0\bin\Win32\Release\toolset\x86\*.dll"    "%PACK_PATH%\toolset\x86"
103 copy "%~dp0\bin\Win32\Release\toolset\x64\*.exe"    "%PACK_PATH%\toolset\x64"
104 copy "%~dp0\bin\Win32\Release\toolset\x64\*.dll"    "%PACK_PATH%\toolset\x64"
105 copy "%~dp0\bin\Win32\Release\toolset\common\*.exe" "%PACK_PATH%\toolset\common"
106 copy "%~dp0\bin\Win32\Release\toolset\common\*.gpg" "%PACK_PATH%\toolset\common"
107 copy "%~dp0\etc\sources\*.xz"                       "%PACK_PATH%\sources"
108 copy "%~dp0\LICENSE.html"                           "%PACK_PATH%"
109 copy "%~dp0\*.txt"                                  "%PACK_PATH%"
110
111 REM ///////////////////////////////////////////////////////////////////////////
112 REM // Copy dependencies
113 REM ///////////////////////////////////////////////////////////////////////////
114 copy "%MSVC_PATH%\redist\x86\Microsoft.VC%TOOLS_VER%.CRT\*.dll"                     "%PACK_PATH%"
115 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtCore4.dll"            "%PACK_PATH%"
116 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtGui4.dll"             "%PACK_PATH%"
117 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtSvg4.dll"             "%PACK_PATH%"
118 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtXml4.dll"             "%PACK_PATH%"
119 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\bin\QtXml4.dll"             "%PACK_PATH%"
120 copy "%~dp0\..\Prerequisites\Qt4\v%TOOLS_VER%_xp\Shared\plugins\imageformats\*.dll" "%PACK_PATH%\imageformats"
121 del "%PACK_PATH%\imageformats\*d4.dll" 2> NUL
122 if %TOOLS_VER% GEQ 140 (
123         copy "%WSDK_PATH%\Redist\ucrt\DLLs\x86\*.dll" "%PACK_PATH%"
124 )
125
126 REM ///////////////////////////////////////////////////////////////////////////
127 REM // Generate Docs
128 REM ///////////////////////////////////////////////////////////////////////////
129 "%PDOC_PATH%\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"
130
131 REM ///////////////////////////////////////////////////////////////////////////
132 REM // Compress
133 REM ///////////////////////////////////////////////////////////////////////////
134 "%UPX3_PATH%\upx.exe" --brute "%PACK_PATH%\*.exe"
135 "%UPX3_PATH%\upx.exe" --brute "%PACK_PATH%\MUtils32-?.dll
136 "%UPX3_PATH%\upx.exe" --best  "%PACK_PATH%\Qt*.dll"
137
138 REM ///////////////////////////////////////////////////////////////////////////
139 REM // Attributes
140 REM ///////////////////////////////////////////////////////////////////////////
141 attrib +R "%PACK_PATH%\*.exe"
142 attrib +R "%PACK_PATH%\*.dll"
143 attrib +R "%PACK_PATH%\*.txt"
144 attrib +R "%PACK_PATH%\*.html"
145
146 REM ///////////////////////////////////////////////////////////////////////////
147 REM // Setup install parameters
148 REM ///////////////////////////////////////////////////////////////////////////
149 mkdir "%~dp0\out" 2> NUL
150 set "OUT_PATH=%~dp0\out\x264_launcher.%ISO_DATE%"
151 :GenerateOutfileName
152 if exist "%OUT_PATH%.exe" (
153         set "OUT_PATH=%OUT_PATH%.new"
154         goto GenerateOutfileName
155 )
156 if exist "%OUT_PATH%.sfx" (
157         set "OUT_PATH=%OUT_PATH%.new"
158         goto GenerateOutfileName
159 )
160 if exist "%OUT_PATH%.zip" (
161         set "OUT_PATH=%OUT_PATH%.new"
162         goto GenerateOutfileName
163 )
164
165 REM ///////////////////////////////////////////////////////////////////////////
166 REM // Create Tag
167 REM ///////////////////////////////////////////////////////////////////////////
168 echo Simple x264/x265 Launcher - graphical front-end for x264 and x265 > "%PACK_PATH%\BUILD_TAG.txt"
169 echo Copyright (C) 2004-2016 LoRd_MuldeR ^<MuldeR2@GMX.de^> >> "%PACK_PATH%\BUILD_TAG.txt"
170 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
171 echo Build #%BUILD_NO%, created on %ISO_DATE% at %ISO_TIME% >> "%PACK_PATH%\BUILD_TAG.txt"
172 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
173 echo. >> "%PACK_PATH%\BUILD_TAG.txt"
174 "%~dp0\etc\cat.exe" "%~dp0\etc\setup\build.nfo" >> "%PACK_PATH%\BUILD_TAG.txt"
175
176 REM ///////////////////////////////////////////////////////////////////////////
177 REM // Build the installer
178 REM ///////////////////////////////////////////////////////////////////////////
179 "%NSIS_PATH%\makensis.exe" "/DX264_UPX_PATH=%UPX3_PATH%" "/DX264_DATE=%ISO_DATE%" "/DX264_BUILD=%BUILD_NO%" "/DX264_OUTPUT_FILE=%OUT_PATH%.sfx" "/DX264_SOURCE_PATH=%PACK_PATH%"    "%~dp0\etc\setup\setup.nsi"
180 if not "%ERRORLEVEL%"=="0" goto BuildError
181
182 "%NSIS_PATH%\makensis.exe" "/DX264_UPX_PATH=%UPX3_PATH%" "/DX264_DATE=%ISO_DATE%" "/DX264_BUILD=%BUILD_NO%" "/DX264_OUTPUT_FILE=%OUT_PATH%.exe" "/DX264_SOURCE_FILE=%OUT_PATH%.sfx" "%~dp0\etc\setup\wrapper.nsi"
183 if not "%ERRORLEVEL%"=="0" goto BuildError
184
185 attrib +R "%OUT_PATH%.exe"
186 attrib +R "%OUT_PATH%.sfx"
187
188 REM ///////////////////////////////////////////////////////////////////////////
189 REM // Build ZIP package
190 REM ///////////////////////////////////////////////////////////////////////////
191 pushd "%PACK_PATH%"
192 "%~dp0\etc\zip.exe" -r -9 -z "%OUT_PATH%.zip" "*.*" < "%PACK_PATH%\BUILD_TAG.txt"
193 popd
194
195 if not "%ERRORLEVEL%"=="0" goto BuildError
196 attrib +R "%OUT_PATH%.zip"
197
198 REM ///////////////////////////////////////////////////////////////////////////
199 REM // Clean up
200 REM ///////////////////////////////////////////////////////////////////////////
201 rmdir /Q /S "%PACK_PATH%"
202
203 REM ///////////////////////////////////////////////////////////////////////////
204 REM // COMPLETE
205 REM ///////////////////////////////////////////////////////////////////////////
206 echo.
207 echo Build completed.
208 echo.
209 pause
210 goto:eof
211
212 REM ///////////////////////////////////////////////////////////////////////////
213 REM // FAILED
214 REM ///////////////////////////////////////////////////////////////////////////
215 :BuildError
216 echo.
217 echo Build has failed !!!
218 echo.
219 pause