Skip to content

Commit

Permalink
Merge branch 'tdlib:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pylakey authored Dec 27, 2021
2 parents fdffc2f + 218de37 commit b308720
Show file tree
Hide file tree
Showing 103 changed files with 2,650 additions and 1,954 deletions.
4 changes: 2 additions & 2 deletions CMake/FindReadline.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if (APPLE)
find_path(READLINE_INCLUDE_DIR readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH)
find_path(READLINE_INCLUDE_DIR readline/readline.h /opt/homebrew/opt/readline/include /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH)
endif()
find_path(READLINE_INCLUDE_DIR readline/readline.h)

if (APPLE)
find_library(READLINE_LIBRARY readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH)
find_library(READLINE_LIBRARY readline /opt/homebrew/opt/readline/lib /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH)
endif()
find_library(READLINE_LIBRARY readline)

Expand Down
2 changes: 2 additions & 0 deletions CMake/TdSetUpCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function(td_set_up_compiler)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
set(TD_LINKER_FLAGS "-Wl,-z,ignore")
elseif (EMSCRIPTEN)
set(TD_LINKER_FLAGS "-Wl,--gc-sections")
else()
set(TD_LINKER_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL")
endif()
Expand Down
40 changes: 22 additions & 18 deletions CMake/iOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
#
# IOS_ARCH = automatic(default) or "arch1;arch2" (e.q. "x86_64;arm64")
# By default this value will be automatically chosen based on the IOS_PLATFORM value above.
# If set manually, it will override the default and force to build those architectures only.
#
# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
# By default this location is automatically chosen based on the IOS_PLATFORM value above.
# If set manually, it will override the default location and force the user of a particular Developer Platform
#
# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
# By default this location is automatically chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
# If set manually, this will force the use of a specific SDK version

Expand Down Expand Up @@ -191,23 +195,23 @@ set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the select
# Set the sysroot default to the most recent SDK
set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")

# set the architecture for iOS
if (IOS_PLATFORM STREQUAL "OS")
set (IOS_ARCH "armv7;armv7s;arm64")
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
set (IOS_ARCH "i386;x86_64;arm64")
elseif (IOS_PLATFORM STREQUAL "WATCHOS")
set (IOS_ARCH "armv7k;arm64_32")
elseif (IOS_PLATFORM STREQUAL "WATCHSIMULATOR")
set (IOS_ARCH "i386;x86_64;arm64")
elseif (IOS_PLATFORM STREQUAL "TVOS")
set (IOS_ARCH "arm64")
elseif (IOS_PLATFORM STREQUAL "TVSIMULATOR")
set (IOS_ARCH "x86_64;arm64")
else()
message (WARNING "Unknown IOS_PLATFORM=<${IOS_PLATFORM}>")
# Set the architectures unless specified manually with IOS_ARCH
if (NOT DEFINED IOS_ARCH)
if (IOS_PLATFORM STREQUAL "OS")
set (IOS_ARCH "armv7;armv7s;arm64")
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
set (IOS_ARCH "i386;x86_64;arm64")
elseif (IOS_PLATFORM STREQUAL "WATCHOS")
set (IOS_ARCH "armv7k;arm64_32")
elseif (IOS_PLATFORM STREQUAL "WATCHSIMULATOR")
set (IOS_ARCH "i386;x86_64;arm64")
elseif (IOS_PLATFORM STREQUAL "TVOS")
set (IOS_ARCH "arm64")
elseif (IOS_PLATFORM STREQUAL "TVSIMULATOR")
set (IOS_ARCH "x86_64;arm64")
endif()
endif()
message (STATUS ${IOS_ARCH})
message (STATUS "The iOS architectures: ${IOS_ARCH}")

set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")

Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()

project(TDLib VERSION 1.7.10 LANGUAGES CXX C)
project(TDLib VERSION 1.7.11 LANGUAGES CXX C)

if (NOT DEFINED CMAKE_MODULE_PATH)
set(CMAKE_MODULE_PATH "")
Expand Down Expand Up @@ -361,7 +361,7 @@ set(TDLIB_SOURCE
td/telegram/MessageSearchFilter.cpp
td/telegram/MessageSender.cpp
td/telegram/MessagesManager.cpp
td/telegram/MessageTtlSetting.cpp
td/telegram/MessageTtl.cpp
td/telegram/misc.cpp
td/telegram/net/AuthDataShared.cpp
td/telegram/net/ConnectionCreator.cpp
Expand All @@ -385,6 +385,7 @@ set(TDLIB_SOURCE
td/telegram/NotificationManager.cpp
td/telegram/NotificationSettings.cpp
td/telegram/NotificationType.cpp
td/telegram/OptionManager.cpp
td/telegram/Payments.cpp
td/telegram/PasswordManager.cpp
td/telegram/PhoneNumberManager.cpp
Expand Down Expand Up @@ -565,7 +566,8 @@ set(TDLIB_SOURCE
td/telegram/MessageSearchFilter.h
td/telegram/MessageSender.h
td/telegram/MessagesManager.h
td/telegram/MessageTtlSetting.h
td/telegram/MessageTtl.h
td/telegram/MinChannel.h
td/telegram/misc.h
td/telegram/net/AuthDataShared.h
td/telegram/net/ConnectionCreator.h
Expand Down Expand Up @@ -599,6 +601,7 @@ set(TDLIB_SOURCE
td/telegram/NotificationManager.h
td/telegram/NotificationSettings.h
td/telegram/NotificationType.h
td/telegram/OptionManager.h
td/telegram/PasswordManager.h
td/telegram/Payments.h
td/telegram/PhoneNumberManager.h
Expand Down Expand Up @@ -672,6 +675,8 @@ set(TDLIB_SOURCE
td/telegram/Game.hpp
td/telegram/InputMessageText.hpp
td/telegram/MessageEntity.hpp
td/telegram/MessageReplyInfo.hpp
td/telegram/MinChannel.hpp
td/telegram/NotificationSettings.hpp
td/telegram/Payments.hpp
td/telegram/Photo.hpp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ target_link_libraries(YourTarget PRIVATE Td::TdStatic)

Or you could install `TDLib` and then reference it in your CMakeLists.txt like this:
```
find_package(Td 1.7.10 REQUIRED)
find_package(Td 1.7.11 REQUIRED)
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
```
See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt).
Expand Down
3 changes: 2 additions & 1 deletion SplitSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function split_file($file, $chunks, $undo) {
}

if (count($functions) < $chunks) {
fwrite(STDERR, "ERROR: file is too small to be splitted more".PHP_EOL);
fwrite(STDERR, "ERROR: file is too small to be split more".PHP_EOL);
return;
}

Expand Down Expand Up @@ -297,6 +297,7 @@ function ($matches) use ($needed_std_headers) {
'MessageCopyOptions' => 'MessageCopyOptions',
'messages_manager[_(-][^.]|MessagesManager' => 'MessagesManager',
'notification_manager[_(-][^.]|NotificationManager|notifications[)]' => 'NotificationManager',
'option_manager[_(-][^.]|OptionManager' => "OptionManager",
'phone_number_manager[_(-][^.]|PhoneNumberManager' => "PhoneNumberManager",
'poll_manager[_(-][^.]|PollManager' => "PollManager",
'PublicDialogType|get_public_dialog_type' => 'PublicDialogType',
Expand Down
29 changes: 25 additions & 4 deletions build.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@
<p></p>
</div>

<div id="buildMacOsHostDiv" class="hide">
<span>Choose host architecture:</span><br>
<label><input type="radio" id="buildMacOsHostRadioAppleSilicon" name="buildMacOsHostRadio" onchange="onOptionsChanged()" checked/>Apple silicon</label>
<label><input type="radio" id="buildMacOsHostRadioIntel" name="buildMacOsHostRadio" onchange="onOptionsChanged()"/>Intel</label>
<p></p>
</div>

<div id="buildBitnessDiv" class="hide">
<span>Choose for which bitness you want to build TDLib:</span><br>
<label><input type="radio" id="buildBitnessRadio32" name="buildBitnessRadio" onchange="onOptionsChanged()" checked/>32</label>
Expand Down Expand Up @@ -586,6 +593,8 @@
var use_powershell = false;
var use_cmd = false;
var use_csh = false;
var homebrew_install_dir = '';
var os_mac_host_name = '';
if (os_windows) {
document.getElementById('buildShellDiv').style.display = 'block';
use_powershell = document.getElementById('buildShellRadioPowerShell').checked;
Expand All @@ -598,6 +607,18 @@
} else {
document.getElementById('buildShellBsdDiv').style.display = 'none';
}
if (os_mac) {
document.getElementById('buildMacOsHostDiv').style.display = 'block';
if (document.getElementById('buildMacOsHostRadioAppleSilicon').checked) {
homebrew_install_dir = '/opt/homebrew';
os_mac_host_name = 'Apple silicon';
} else {
homebrew_install_dir = '/usr/local';
os_mac_host_name = 'Intel';
}
} else {
document.getElementById('buildMacOsHostDiv').style.display = 'none';
}

var use_msvc = os_windows;
var use_vcpkg = os_windows;
Expand Down Expand Up @@ -713,7 +734,7 @@
pre_text.push('Note that the following instruction is for NetBSD 8.0 and default SH shell.');
}
if (os_mac) {
pre_text.push('Note that the following instruction will build TDLib only for the current architecture (x64 or Apple silicon).');
pre_text.push('Note that the following instruction will build TDLib only for ' + os_mac_host_name + '.');
pre_text.push('If you want to create a universal XCFramework, take a look at our <a href="https://github.com/tdlib/td/tree/master/example/ios">example</a> instead.');
}

Expand Down Expand Up @@ -773,7 +794,7 @@
var cmake = 'cmake';
if (os_mac) {
commands.push('xcode-select --install');
commands.push('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"');
commands.push('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"');
commands.push('brew install gperf cmake openssl' + (target === 'JNI' ? ' coreutils' : ''));
if (target === 'JNI') {
commands.push('brew install openjdk');
Expand Down Expand Up @@ -926,7 +947,7 @@
options.push('-DJAVA_HOME=/usr/local/openjdk7/');
}
if (os_mac) {
options.push('-DJAVA_HOME=/usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/');
options.push('-DJAVA_HOME=' + homebrew_install_dir + '/opt/openjdk/libexec/openjdk.jdk/Contents/Home/');
}
}
return options;
Expand Down Expand Up @@ -957,7 +978,7 @@

cmake_init_options = getBacicCmakeInitOptions();
if (os_mac) {
cmake_init_options.push('-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/');
cmake_init_options.push('-DOPENSSL_ROOT_DIR=' + homebrew_install_dir + '/opt/openssl/');
}
if (install_dir) {
cmake_init_options.push('-DCMAKE_INSTALL_PREFIX:PATH=' + install_dir);
Expand Down
2 changes: 1 addition & 1 deletion example/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4 FATAL_ERROR)

project(TdExample VERSION 1.0 LANGUAGES CXX)

find_package(Td 1.7.10 REQUIRED)
find_package(Td 1.7.11 REQUIRED)

add_executable(tdjson_example tdjson_example.cpp)
target_link_libraries(tdjson_example PRIVATE Td::TdJson)
Expand Down
2 changes: 1 addition & 1 deletion example/cpp/td_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class TdExample {
[this](td_api::updateNewMessage &update_new_message) {
auto chat_id = update_new_message.message_->chat_id_;
std::string sender_name;
td_api::downcast_call(*update_new_message.message_->sender_,
td_api::downcast_call(*update_new_message.message_->sender_id_,
overloaded(
[this, &sender_name](td_api::messageSenderUser &user) {
sender_name = get_user_name(user.user_id_);
Expand Down
2 changes: 1 addition & 1 deletion example/ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cd <path to TDLib sources>/example/ios
./build.sh
```
This may take a while, because TDLib will be built about 16 times.
Resulting XCFramework will work on any architecture and even on a simulator (x64, Apple silicon).
Resulting XCFramework will work on any architecture and even on a simulator.
We use [CMake/iOS.cmake](https://github.com/tdlib/td/blob/master/CMake/iOS.cmake) toolchain, other toolchains may work too.

Built libraries and XCFramework will be stored in `tdjson` directory.
Expand Down
8 changes: 6 additions & 2 deletions example/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
To run this example, you will need installed JDK >= 1.6.
For Javadoc documentation generation PHP is needed.

You can find complete build instructions for your operating system at https://tdlib.github.io/td/build.html?language=Java.

In general, the build process looks as follows.

TDLib should be prebuilt with JNI bindings and installed to local subdirectory `td/` as follows:
```
cd <path to TDLib sources>
Expand All @@ -13,7 +17,7 @@ cmake --build . --target install
```
If you want to compile TDLib for 32-bit/64-bit Java on Windows using MSVC, you will also need to add `-A Win32`/`-A x64` option to CMake.

In Windows, use Vcpkg toolchain file by adding parameter -DCMAKE_TOOLCHAIN_FILE=<VCPKG_DIR>/scripts/buildsystems/vcpkg.cmake
In Windows, use vcpkg toolchain file by adding parameter -DCMAKE_TOOLCHAIN_FILE=<VCPKG_DIR>/scripts/buildsystems/vcpkg.cmake

Then you can build this example:
```
Expand All @@ -36,4 +40,4 @@ If you receive "Could NOT find JNI ..." error from CMake, you need to specify to

If you receive java.lang.UnsatisfiedLinkError with "Can't find dependent libraries", you may also need to copy some dependent shared OpenSSL and zlib libraries to `bin/`.

In case you compiled the example as 32-bit version, you may need to give -d32 parameter to Java.
Make sure that you compiled the example for the same architecture as your JVM.
6 changes: 3 additions & 3 deletions example/java/org/drinkless/tdlib/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private static void getCommand() {
private static void getMainChatList(final int limit) {
synchronized (mainChatList) {
if (!haveFullMainChatList && limit > mainChatList.size()) {
// send GetChats request if there are some unknown chats and have not enough known chats
// send LoadChats request if there are some unknown chats and have not enough known chats
client.send(new TdApi.LoadChats(new TdApi.ChatListMain(), limit - mainChatList.size()), new Client.ResultHandler() {
@Override
public void onResult(TdApi.Object object) {
Expand All @@ -259,7 +259,7 @@ public void onResult(TdApi.Object object) {
haveFullMainChatList = true;
}
} else {
System.err.println("Receive an error for GetChats:" + newLine + object);
System.err.println("Receive an error for LoadChats:" + newLine + object);
}
break;
case TdApi.Ok.CONSTRUCTOR:
Expand Down Expand Up @@ -598,4 +598,4 @@ public void onResult(TdApi.Object object) {
}
}
}
}
}
2 changes: 1 addition & 1 deletion example/uwp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cd <path to vcpkg>
```
powershell -ExecutionPolicy ByPass .\build.ps1 -vcpkg_root C:\vcpkg
```
If you need to restart the build from scratch, call `.\build.ps1 -vcpkg_root ../../vcpkg -mode clean` first.
If you need to restart the build from scratch, call `.\build.ps1 -vcpkg_root C:\vcpkg -mode clean` first.
* Install Visual Studio Extension "TDLib for Universal Windows Platform" located at `build-uwp\vsix\tdlib.vsix`, which was created on the previous step by `build.ps1` script.

Now `TDLib` can be used from any UWP project, built in Visual Studio.
Expand Down
2 changes: 1 addition & 1 deletion example/uwp/app/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
[assembly: ComVisible(false)]
2 changes: 1 addition & 1 deletion example/uwp/extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
<Metadata>
<Identity Id="Telegram.Td.UWP" Version="1.7.10" Language="en-US" Publisher="Telegram LLC" />
<Identity Id="Telegram.Td.UWP" Version="1.7.11" Language="en-US" Publisher="Telegram LLC" />
<DisplayName>TDLib for Universal Windows Platform</DisplayName>
<Description>TDLib is a library for building Telegram clients</Description>
<MoreInfo>https://core.telegram.org/tdlib</MoreInfo>
Expand Down
2 changes: 1 addition & 1 deletion example/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You need a Unix shell with `sed`, `tar` and `wget` utilities to run the provided
## Building tdweb NPM package

* Install the 2.0.6 [emsdk](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html), which is known to work. Do not use the system-provided `emscripten` package, because it contains a too old emsdk version.
* Install all `TDLib` build dependencies described in [Building](https://github.com/tdlib/td#building).
* Install all `TDLib` build dependencies described in [Building](https://github.com/tdlib/td#building) and `sed`, `tar` and `wget` utilities.
* Run `source ./emsdk_env.sh` from `emsdk` directory to set up the correct build environment.
* On `macOS`, install the `coreutils` [Homebrew](https://brew.sh) package and replace `realpath` in scripts with `grealpath`:
```
Expand Down
Loading

0 comments on commit b308720

Please sign in to comment.