diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-04 19:24:05 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-04 19:24:05 +0300 |
commit | efc336e60cf1331bf5f3213d296981b87b8b2a6c (patch) | |
tree | ea59ea1a324f45f6e8a06cc0887b376bfba90ca9 /protocols/Telegram/tdlib/td/example/uwp | |
parent | 6e83622d2af1cec3c759f4cff6efe4df2fe3328c (diff) |
fixes #3537 (Telegram: 32-разрядная версия падает в 64-разрядной Windows) + update to the fresh TDLIB
Diffstat (limited to 'protocols/Telegram/tdlib/td/example/uwp')
8 files changed, 84 insertions, 18 deletions
diff --git a/protocols/Telegram/tdlib/td/example/uwp/README.md b/protocols/Telegram/tdlib/td/example/uwp/README.md index c0b4de723f..3faa890d51 100644 --- a/protocols/Telegram/tdlib/td/example/uwp/README.md +++ b/protocols/Telegram/tdlib/td/example/uwp/README.md @@ -6,13 +6,15 @@ This is an example of building TDLib SDK for Universal Windows Platform and an e * Download and install Microsoft Visual Studio 2015+ with Windows 10 SDK. We recommend to use the latest available versions of Microsoft Visual Studio and Windows 10 SDK. * Download and install [CMake](https://cmake.org/download/). -* Install [vcpkg](https://github.com/Microsoft/vcpkg#quick-start) or update it to the latest version using `vcpkg update` and following received instructions. -* Install `zlib` and `openssl` for all UWP architectures and `gperf` for x86 using `vcpkg`: +* Install `zlib` and `openssl` for all UWP architectures and `gperf` for x86 using [vcpkg](https://github.com/Microsoft/vcpkg#quick-start): ``` -cd <path to vcpkg> +git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +git checkout 1b1ae50e1a69f7c659bd7d731e80b358d21c86ad +.\bootstrap-vcpkg.bat .\vcpkg.exe install gperf:x86-windows openssl:arm-uwp openssl:arm64-uwp openssl:x64-uwp openssl:x86-uwp zlib:arm-uwp zlib:arm64-uwp zlib:x64-uwp zlib:x86-uwp ``` -* (Optional. For XML documentation generation.) Download [PHP](https://windows.php.net/download#php-7.2). Add the path to php.exe to the PATH environment variable. +* (Optional. For XML documentation generation.) Download [PHP](https://windows.php.net/download). Add the path to php.exe to the PATH environment variable. * Download and install [7-Zip](http://www.7-zip.org/download.html) archiver, which is used by the `build.ps1` script to create a Telegram.Td.UWP Visual Studio Extension. Add the path to 7z.exe to the PATH environment variable. Alternatively `build.ps1` supports compressing using [WinRAR](https://en.wikipedia.org/wiki/WinRAR) with option `-compress winrar` and compressing using [zip](http://gnuwin32.sourceforge.net/packages/zip.htm) with `-compress zip`. * Build `TDLib` using provided `build.ps1` script (TDLib should be built 6 times for multiple platforms in Debug and Release configurations, so it make take few hours). Pass path to vcpkg.exe as `-vcpkg-root` argument, for example: @@ -22,7 +24,10 @@ powershell -ExecutionPolicy ByPass .\build.ps1 -vcpkg_root C:\vcpkg 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. +After this `TDLib` can be used from any UWP project, built in Visual Studio. + +Alternatively, you can build `TDLib` as a NuGet package, adding the option `-nupkg` to the `.\build.ps1` script invocation. The resulting package will be placed in the directory `build-uwp\nupkg`. ## Example of usage + The `app/` directory contains a simple example of a C# application for Universal Windows Platform. Just open it with Visual Studio 2015 or later and run. diff --git a/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.nuspec b/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.nuspec new file mode 100644 index 0000000000..039ec2adaf --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.nuspec @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd"> + <metadata> + <id>Telegram.Td.UWP</id> + <version>1.8.14</version> + <title>TDLib for Universal Windows Platform</title> + <authors>Telegram</authors> + <owners>Telegram</owners> + <requireLicenseAcceptance>false</requireLicenseAcceptance> + <license type="file">LICENSE_1_0.txt</license> + <projectUrl>https://core.telegram.org/tdlib</projectUrl> + <releaseNotes>https://github.com/tdlib/td/blob/master/CHANGELOG.md</releaseNotes> + <description>TDLib for Universal Windows Platform</description> + <copyright>© Telegram FZ-LLC. All rights reserved.</copyright> + </metadata> +</package>
\ No newline at end of file diff --git a/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.targets b/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.targets new file mode 100644 index 0000000000..3ad7f3e95d --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/uwp/Telegram.Td.UWP.targets @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <PropertyGroup> + <TelegramTdPlatform Condition="'$(Platform)' == 'Win32'">x86</TelegramTdPlatform> + <TelegramTdPlatform Condition="'$(Platform)' != 'Win32'">$(Platform)</TelegramTdPlatform> + <OpenSSLPlatform Condition="'$(Platform)' == 'Win32'"></OpenSSLPlatform> + <OpenSSLPlatform Condition="'$(Platform)' != 'Win32'">-$(Platform)</OpenSSLPlatform> + </PropertyGroup> + + <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'UAP'"> + <Reference Include="$(MSBuildThisFileDirectory)..\..\lib\uap10.0\Telegram.Td.winmd"> + <Implementation>Telegram.Td.dll</Implementation> + </Reference> + <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\Telegram.Td.dll" /> + <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\libcrypto-1_1$(OpenSSLPlatform).dll" /> + <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\libssl-1_1$(OpenSSLPlatform).dll" /> + <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(TelegramTdPlatform)\native\zlib1.dll" /> + </ItemGroup> + +</Project>
\ No newline at end of file diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs index 5bfc66a30f..faaa46cab0 100644 --- a/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs +++ b/protocols/Telegram/tdlib/td/example/uwp/app/App.xaml.cs @@ -1,5 +1,5 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs b/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs index 4c42e27676..e4218386e3 100644 --- a/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs +++ b/protocols/Telegram/tdlib/td/example/uwp/app/MainPage.xaml.cs @@ -1,5 +1,5 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -85,11 +85,6 @@ namespace TdApp AcceptCommand("LogOut"); _client.Send(new TdApi.LogOut(), _handler); } - else if (command.StartsWith("gas")) - { - AcceptCommand(command); - _client.Send(new TdApi.GetAuthorizationState(), _handler); - } else if (command.StartsWith("sap")) { var args = command.Split(" ".ToCharArray(), 2); diff --git a/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs b/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs index 2e008d1a29..14a02677cd 100644 --- a/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs +++ b/protocols/Telegram/tdlib/td/example/uwp/app/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("App2")] -[assembly: AssemblyCopyright("Copyright © 2015-2022")] +[assembly: AssemblyCopyright("Copyright © 2015-2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/protocols/Telegram/tdlib/td/example/uwp/build.ps1 b/protocols/Telegram/tdlib/td/example/uwp/build.ps1 index 587945a4b2..463592fa3d 100644 --- a/protocols/Telegram/tdlib/td/example/uwp/build.ps1 +++ b/protocols/Telegram/tdlib/td/example/uwp/build.ps1 @@ -3,7 +3,8 @@ param ( [string]$arch = "", [string]$mode = "all", [string]$compress = "7z", - [switch]$release_only = $false + [switch]$release_only = $false, + [switch]$nupkg = $false ) $ErrorActionPreference = "Stop" @@ -15,7 +16,7 @@ if ($arch) { $arch_list = @(, $arch) } $config_list = @( "Debug", "Release" ) -if ($release_only) { +if ($release_only -or $nupkg) { $config_list = @(, "RelWithDebInfo") } $targets = @{ Debug = "Debug"; Release = "Retail"; RelWithDebInfo = "CommonConfiguration"} @@ -77,13 +78,14 @@ function build { cd $arch ForEach ($config in $config_list) { cmake --build . --config $config --target tddotnet + CheckLastExitCode } cd .. } cd .. } -function export { +function export-vsix { cd build-uwp Remove-Item vsix -Force -Recurse -ErrorAction SilentlyContinue New-Item -ItemType Directory -Force -Path vsix @@ -119,6 +121,29 @@ function export { cd .. } +function export-nupkg { + cd build-uwp + Remove-Item nupkg -Force -Recurse -ErrorAction SilentlyContinue + New-Item -ItemType Directory -Force -Path nupkg/build/native + cp ../LICENSE_1_0.txt nupkg + cp ../Telegram.Td.UWP.nuspec nupkg + cp ../Telegram.Td.UWP.targets nupkg/build/native + + ForEach ($arch in $arch_list) { + New-Item -ItemType Directory -Force -Path nupkg/runtimes/win10-${arch}/native + New-Item -ItemType Directory -Force -Path nupkg/lib/uap10.0 + + ForEach ($config in $config_list) { + cp ${arch}/${config}/* -include "SSLEAY*","LIBEAY*","libcrypto*","libssl*","zlib*","Telegram.Td.pdb","Telegram.Td.pri","Telegram.Td.dll" nupkg/runtimes/win10-${arch}/native + cp ${arch}/${config}/* -include "Telegram.Td.winmd","Telegram.Td.xml" nupkg/lib/uap10.0 + } + } + + cd nupkg + nuget pack Telegram.Td.UWP.nuspec + cd .. +} + function run { Push-Location Try { @@ -135,7 +160,11 @@ function run { build } if (($mode -eq "export") -or ($mode -eq "all")) { - export + if ($nupkg) { + export-nupkg + } else { + export-vsix + } } } Finally { Pop-Location diff --git a/protocols/Telegram/tdlib/td/example/uwp/extension.vsixmanifest b/protocols/Telegram/tdlib/td/example/uwp/extension.vsixmanifest index 28cacff65f..66c434a164 100644 --- a/protocols/Telegram/tdlib/td/example/uwp/extension.vsixmanifest +++ b/protocols/Telegram/tdlib/td/example/uwp/extension.vsixmanifest @@ -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.8.8" Language="en-US" Publisher="Telegram LLC" /> + <Identity Id="Telegram.Td.UWP" Version="1.8.14" 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> |