diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a7fa9402..eb834a743 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,6 +209,9 @@ add_subdirectory(td/generate) if (NOT CMAKE_CROSSCOMPILING) add_custom_target(prepare_cross_compiling DEPENDS tl_generate_common tdmime_auto) + if (TD_ENABLE_DOTNET) + add_dependencies(prepare_cross_compiling generate_dotnet_api) + endif() endif() if (NOT OPENSSL_FOUND) diff --git a/example/uwp/SDKManifest.xml b/example/uwp/SDKManifest.xml new file mode 100644 index 000000000..097ee050d --- /dev/null +++ b/example/uwp/SDKManifest.xml @@ -0,0 +1,12 @@ + + + + diff --git a/example/uwp/[Content_Types].xml b/example/uwp/[Content_Types].xml new file mode 100644 index 000000000..b91d46fa3 --- /dev/null +++ b/example/uwp/[Content_Types].xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/example/uwp/build.ps1 b/example/uwp/build.ps1 new file mode 100644 index 000000000..fd6fda566 --- /dev/null +++ b/example/uwp/build.ps1 @@ -0,0 +1,135 @@ +param ( + [string]$vcpkg_root = $(throw "-vcpkg_root= is required"), + [string]$arch = "", + [string]$mode = "all" +) +$ErrorActionPreference = "Stop" + +$vcpkg_root = Resolve-Path $vcpkg_root + +$vcpkg_cmake="${vcpkg_root}\scripts\buildsystems\vcpkg.cmake" +$arch_list = @( "x86", "x64", "arm" ) +if ($arch) { + $arch_list = @(, $arch) +} + +$td_root = Resolve-Path "../.." + +function CheckLastExitCode { + if ($LastExitCode -ne 0) { + $msg = @" +EXE RETURNED EXIT CODE $LastExitCode +CALLSTACK:$(Get-PSCallStack | Out-String) +"@ + throw $msg + } +} + +function clean { + Remove-Item build-* -Force -Recurse -ErrorAction SilentlyContinue +} + +function prepare { + New-Item -ItemType Directory -Force -Path build-native + + cd build-native + + cmake $td_root -DCMAKE_TOOLCHAIN_FILE="$vcpkg_cmake" -DTD_ENABLE_DOTNET=1 + CheckLastExitCode + cmake --build . --target prepare_cross_compiling + CheckLastExitCode + + cd .. +} + +function config { + New-Item -ItemType Directory -Force -Path build-uwp + cd build-uwp + + ForEach($arch in $arch_list) { + echo "Config Arch = [$arch]" + Remove-Item $arch -Force -Recurse -ErrorAction SilentlyContinue + New-Item -ItemType Directory -Force -Path $arch + cd $arch + echo "${td_root}" + $fixed_arch = $arch + if ($arch -eq "x86") { + $fixed_arch = "win32" + } + cmake "$td_root" -A $fixed_arch -DCMAKE_SYSTEM_VERSION="10.0" -DCMAKE_SYSTEM_NAME="WindowsStore" -DCMAKE_TOOLCHAIN_FILE="$vcpkg_cmake" -DTD_ENABLE_DOTNET=1 + CheckLastExitCode + cd .. + } + echo "done" + cd .. +} + +function build { + cd build-uwp + ForEach($arch in $arch_list) { + echo "Build Arch = [$arch]" + cd $arch + cmake --build . --config Release --target tddotnet + cmake --build . --config Debug --target tddotnet + cd .. + } + cd .. +} + +function export { + cd build-uwp + Remove-Item vsix -Force -Recurse -ErrorAction SilentlyContinue + mkdir vsix + cp ../SDKManifest.xml vsix + cp ../extension.vsixmanifest vsix + cp '../`[Content_Types`].xml' vsix + + ForEach($arch in $arch_list) { + New-Item -ItemType Directory -Force -Path vsix/DesignTime/Debug/${arch} + New-Item -ItemType Directory -Force -Path vsix/DesignTime/Retail/${arch} + New-Item -ItemType Directory -Force -Path vsix/Redist/Debug/${arch} + New-Item -ItemType Directory -Force -Path vsix/Redist/Retail/${arch} + New-Item -ItemType Directory -Force -Path vsix/References/CommonConfiguration/${arch} + + cp ${arch}/Debug/* -filter "tddotnet.*" -include "*.lib" vsix/DesignTime/Debug/${arch}/ + cp ${arch}/Release/* -filter "tddotnet.*" -include "*.lib" vsix/DesignTime/Retail/${arch}/ + + cp ${arch}/Debug/* -filter "tddotnet.*" -include "*.pdb","*.dll" vsix/Redist/Debug/${arch}/ + cp ${arch}/Release/* -filter "tddotnet.*" -include "*.pdb","*.dll" vsix/Redist/Retail/${arch}/ + + cp ${arch}/Release/* -filter "tddotnet.*" -include "*.pri","*.winmd" vsix/References/CommonConfiguration/${arch}/ + } + + cd vsix + + 7z.exe a -tzip -r tdlib.vsix * + #zip -r tdlib.vsix * + #WinRAR.exe a -afzip -r -ep1 tdlib.vsix * + cd .. +} + +function run { + Push-Location + Try { + if (($mode -eq "clean") -or ($mode -eq "all")) { + clean + } + if (($mode -eq "prepare") -or ($mode -eq "all")) { + prepare + } + if (($mode -eq "config") -or ( $mode -eq "all")) { + config + } + if (($mode -eq "build") -or ($mode -eq "all")) { + build + } + if (($mode -eq "export") -or ($mode -eq "all")) { + export + } + } Finally { + Pop-Location + } +} + +run + diff --git a/example/uwp/extension.vsixmanifest b/example/uwp/extension.vsixmanifest new file mode 100644 index 000000000..eb95ad712 --- /dev/null +++ b/example/uwp/extension.vsixmanifest @@ -0,0 +1,15 @@ + + + + TDLib for Universal Windows Platform + TDLib is a library for building Telegram clients + https://core.telegram.org/tdlib + Telegram, TDLib + + + + + + + + diff --git a/tdutils/td/utils/port/Stat.cpp b/tdutils/td/utils/port/Stat.cpp index 0005d9633..28ef069e1 100644 --- a/tdutils/td/utils/port/Stat.cpp +++ b/tdutils/td/utils/port/Stat.cpp @@ -288,8 +288,8 @@ Result cpu_stat() { return Status::Error("Not supported"); #endif } -#endif } +#endif #if TD_PORT_WINDOWS namespace td {