Skip to content

Commit f1b0c57

Browse files
committed
Add TDLib as submodule
1 parent 0f804b1 commit f1b0c57

4 files changed

Lines changed: 115 additions & 2 deletions

File tree

‎.gitmodules‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
[submodule "Libraries/vlc/vlc"]
2020
path = Libraries/vlc/vlc
2121
url = https://github.com/videolan/vlc.git
22+
[submodule "Libraries/tdlib"]
23+
path = Libraries/tdlib
24+
url = https://github.com/tdlib/td.git

‎Documentation/Build-instructions.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ You can choose to install both `x64` and `arm64` or just opt for the architectur
6161

6262
### TDLib
6363
In order to communicate with Telegram servers, Unigram uses TDLib.
64-
Here is complete instruction for TDLib binaries building, taken from the official [documentation](https://tdlib.github.io/td/build.html?language=C%23):
64+
Here is complete instruction for TDLib binaries building:
6565

6666
- Download and install Microsoft Visual Studio. Enable C++ and Windows 10 SDK support while installing.
6767
- Download and install CMake; choose "Add CMake to the system PATH" option while installing.
6868
- Download and install Git.
6969
- Download and unpack PHP. Add the path to php.exe to the PATH environment variable.
70-
- Download and install 7-Zip archiver. Add the path to 7z.exe to the PATH environment variable.
7170
- Close and re-open PowerShell if the PATH environment variable was changed.
7271
- Run these commands in PowerShell to build TDLib and to install it to td/tdlib:
7372

‎Libraries/tdjson/build.ps1‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
param (
2+
[string]$vcpkg_root = $(throw "-vcpkg_root=<path to vcpkg> is required"),
3+
[ValidateSet('x86', 'x64', 'ARM', 'ARM64', IgnoreCase = $false)]
4+
[string[]]$arch = @( "x86", "x64", "ARM", "ARM64" ),
5+
[string]$mode = "all"
6+
)
7+
$ErrorActionPreference = "Stop"
8+
9+
$vcpkg_root = Resolve-Path $vcpkg_root
10+
11+
$vcpkg_cmake="${vcpkg_root}\scripts\buildsystems\vcpkg.cmake"
12+
$arch_list = $arch
13+
$td_root = Resolve-Path "../tdlib"
14+
15+
function CheckLastExitCode {
16+
if ($LastExitCode -ne 0) {
17+
$msg = @"
18+
EXE RETURNED EXIT CODE $LastExitCode
19+
CALLSTACK:$(Get-PSCallStack | Out-String)
20+
"@
21+
throw $msg
22+
}
23+
}
24+
25+
function clean {
26+
Remove-Item build-* -Force -Recurse -ErrorAction SilentlyContinue
27+
}
28+
29+
function prepare {
30+
New-Item -ItemType Directory -Force -Path build-native
31+
32+
cd build-native
33+
34+
cmake -A Win32 -DTD_GENERATE_SOURCE_FILES=ON -DTD_ENABLE_MULTI_PROCESSOR_COMPILATION=ON "$td_root"
35+
CheckLastExitCode
36+
cmake --build .
37+
CheckLastExitCode
38+
39+
cd ..
40+
}
41+
42+
function config {
43+
New-Item -ItemType Directory -Force -Path build-uwp
44+
cd build-uwp
45+
46+
ForEach ($arch in $arch_list) {
47+
echo "Config Arch = [$arch]"
48+
New-Item -ItemType Directory -Force -Path $arch
49+
cd $arch
50+
echo "${td_root}"
51+
$fixed_arch = $arch
52+
if ($arch -eq "x86") {
53+
$fixed_arch = "win32"
54+
}
55+
cmake -A $fixed_arch -DCMAKE_SYSTEM_VERSION="10.0" -DCMAKE_SYSTEM_NAME="WindowsStore" -DCMAKE_TOOLCHAIN_FILE="$vcpkg_cmake" -DTD_ENABLE_MULTI_PROCESSOR_COMPILATION=ON "$td_root"
56+
CheckLastExitCode
57+
cd ..
58+
}
59+
echo "done"
60+
cd ..
61+
}
62+
63+
function build {
64+
cd build-uwp
65+
ForEach ($arch in $arch_list) {
66+
echo "Build Arch = [$arch]"
67+
cd $arch
68+
cmake --build . --config RelWithDebInfo --target tdjson
69+
CheckLastExitCode
70+
cd ..
71+
}
72+
cd ..
73+
}
74+
75+
function export {
76+
cp ../tdlib/td/generate/scheme/td_api.tl .
77+
78+
ForEach ($arch in $arch_list) {
79+
$fixed_arch = $arch.ToLower();
80+
Remove-Item $arch -Force -Recurse -ErrorAction SilentlyContinue
81+
New-Item -ItemType Directory -Force -Path $arch
82+
83+
cp ${arch}/RelWithDebInfo/* -include "SSLEAY*","LIBEAY*","libcrypto*","libssl*","zlib*","tdjson.pdb","tdjson.dll" $arch
84+
}
85+
}
86+
87+
function run {
88+
Push-Location
89+
Try {
90+
if ($mode -eq "clean") {
91+
clean
92+
}
93+
if (($mode -eq "prepare") -or ($mode -eq "all")) {
94+
prepare
95+
}
96+
if (($mode -eq "config") -or ( $mode -eq "all")) {
97+
config
98+
}
99+
if (($mode -eq "build") -or ($mode -eq "all")) {
100+
build
101+
}
102+
if (($mode -eq "export") -or ($mode -eq "all")) {
103+
export
104+
}
105+
} Finally {
106+
Pop-Location
107+
}
108+
}
109+
110+
run

‎Libraries/tdlib‎

Submodule tdlib added at cecbf12

0 commit comments

Comments
 (0)