2018-02-28 19:19:33 +01:00
|
|
|
param (
|
|
|
|
[string]$vcpkg_root = $(throw "-vcpkg_root=<path to vcpkg> is required"),
|
|
|
|
[string]$arch = "",
|
2018-03-07 12:31:57 +01:00
|
|
|
[string]$mode = "all",
|
2021-05-10 22:41:32 +02:00
|
|
|
[string]$compress = "7z",
|
2023-03-22 14:53:22 +01:00
|
|
|
[switch]$release_only = $false,
|
|
|
|
[switch]$nupkg = $false
|
2018-02-28 19:19:33 +01:00
|
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
|
|
$vcpkg_root = Resolve-Path $vcpkg_root
|
|
|
|
|
|
|
|
$vcpkg_cmake="${vcpkg_root}\scripts\buildsystems\vcpkg.cmake"
|
2018-09-05 14:21:31 +02:00
|
|
|
$arch_list = @( "x86", "x64", "ARM" )
|
2018-02-28 19:19:33 +01:00
|
|
|
if ($arch) {
|
|
|
|
$arch_list = @(, $arch)
|
|
|
|
}
|
2021-05-11 02:24:47 +02:00
|
|
|
$config_list = @( "Debug", "Release" )
|
2023-03-22 14:53:22 +01:00
|
|
|
if ($release_only -or $nupkg) {
|
2021-05-11 02:24:47 +02:00
|
|
|
$config_list = @(, "RelWithDebInfo")
|
|
|
|
}
|
|
|
|
$targets = @{ Debug = "Debug"; Release = "Retail"; RelWithDebInfo = "CommonConfiguration"}
|
2018-02-28 19:19:33 +01:00
|
|
|
|
|
|
|
$td_root = Resolve-Path "../.."
|
|
|
|
|
|
|
|
function CheckLastExitCode {
|
|
|
|
if ($LastExitCode -ne 0) {
|
2018-03-07 11:50:21 +01:00
|
|
|
$msg = @"
|
2018-02-28 19:19:33 +01:00
|
|
|
EXE RETURNED EXIT CODE $LastExitCode
|
|
|
|
CALLSTACK:$(Get-PSCallStack | Out-String)
|
|
|
|
"@
|
2018-03-07 11:50:21 +01:00
|
|
|
throw $msg
|
2018-02-28 19:19:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clean {
|
|
|
|
Remove-Item build-* -Force -Recurse -ErrorAction SilentlyContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepare {
|
|
|
|
New-Item -ItemType Directory -Force -Path build-native
|
|
|
|
|
|
|
|
cd build-native
|
|
|
|
|
2022-08-16 12:28:34 +02:00
|
|
|
cmake -A Win32 -DCMAKE_TOOLCHAIN_FILE="$vcpkg_cmake" -DTD_ENABLE_DOTNET=ON "$td_root"
|
2018-02-28 19:19:33 +01:00
|
|
|
CheckLastExitCode
|
2018-03-02 14:55:55 +01:00
|
|
|
cmake --build . --target prepare_cross_compiling
|
2018-02-28 19:19:33 +01:00
|
|
|
CheckLastExitCode
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
function config {
|
|
|
|
New-Item -ItemType Directory -Force -Path build-uwp
|
|
|
|
cd build-uwp
|
2018-03-02 14:55:55 +01:00
|
|
|
|
2021-05-11 02:24:47 +02:00
|
|
|
ForEach ($arch in $arch_list) {
|
2018-02-28 19:19:33 +01:00
|
|
|
echo "Config Arch = [$arch]"
|
|
|
|
New-Item -ItemType Directory -Force -Path $arch
|
|
|
|
cd $arch
|
|
|
|
echo "${td_root}"
|
|
|
|
$fixed_arch = $arch
|
|
|
|
if ($arch -eq "x86") {
|
|
|
|
$fixed_arch = "win32"
|
|
|
|
}
|
2022-08-16 12:28:34 +02:00
|
|
|
cmake -A $fixed_arch -DCMAKE_SYSTEM_VERSION="10.0" -DCMAKE_SYSTEM_NAME="WindowsStore" -DCMAKE_TOOLCHAIN_FILE="$vcpkg_cmake" -DTD_ENABLE_DOTNET=ON "$td_root"
|
2018-02-28 19:19:33 +01:00
|
|
|
CheckLastExitCode
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
echo "done"
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
function build {
|
|
|
|
cd build-uwp
|
2021-05-11 02:24:47 +02:00
|
|
|
ForEach ($arch in $arch_list) {
|
2018-02-28 19:19:33 +01:00
|
|
|
echo "Build Arch = [$arch]"
|
|
|
|
cd $arch
|
2021-05-11 02:24:47 +02:00
|
|
|
ForEach ($config in $config_list) {
|
|
|
|
cmake --build . --config $config --target tddotnet
|
2023-05-03 13:46:03 +02:00
|
|
|
CheckLastExitCode
|
2021-05-10 22:41:32 +02:00
|
|
|
}
|
2018-02-28 19:19:33 +01:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
2023-03-22 14:53:22 +01:00
|
|
|
function export-vsix {
|
2018-02-28 19:19:33 +01:00
|
|
|
cd build-uwp
|
|
|
|
Remove-Item vsix -Force -Recurse -ErrorAction SilentlyContinue
|
2018-03-17 00:00:09 +01:00
|
|
|
New-Item -ItemType Directory -Force -Path vsix
|
2018-03-02 14:55:55 +01:00
|
|
|
cp ../SDKManifest.xml vsix
|
2018-02-28 19:19:33 +01:00
|
|
|
cp ../extension.vsixmanifest vsix
|
|
|
|
cp '../`[Content_Types`].xml' vsix
|
2018-03-17 00:00:09 +01:00
|
|
|
cp ../LICENSE_1_0.txt vsix
|
2018-03-02 14:55:55 +01:00
|
|
|
|
2021-05-11 02:24:47 +02:00
|
|
|
ForEach ($arch in $arch_list) {
|
|
|
|
New-Item -ItemType Directory -Force -Path vsix/References/CommonConfiguration/${arch}
|
|
|
|
ForEach ($config in $config_list) {
|
|
|
|
$target = $targets[$config]
|
|
|
|
|
|
|
|
New-Item -ItemType Directory -Force -Path vsix/DesignTime/${target}/${arch}
|
|
|
|
cp ${arch}/${config}/Telegram.Td.lib vsix/DesignTime/${target}/${arch}/
|
|
|
|
|
|
|
|
New-Item -ItemType Directory -Force -Path vsix/Redist/${target}/${arch}
|
|
|
|
cp ${arch}/${config}/* -include "SSLEAY*","LIBEAY*","libcrypto*","libssl*","zlib*","Telegram.Td.pdb","Telegram.Td.dll" vsix/Redist/${target}/${arch}/
|
|
|
|
|
|
|
|
cp ${arch}/${config}/* -include "Telegram.Td.pri","Telegram.Td.winmd","Telegram.Td.xml" vsix/References/CommonConfiguration/${arch}/
|
2021-05-10 22:41:32 +02:00
|
|
|
}
|
2018-02-28 19:19:33 +01:00
|
|
|
}
|
2018-03-02 14:55:55 +01:00
|
|
|
|
2018-02-28 19:19:33 +01:00
|
|
|
cd vsix
|
2018-03-02 14:55:55 +01:00
|
|
|
|
2018-03-14 15:43:00 +01:00
|
|
|
if ($compress -eq "zip") {
|
2018-03-07 09:46:01 +01:00
|
|
|
zip -r tdlib.vsix *
|
2018-03-07 12:31:57 +01:00
|
|
|
} elseif ($compress -eq "winrar") {
|
2018-03-07 09:46:01 +01:00
|
|
|
WinRAR.exe a -afzip -r -ep1 tdlib.vsix *
|
|
|
|
} else {
|
|
|
|
7z.exe a -tzip -r tdlib.vsix *
|
|
|
|
}
|
2018-02-28 19:19:33 +01:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
2023-03-22 14:53:22 +01:00
|
|
|
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 ..
|
|
|
|
}
|
|
|
|
|
2018-02-28 19:19:33 +01:00
|
|
|
function run {
|
|
|
|
Push-Location
|
|
|
|
Try {
|
2018-03-07 12:31:57 +01:00
|
|
|
if ($mode -eq "clean") {
|
|
|
|
clean
|
|
|
|
}
|
2018-02-28 19:19:33 +01:00
|
|
|
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")) {
|
2023-03-22 14:53:22 +01:00
|
|
|
if ($nupkg) {
|
|
|
|
export-nupkg
|
|
|
|
} else {
|
|
|
|
export-vsix
|
|
|
|
}
|
2018-02-28 19:19:33 +01:00
|
|
|
}
|
|
|
|
} Finally {
|
|
|
|
Pop-Location
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run
|