OSDN Git Service

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