Build with Visual Studio 2013, Windows 8.1

Prepare folder:

  Choose folder for future build, for example "D:\TBuild\".
  There you will have two folders, "Libraries" for third-party libs and "tdesktop" for the app.

Clone sources:

  - By git: in Git Bash go to "/d/tbuild" and run "git clone https://github.com/telegramdesktop/tdesktop.git"
  - Or download in ZIP and extract to "D:\TBuild\", rename "tdesktop-master" to "tdesktop" to have "D:\TBuild\tdesktop\Telegram.sln" solution

Prepare libraries:

OpenSSL (1.0.1g)

  https://www.openssl.org/related/binaries.html > "OpenSSL for Windows" > "Win32 OpenSSL v1.0.1g" (16 Mb)
  - Install to "D:\TBuild\Libraries\OpenSSL-Win32", while installing "Copy OpenSSL DLLs to" choose "The OpenSSL binaries (/bin) directory"

LZMA (9.20)

  http://www.7-zip.org/sdk.html > Download 9.20 "LZMA SDK (C, C++, C#, Java)"
  - Extract to "D:\TBuild\Libraries\lzma\"

  Building Lib:

    - Open "D:\TBuild\Libraries\lzma\C\Util\LzmaLib\LzmaLib.dsw" with Visual Studio 2013 > One-way upgrade OK
    - For Debug and Release configurations:
      - LzmaLib Properties > General > Configuration Type = "Static library (.lib)" > OK
      - LzmaLib Properties > Librarian > General > Target Machine = "MachineX86 (/MACHINE:X86)" > OK
    - Build Debug
    - Build Release

zlib (1.2.8)

  http://www.zlib.net/ > "zlib source code, version 1.2.8, zipfile format" > http://zlib.net/zlib128.zip
  - Extract to "D:\TBuild\Libraries\"

  Building Lib:
    - Open "D:\TBuild\Libraries\zlib-1.2.8\contrib\vstudio\vc11\zlibvc.sln" > Upgrade .. > OK
    - We are interested in only "zlibstat" project, but it depends on some custom pre-build step
    - For Debug configuration:
      - zlibstat Properties > C/C++ > Code Generation > Runtime Library = "Multi-threaded Debug (/MTd)" > OK
    - For Release configuration:
      - zlibstat Properties > C/C++ > Code Generation > Runtime Library = "Multi-threaded (/MT)" > OK
    - Build Solution for Debug - only "zlibstat" project build successfully, and we need only it
    - Build Solution for Release - only "zlibstat" project build successfully, and we need only it

libexif (0.6.20) - prepared

  https://github.com/telegramdesktop/libexif-0.6.20
  - By git: in Git Bash go to "/d/tbuild/libraries" and run "git clone https://github.com/telegramdesktop/libexif-0.6.20.git"
  - Or download in ZIP and extract to "D:\TBuild\Libraries\", rename "libexif-0.6.20-master" to "libexif-0.6.20" to have "D:\TBuild\Libraries\libexif-0.6.20\win32\lib_exif.sln" solution

  Building Lib:
    - Open "D:\TBuild\Libraries\libexif-0.6.20\win32\lib_exif.sln"
    - Build Debug
    - Build Release

Qt (5.3.0)

  http://download.qt-project.org/official_releases/qt/5.3/5.3.0/single/qt-everywhere-opensource-src-5.3.0.zip
  - Extract to "D:\TBuild\Libraries\Tmp\"
  - Copy everything from "D:\TBuild\Libraries\Tmp\qt-everywhere-opensource-src-5.3.0" to "D:\TBuild\Libraries\QtStatic"
  - Copy (with overwrite) everything from "D:\TBuild\tdesktop\_qt_5_3_0_patch" to "D:\TBuild\Libraries\QtStatic"

  Building Lib:

    - Install Python (3.3.2) from https://www.python.org/download/releases/3.3.2 > "Windows x86 MSI Installer (3.3.2)" (https://www.python.org/ftp/python/3.3.2/python-3.3.2.msi)
    - Open "VS2013 x86 Native Tools Command Prompt.bat" (should be in "\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts")

    Go to Qt directory ("D:" > Enter > "cd TBuild\Libraries\QtStatic" > Enter) and run "configure -debug-and-release -opensource -static -opengl desktop -mp -nomake examples -platform win32-msvc2013", then "y" (accept), after configuration is complete run "nmake" and then "nmake install", nmake will take really long time.

Qt Visual Studio Addin 1.2.3

  http://download.qt-project.org/official_releases/vsaddin/qt-vs-addin-1.2.3-opensource.exe
  - Install to default location

Building Telegram Desktop:

  - Launch Microsoft Visual Studio 2013
  - QT5 > Qt Options > Add:
    Version name: QtStatic.5.3.0
    Path: D:\TBuild\Libraries\QtStatic\qtbase
  - Default Qt/Win version: QtStatic.5.3.0 > OK
  - File > Open > Project/Solution > D:\TBuild\tdesktop\Telegram.sln
  - Build > Build Solution

Projects in Telegram solution:

  Telegram:
    tdesktop messenger

  Updater:
    little app, that is launched by Telegram when update is ready, replaces all files and launches it back

  Packer:
    compiles given files to single update file, compresses it with lzma and signs with a private key,
    it was not included to Telegram solution, because private key is inaccessible

  Prepare:
    prepares a release for deployment: puts all files to deploy/{version} folder
      current tsetup{version}exe installer
      current Telegram.exe
      current Telegram.pdb (debug info for crash minidumps view)
      current tupdate{updversion} binary lzma update archive

  MetaEmoji:
    from two folders
      SourceFiles/art/Emoji
      SourceFiles/art/Emoji_200x
    and some inner config creates four sprites and text2emoji replace code:
      SourceFiles/art/emoji.png
      SourceFiles/art/emoji_125x.png
      SourceFiles/art/emoji_150x.png
      SourceFiles/art/emoji_200x.png
      SourceFiles/gui/emoji_config.cpp

  MetaStyle:
    from two files and two sprites
      Resources/style_classes.txt
      Resources/style.txt
      SourceFiles/art/sprite.png
      SourceFiles/art/sprite_200x.png
    creates two other sprites, four sprite grids and style constants code:
      SourceFiles/art/sprite_125x.png
      SourceFiles/art/sprite_150x.png
      SourceFiles/art/grid.png
      SourceFiles/art/grid_125x.png
      Sourcefiles/art/grid_150x.png
      SourceFiles/art/grid_200x.png
      GeneratedFiles/style_classes.h
      GeneratedFiles/style_auto.h
      GeneratedFiles/style_auto.cpp

  MetaLang:
    from langpack file
      Resources/lang.txt
    creates lang constants code and lang file parse code:
      GeneratedFiles/lang.h
      GeneratedFiles/lang.cpp