OSDN Git Service

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