-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcsharp.ps1
105 lines (89 loc) · 3.52 KB
/
csharp.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Note: in functions app used Set-Location instead of cd because of Powershell analyser problem in VSCode
function Build-TdLib {
param ($arch, $outputDir)
# Initializing folder
Remove-Item $outputDir -Force -Recurse -ErrorAction SilentlyContinue
mkdir $outputDir
Remove-Item build -Force -Recurse -ErrorAction SilentlyContinue
mkdir build
cd build
# Building
cmake -A $arch -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE:FILEPATH=./vcpkg/scripts/buildsystems/vcpkg.cmake ../td
cmake --build . --target install --config Release
Set-Location ..
git checkout td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h
}
function Install-TdLib {
param ($arch)
if ($arch -eq 'Win32') {
$arch = 'x86'
}
$td = './td'
"$td"
if (Test-Path -Path $td) {
Set-Location td
git pull
} else {
git clone https://github.com/tdlib/td.git
Set-Location td
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
git checkout cd5e746ec203c8c3c61647e0886a8df8c1e78e41
.\bootstrap-vcpkg.bat
.\vcpkg.exe install gperf:$arch-windows openssl:$arch-windows zlib:$arch-windows
}
cd ..
}
function Show-Help {
"This is help message in C# Building Script"
"You'll need to install git and cmake"
"You should has at least 1.5 GB free needed for building"
"Building may reinstall vcpkg.exe"
"/o <string> === New output folder name, Default = build + arch + csharp [Optional]"
"/a <string> === Building architicture (`x64` Or `x86`) [Optional]"
"/v <string> === Version (i.e. 1.11.0, v1.7.9) [Optional]"
"/h || /help === Show this help message and exit"
}
# Archiricture should be "x64" Or "Win32" ONLY
$buildArch = 'x64'
$outputFolder = "./c#/new/release/"
$version = 'New'
# Reading command line input
for ($i = 0; $i -lt $args.count; $i++) {
# Output
if ($args[$i] -eq "/o"){ $outputFolder = $args[ $i+1 ]}
if ($args[$i] -eq "-o"){ $outputFolder = $args[ $i+1 ]}
if ($args[$i] -eq "/out"){ $outputFolder = $args[ $i+1 ]}
if ($args[$i] -eq "--out"){ $outputFolder = $args[ $i+1 ]}
# Arch
if ($args[$i] -eq "/a"){ $buildArch = $args[ $i+1 ]}
if ($args[$i] -eq "-a"){ $buildArch = $args[ $i+1 ]}
if ($args[$i] -eq "/arch"){ $buildArch = $args[ $i+1 ]}
if ($args[$i] -eq "--arch"){ $buildArch = $args[ $i+1 ]}
# Version
if ($args[$i] -eq "/v"){ $version = $args[ $i+1 ]}
if ($args[$i] -eq "-v"){ $version = $args[ $i+1 ]}
if ($args[$i] -eq "/version"){ $version = $args[ $i+1 ]}
if ($args[$i] -eq "--version"){ $version = $args[ $i+1 ]}
# Help
if ($args[$i] -eq "-h"){ Show-Help; exit }
if ($args[$i] -eq "/h"){ Show-Help; exit }
if ($args[$i] -eq "--help"){ Show-Help; exit }
if ($args[$i] -eq "/help"){ Show-Help; exit }
}
# Fixing user error
if ($buildArch -eq 'x86') { $buildArch = 'Win32' }
# Check wrong architctures before building
if ($buildArch -ne 'Win32' -And $buildArch -ne 'x64') {
"Error: Architicture should be x64 Or x86 (Win32) ONLY, $buildArch isn't acceptable"
exit 1
}
"Installing TDLib.."
Install-TdLib $buildArch
"Building C# $buildArch Release.."
Build-TdLib $buildArch $outputFolder
"Binaries are ready in ./td/bin/"
if ($buildArch -eq 'Win32') { $buildArch = 'x86' }
$copyFolder = "./c#/windows/v$version/$buildArch/release/"
"Binaries should be copied into $copyFolder"
# Coping output from td/bin/ to $copyFolder