OSDN Git Service

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