2016-04-27 12:03:10 +00:00
|
|
|
@echo OFF
|
|
|
|
setlocal enabledelayedexpansion
|
|
|
|
set "FullScriptPath=%~dp0"
|
|
|
|
set "FullExecPath=%cd%"
|
|
|
|
|
|
|
|
if not exist "%FullScriptPath%..\..\..\TelegramPrivate" (
|
|
|
|
echo.
|
|
|
|
echo This script is for building the production version of Telegram Desktop.
|
|
|
|
echo.
|
|
|
|
echo For building custom versions please visit the build instructions page at:
|
|
|
|
echo https://github.com/telegramdesktop/tdesktop/#build-instructions
|
|
|
|
exit /b
|
|
|
|
)
|
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
FOR /F "tokens=1* delims= " %%i in (%FullScriptPath%target) do set "BuildTarget=%%i"
|
|
|
|
|
|
|
|
if "%BuildTarget%" equ "uwp" (
|
|
|
|
set "BuildUWP=1"
|
|
|
|
) else (
|
|
|
|
set "BuildUWP=0"
|
|
|
|
)
|
|
|
|
|
2016-04-27 12:03:10 +00:00
|
|
|
FOR /F "tokens=1,2* delims= " %%i in (%FullScriptPath%version) do set "%%i=%%j"
|
|
|
|
|
|
|
|
set "VersionForPacker=%AppVersion%"
|
|
|
|
if %BetaVersion% neq 0 (
|
|
|
|
set "AppVersion=%BetaVersion%"
|
|
|
|
set "AppVersionStrFull=%AppVersionStr%_%BetaVersion%"
|
|
|
|
set "AlphaBetaParam=-beta %BetaVersion%"
|
|
|
|
set "BetaKeyFile=tbeta_%BetaVersion%_key"
|
|
|
|
) else (
|
|
|
|
if %AlphaChannel% neq 0 (
|
|
|
|
set "AlphaBetaParam=-alpha"
|
|
|
|
set "AppVersionStrFull=%AppVersionStr%.alpha"
|
|
|
|
) else (
|
|
|
|
set "AlphaBetaParam="
|
|
|
|
set "AppVersionStrFull=%AppVersionStr%"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
echo.
|
2017-02-01 10:12:52 +00:00
|
|
|
if %BuildUWP% neq 0 (
|
|
|
|
echo Building version %AppVersionStrFull% for UWP..
|
|
|
|
) else (
|
|
|
|
echo Building version %AppVersionStrFull% for Windows..
|
|
|
|
)
|
2016-04-27 12:03:10 +00:00
|
|
|
echo.
|
|
|
|
|
|
|
|
set "HomePath=%FullScriptPath%.."
|
|
|
|
set "ResourcesPath=%HomePath%\Resources"
|
|
|
|
set "SolutionPath=%HomePath%\.."
|
|
|
|
set "UpdateFile=tupdate%AppVersion%"
|
|
|
|
set "SetupFile=tsetup.%AppVersionStrFull%.exe"
|
|
|
|
set "PortableFile=tportable.%AppVersionStrFull%.zip"
|
2016-08-14 18:05:10 +00:00
|
|
|
set "ReleasePath=%HomePath%\..\out\Release"
|
2016-04-27 12:03:10 +00:00
|
|
|
set "DeployPath=%ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStrFull%"
|
|
|
|
set "SignPath=%HomePath%\..\..\TelegramPrivate\Sign.bat"
|
2017-02-01 10:12:52 +00:00
|
|
|
set "SignAppxPath=%HomePath%\..\..\TelegramPrivate\AppxSign.bat"
|
2016-04-27 12:03:10 +00:00
|
|
|
set "BinaryName=Telegram"
|
2017-10-13 19:23:19 +00:00
|
|
|
set "DropboxSymbolsPath=Y:\Telegram\symbols"
|
2018-04-08 13:17:56 +00:00
|
|
|
set "FinalReleasePath=Z:\Telegram\backup"
|
2016-04-27 12:03:10 +00:00
|
|
|
|
2016-08-05 19:31:19 +00:00
|
|
|
if not exist %DropboxSymbolsPath% (
|
2016-12-20 13:03:51 +00:00
|
|
|
echo Dropbox path %DropboxSymbolsPath% not found!
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
|
|
|
|
if not exist %FinalReleasePath% (
|
|
|
|
echo Release path %FinalReleasePath% not found!
|
2016-08-05 19:31:19 +00:00
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
|
2017-02-09 19:31:30 +00:00
|
|
|
if %BuildUWP% neq 0 (
|
|
|
|
if exist %ReleasePath%\AppX\ (
|
|
|
|
echo Result folder out\Release\AppX already exists!
|
2016-04-27 12:03:10 +00:00
|
|
|
exit /b 1
|
|
|
|
)
|
2017-04-05 17:02:25 +00:00
|
|
|
)
|
|
|
|
if %BetaVersion% neq 0 (
|
|
|
|
if exist %DeployPath%\ (
|
|
|
|
echo Deploy folder for version %AppVersionStr% already exists!
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
if exist %ReleasePath%\%BetaKeyFile% (
|
|
|
|
echo Beta version key file for version %AppVersion% already exists!
|
|
|
|
exit /b 1
|
2017-02-09 19:31:30 +00:00
|
|
|
)
|
|
|
|
) else (
|
2017-04-05 17:02:25 +00:00
|
|
|
if exist %ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStr%.alpha\ (
|
|
|
|
echo Deploy folder for version %AppVersionStr%.alpha already exists!
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
if exist %ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStr%.dev\ (
|
|
|
|
echo Deploy folder for version %AppVersionStr%.dev already exists!
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
if exist %ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStr%\ (
|
|
|
|
echo Deploy folder for version %AppVersionStr% already exists!
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
if exist %ReleasePath%\tupdate%AppVersion% (
|
|
|
|
echo Update file for version %AppVersion% already exists!
|
|
|
|
exit /b 1
|
2016-04-27 12:03:10 +00:00
|
|
|
)
|
|
|
|
)
|
2016-06-08 11:33:49 +00:00
|
|
|
|
|
|
|
cd "%HomePath%"
|
2017-02-01 10:12:52 +00:00
|
|
|
|
2016-08-14 18:05:10 +00:00
|
|
|
call gyp\refresh.bat
|
2016-04-27 12:03:10 +00:00
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
|
|
|
cd "%SolutionPath%"
|
2016-08-14 18:05:10 +00:00
|
|
|
call ninja -C out/Release Telegram
|
2016-04-27 12:03:10 +00:00
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
echo.
|
2016-04-27 12:03:10 +00:00
|
|
|
echo Version %AppVersionStrFull% build successfull. Preparing..
|
2017-02-01 10:12:52 +00:00
|
|
|
echo.
|
2016-04-27 12:03:10 +00:00
|
|
|
|
|
|
|
echo Dumping debug symbols..
|
2016-10-24 20:37:43 +00:00
|
|
|
xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\%BinaryName%.exe.exe*"
|
2016-08-14 19:56:26 +00:00
|
|
|
call "%SolutionPath%\..\Libraries\breakpad\src\tools\windows\dump_syms\Release\dump_syms.exe" "%ReleasePath%\%BinaryName%.exe.pdb" > "%ReleasePath%\%BinaryName%.exe.sym"
|
2016-10-20 09:46:16 +00:00
|
|
|
del "%ReleasePath%\%BinaryName%.exe.exe"
|
2016-04-27 12:03:10 +00:00
|
|
|
echo Done!
|
|
|
|
|
|
|
|
set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5"
|
|
|
|
|
|
|
|
cd "%ReleasePath%"
|
|
|
|
call "%SignPath%" "%BinaryName%.exe"
|
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
2017-02-02 16:29:36 +00:00
|
|
|
if %BuildUWP% equ 0 (
|
2017-02-01 10:12:52 +00:00
|
|
|
call "%SignPath%" "Updater.exe"
|
2016-04-27 12:03:10 +00:00
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
if %BetaVersion% equ 0 (
|
|
|
|
iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppVersionFull=%AppVersionStrFull% "/dReleasePath=%ReleasePath%" "%FullScriptPath%setup.iss"
|
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
if not exist "tsetup.%AppVersionStrFull%.exe" goto error
|
2016-04-27 12:03:10 +00:00
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
call "%SignPath%" "tsetup.%AppVersionStrFull%.exe"
|
|
|
|
if %errorlevel% neq 0 goto error
|
2016-04-27 12:03:10 +00:00
|
|
|
)
|
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe %AlphaBetaParam%
|
|
|
|
if %errorlevel% neq 0 goto error
|
2016-04-27 12:03:10 +00:00
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
if %BetaVersion% neq 0 (
|
|
|
|
if not exist "%ReleasePath%\%BetaKeyFile%" (
|
|
|
|
echo Beta version key file not found!
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
|
|
|
|
FOR /F "tokens=1* delims= " %%i in (%ReleasePath%\%BetaKeyFile%) do set "BetaSignature=%%i"
|
|
|
|
)
|
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
|
|
|
if %BetaVersion% neq 0 (
|
2017-02-07 17:39:47 +00:00
|
|
|
set "UpdateFile=!UpdateFile!_!BetaSignature!"
|
|
|
|
set "PortableFile=tbeta!BetaVersion!_!BetaSignature!.zip"
|
2017-02-01 10:12:52 +00:00
|
|
|
)
|
2016-04-27 12:03:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
for /f ^"usebackq^ eol^=^
|
|
|
|
|
2016-08-14 19:56:26 +00:00
|
|
|
^ delims^=^" %%a in (%ReleasePath%\%BinaryName%.exe.sym) do (
|
2017-02-01 10:12:52 +00:00
|
|
|
set "SymbolsHashLine=%%a"
|
|
|
|
goto symbolslinedone
|
|
|
|
)
|
|
|
|
:symbolslinedone
|
2016-04-27 12:03:10 +00:00
|
|
|
FOR /F "tokens=1,2,3,4* delims= " %%i in ("%SymbolsHashLine%") do set "SymbolsHash=%%l"
|
|
|
|
|
2016-08-14 19:56:26 +00:00
|
|
|
echo Copying %BinaryName%.exe.sym to %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%
|
|
|
|
if not exist %DropboxSymbolsPath%\%BinaryName%.exe.pdb mkdir %DropboxSymbolsPath%\%BinaryName%.exe.pdb
|
|
|
|
if not exist %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash% mkdir %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%
|
2016-10-20 09:46:16 +00:00
|
|
|
move "%ReleasePath%\%BinaryName%.exe.sym" %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%\
|
2016-04-27 12:03:10 +00:00
|
|
|
echo Done!
|
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
if %BuildUWP% neq 0 (
|
2017-02-02 16:29:36 +00:00
|
|
|
cd "%HomePath%"
|
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
mkdir "%ReleasePath%\AppX_x86"
|
|
|
|
xcopy "Resources\uwp\AppX\*" "%ReleasePath%\AppX_x86\" /E
|
|
|
|
set "ResourcePath=%ReleasePath%\AppX_x86\AppxManifest.xml"
|
|
|
|
call :repl "Argument= (ProcessorArchitecture=)"ARCHITECTURE"/ $1"x86"" "Filename=!ResourcePath!" || goto error
|
|
|
|
|
|
|
|
makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX_x86\AppxManifest.xml /of %ReleasePath%\AppX_x86\resources.pri
|
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
|
|
|
xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX_x86\"
|
|
|
|
|
|
|
|
MakeAppx.exe pack /d "%ReleasePath%\AppX_x86" /l /p ..\out\Release\%BinaryName%.x86.appx
|
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
|
|
|
mkdir "%ReleasePath%\AppX_x64"
|
|
|
|
xcopy "Resources\uwp\AppX\*" "%ReleasePath%\AppX_x64\" /E
|
|
|
|
set "ResourcePath=%ReleasePath%\AppX_x64\AppxManifest.xml"
|
|
|
|
call :repl "Argument= (ProcessorArchitecture=)"ARCHITECTURE"/ $1"x64"" "Filename=!ResourcePath!" || goto error
|
2017-02-02 16:29:36 +00:00
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX_x64\AppxManifest.xml /of %ReleasePath%\AppX_x64\resources.pri
|
2017-02-02 16:29:36 +00:00
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX_x64\"
|
2017-02-02 16:29:36 +00:00
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
MakeAppx.exe pack /d "%ReleasePath%\AppX_x64" /l /p ..\out\Release\%BinaryName%.x64.appx
|
2017-02-02 16:29:36 +00:00
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
if not exist "%ReleasePath%\deploy" mkdir "%ReleasePath%\deploy"
|
|
|
|
if not exist "%ReleasePath%\deploy\%AppVersionStrMajor%" mkdir "%ReleasePath%\deploy\%AppVersionStrMajor%"
|
|
|
|
mkdir "%DeployPath%"
|
2017-02-02 16:29:36 +00:00
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
xcopy "%ReleasePath%\%BinaryName%.pdb" "%DeployPath%\"
|
|
|
|
move "%ReleasePath%\%BinaryName%.exe.pdb" "%DeployPath%\"
|
|
|
|
move "%ReleasePath%\%BinaryName%.x86.appx" "%DeployPath%\"
|
|
|
|
move "%ReleasePath%\%BinaryName%.x64.appx" "%DeployPath%\"
|
|
|
|
move "%ReleasePath%\%BinaryName%.exe" "%DeployPath%\"
|
2017-02-09 19:31:30 +00:00
|
|
|
|
|
|
|
if "%AlphaBetaParam%" equ "" (
|
2017-04-05 17:02:25 +00:00
|
|
|
move "%ReleasePath%\AppX_x86" "%DeployPath%\AppX_x86"
|
|
|
|
move "%ReleasePath%\AppX_x64" "%DeployPath%\AppX_x64"
|
2017-02-09 19:31:30 +00:00
|
|
|
) else (
|
2017-04-05 17:02:25 +00:00
|
|
|
echo Leaving result in out\Release\AppX_arch for now..
|
2017-02-09 19:31:30 +00:00
|
|
|
)
|
2016-04-27 12:03:10 +00:00
|
|
|
) else (
|
2017-02-01 10:12:52 +00:00
|
|
|
if not exist "%ReleasePath%\deploy" mkdir "%ReleasePath%\deploy"
|
|
|
|
if not exist "%ReleasePath%\deploy\%AppVersionStrMajor%" mkdir "%ReleasePath%\deploy\%AppVersionStrMajor%"
|
|
|
|
mkdir "%DeployPath%"
|
|
|
|
mkdir "%DeployPath%\%BinaryName%"
|
|
|
|
if %errorlevel% neq 0 goto error
|
2016-04-27 12:03:10 +00:00
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
move "%ReleasePath%\%BinaryName%.exe" "%DeployPath%\%BinaryName%\"
|
|
|
|
move "%ReleasePath%\Updater.exe" "%DeployPath%\"
|
|
|
|
xcopy "%ReleasePath%\%BinaryName%.pdb" "%DeployPath%\"
|
|
|
|
xcopy "%ReleasePath%\Updater.pdb" "%DeployPath%\"
|
|
|
|
move "%ReleasePath%\%BinaryName%.exe.pdb" "%DeployPath%\"
|
|
|
|
move "%ReleasePath%\Updater.exe.pdb" "%DeployPath%\"
|
|
|
|
if %BetaVersion% equ 0 (
|
|
|
|
move "%ReleasePath%\%SetupFile%" "%DeployPath%\"
|
|
|
|
) else (
|
|
|
|
move "%ReleasePath%\%BetaKeyFile%" "%DeployPath%\"
|
|
|
|
)
|
|
|
|
move "%ReleasePath%\%UpdateFile%" "%DeployPath%\"
|
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
|
|
|
|
cd "%DeployPath%"
|
|
|
|
7z a -mx9 %PortableFile% %BinaryName%\
|
|
|
|
if %errorlevel% neq 0 goto error
|
|
|
|
)
|
2016-04-27 12:03:10 +00:00
|
|
|
|
2018-04-08 13:17:56 +00:00
|
|
|
set "FinalDeployPath=%FinalReleasePath%\%AppVersionStrMajor%\%AppVersionStrFull%\tsetup"
|
2017-02-01 19:38:31 +00:00
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
if %BuildUWP% equ 0 (
|
|
|
|
echo.
|
|
|
|
echo Version %AppVersionStrFull% is ready for deploy!
|
|
|
|
echo.
|
2016-04-27 12:03:10 +00:00
|
|
|
|
2017-02-01 10:12:52 +00:00
|
|
|
if not exist "%DeployPath%\%UpdateFile%" goto error
|
|
|
|
if not exist "%DeployPath%\%PortableFile%" goto error
|
|
|
|
if %BetaVersion% equ 0 (
|
|
|
|
if not exist "%DeployPath%\%SetupFile%" goto error
|
|
|
|
)
|
|
|
|
if not exist "%DeployPath%\%BinaryName%.pdb" goto error
|
|
|
|
if not exist "%DeployPath%\%BinaryName%.exe.pdb" goto error
|
|
|
|
if not exist "%DeployPath%\Updater.exe" goto error
|
|
|
|
if not exist "%DeployPath%\Updater.pdb" goto error
|
|
|
|
if not exist "%DeployPath%\Updater.exe.pdb" goto error
|
2018-04-08 13:17:56 +00:00
|
|
|
md "%FinalDeployPath%"
|
2017-02-01 10:12:52 +00:00
|
|
|
|
2017-04-05 17:02:25 +00:00
|
|
|
xcopy "%DeployPath%\%UpdateFile%" "%FinalDeployPath%\" /Y
|
|
|
|
xcopy "%DeployPath%\%PortableFile%" "%FinalDeployPath%\" /Y
|
2017-02-01 10:12:52 +00:00
|
|
|
if %BetaVersion% equ 0 (
|
2017-04-05 17:02:25 +00:00
|
|
|
xcopy "%DeployPath%\%SetupFile%" "%FinalDeployPath%\" /Y
|
2017-02-01 10:12:52 +00:00
|
|
|
) else (
|
|
|
|
xcopy "%DeployPath%\%BetaKeyFile%" "%FinalDeployPath%\" /Y
|
|
|
|
)
|
2016-04-27 12:03:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
echo Version %AppVersionStrFull% is ready!
|
|
|
|
|
|
|
|
cd "%FullExecPath%"
|
|
|
|
exit /b
|
|
|
|
|
|
|
|
:error
|
|
|
|
(
|
|
|
|
set ErrorCode=%errorlevel%
|
|
|
|
if !ErrorCode! neq 0 (
|
|
|
|
echo Error !ErrorCode!
|
|
|
|
) else (
|
|
|
|
echo Error 666
|
|
|
|
set ErrorCode=666
|
|
|
|
)
|
|
|
|
cd "%FullExecPath%"
|
|
|
|
exit /b !ErrorCode!
|
|
|
|
)
|
2017-04-05 17:02:25 +00:00
|
|
|
|
|
|
|
:repl
|
|
|
|
(
|
|
|
|
set %1
|
|
|
|
set %2
|
|
|
|
set "TempFilename=!Filename!__tmp__"
|
|
|
|
cscript //Nologo "%FullScriptPath%replace.vbs" "Replace" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
|
|
|
|
xcopy /Y !TempFilename! !Filename! >NUL || goto :repl_finish
|
|
|
|
goto :repl_finish
|
|
|
|
)
|
|
|
|
|
|
|
|
:repl_finish
|
|
|
|
(
|
|
|
|
set ErrorCode=%errorlevel%
|
|
|
|
if !ErrorCode! neq 0 (
|
|
|
|
echo Replace error !ErrorCode!
|
|
|
|
echo While replacing "%Replace%"
|
|
|
|
echo In file "%Filename%"
|
|
|
|
)
|
|
|
|
del %TempFilename%
|
|
|
|
exit /b !ErrorCode!
|
|
|
|
)
|