-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathGet-TlFiles.ps1
More file actions
50 lines (41 loc) · 1.36 KB
/
Get-TlFiles.ps1
File metadata and controls
50 lines (41 loc) · 1.36 KB
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
# SPDX-FileCopyrightText: 2024-2025 tdsharp contributors <https://github.com/egramtel/tdsharp>
#
# SPDX-License-Identifier: MIT
param(
[string] $CommitHash = '89e7366783e13d63085878ba407da83107ccd401',
[string] $TdApiUrl = "https://github.com/tdlib/td/raw/$CommitHash/td/generate/scheme/td_api.tl",
[string] $SourceRoot = "$PSScriptRoot/..",
[string] $CodeGenPath = "$SourceRoot/TdLib.CodeGen"
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$apiText = (Invoke-WebRequest $TdApiUrl).Content -split "\r?\n"
$targetFile = "$CodeGenPath/Types.tl"
$skipInitialLines = $true
Remove-Item $targetFile
$emptyLineBuffer = @()
foreach ($line in $apiText) {
if ($line.Trim() -eq '---functions---') {
$targetFile = "$CodeGenPath/Methods.tl"
Remove-Item $targetFile
$skipInitialLines = $true
$emptyLineBuffer = @()
continue
}
if ($line.Trim() -eq '') {
if ($skipInitialLines) {
continue
}
$emptyLineBuffer += $line
continue
} else {
$skipInitialLines = $false
if ($emptyLineBuffer.Length -ge 0) {
foreach ($emptyLine in $emptyLineBuffer) {
$emptyLine | Out-File $targetFile -Encoding utf8 -Append
}
$emptyLineBuffer = @()
}
}
$line | Out-File $targetFile -Encoding utf8 -Append
}