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