Documentation/Build-instructions.md
The following tools and SDKs are mandatory for the project development:
git clone --recursive https://github.com/UnigramDev/Unigram.git.Unigram/Telegram and name it Constants.Secret.cs:namespace Telegram
{
public static partial class Constants
{
static Constants()
{
ApiId = your_api_id;
ApiHash = "your_api_hash";
AppChannel = "Telegram channel username used for in-app updates";
}
}
}
your_api_id and your_api_hash with the data obtained from step 2.Unigram uses NuGet for managed dependencies and vcpkg for unmanaged ones.
If the vcpkg package manager component is selected in the Visual Studio installer, there is
nothing to do — the build finds the copy that ships with Visual Studio. Otherwise clone vcpkg
next to this repository, so that vcpkg and Unigram are siblings:
> git clone https://github.com/Microsoft/vcpkg.git
> cd vcpkg
> ./bootstrap-vcpkg.bat
The build looks for vcpkg in that order, and VCPKG_ROOT overrides both if you keep it
elsewhere.
Two things about that checkout matter:
--depth or --filter clone fails with a confusing git error.vcpkg.json. vcpkg reads its version
database from the working tree rather than from the pinned commit, so an older checkout fails
with no version database entry for <port> at <date>. If you already have a vcpkg you have
used for something else, update it and re-bootstrap:
> git fetch
> git checkout <the builtin-baseline commit from vcpkg.json>
> ./bootstrap-vcpkg.bat
That is the whole setup. Do not run vcpkg integrate install: the repository disables the
machine-wide integration so that it always builds against its own pinned commit.
Everything else comes from vcpkg.json in the repository root, which is a
manifest: it pins the vcpkg commit
(builtin-baseline) and lists the libraries, and the build restores them on demand into
vcpkg_installed\<triplet>.
ffmpeg has to be built with a specific set of decoders, so it is vendored as an
overlay port in
Libraries\vcpkg-ports\ffmpeg, taken from the vcpkg registry with the --enable-* list applied
on top. It takes precedence over whichever ffmpeg version the pinned commit happens to carry.
TDLib is built from the same manifest and the same installed tree, so the openssl and zlib it links are the ones the app ships.
In order to communicate with Telegram servers, Unigram uses TDLib. It comes as a submodule and is
built by Libraries\tdjson\build.ps1, which exports tdjson.dll, its dependencies and
td_api.tl into Libraries\tdjson\<arch> — the paths the app copies from.
Two extra tools are needed for the code generation step:
php.exe on PATH.Then, from Libraries\tdjson:
> powershell -ExecutionPolicy ByPass ./build.ps1 -arch x64,ARM64
The script picks up VCPKG_ROOT and builds against the manifest in the repository root, so
openssl and zlib are the same builds the app links. You can choose to build both x64 and
arm64 or just the architecture you need.
LibVLC plays video and audio, and WebRTC backs calls and video chats. Both arrive as prebuilt
binaries through the same manifest as everything else, as overlay ports in
Libraries\vcpkg-ports. The build downloads an archive for the architecture it is building,
verifies it against a SHA512 recorded in the port, and caches it — so there is nothing to install
or configure for either.
They are built from UnigramDev/vlc and UnigramDev/webrtc-uwp; the WebRTC fork follows WinRTC. Each release names the commit it was built from.
To change either one, see UnigramDev/deps, which holds the build scripts, the patches and the packaging, and documents how to publish a new archive.
If the code fails to build make sure to create a new issue or to open a pull request.