Repository navigation
Expand file tree
/
Copy pathbuild.ps1
More file actions
134 lines (115 loc) · 4.75 KB
/
Copy pathbuild.ps1
File metadata and controls
134 lines (115 loc) · 4.75 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# QUICK- Build Script for Windows
#
# Usage:
# .\build.ps1 # Build with quiche (requires NASM, CMake)
# .\build.ps1 -Quinn # Build with Quinn fallback (pure Rust)
# .\build.ps1 -Docker # Build in Docker (Linux, most reliable)
# .\build.ps1 -Clean # Clean build
param(
[switch]$Quinn,
[switch]$Docker,
[switch]$Clean,
[switch]$Help
)
$ErrorActionPreference = "Stop"
if ($Help) {
Write-Host @"
QUICK- Build Script
Usage:
.\build.ps1 Build with quiche backend (default)
.\build.ps1 -Quinn Build with Quinn backend (pure Rust, easier)
.\build.ps1 -Docker Build in Docker container (Linux)
.\build.ps1 -Clean Clean build artifacts first
Requirements for quiche backend:
- CMake: winget install Kitware.CMake
- NASM: winget install NASM.NASM
- Visual Studio Build Tools or MSVC
Requirements for Quinn backend:
- Rust toolchain only
"@
exit 0
}
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "QUICK- TCP-over-QUIC Tunnel Build" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
if ($Clean) {
Write-Host "`n[Clean] Removing target directory..." -ForegroundColor Yellow
if (Test-Path "target") {
Remove-Item -Recurse -Force "target"
}
Write-Host "[Clean] Done" -ForegroundColor Green
}
if ($Docker) {
Write-Host "`n[Docker] Building in Linux container..." -ForegroundColor Yellow
$transport = if ($Quinn) { "quinn" } else { "quiche" }
docker build --build-arg TRANSPORT=$transport -t quick-tunnel .
Write-Host "`n[Docker] Extracting binaries..." -ForegroundColor Yellow
docker create --name quick-build quick-tunnel 2>$null
docker cp quick-build:/app/target/release/quick-entry ./quick-entry-linux
docker cp quick-build:/app/target/release/quick-exit ./quick-exit-linux
docker rm quick-build
Write-Host "`n[Docker] Build complete!" -ForegroundColor Green
Write-Host " Binaries: quick-entry-linux, quick-exit-linux"
exit 0
}
# Native Windows build
if ($Quinn) {
Write-Host "`n[Build] Using Quinn backend (pure Rust)..." -ForegroundColor Yellow
cargo build --release --no-default-features --features quinn-backend
} else {
# Check dependencies for quiche
Write-Host "`n[Check] Verifying dependencies..." -ForegroundColor Yellow
$cmake = Get-Command cmake -ErrorAction SilentlyContinue
if (-not $cmake) {
Write-Host "[Error] CMake not found. Install with: winget install Kitware.CMake" -ForegroundColor Red
Write-Host " Then restart PowerShell." -ForegroundColor Red
exit 1
}
Write-Host " CMake: $($cmake.Source)" -ForegroundColor Green
# Check NASM
$nasm = Get-Command nasm -ErrorAction SilentlyContinue
if (-not $nasm) {
# Try common paths
$nasmPaths = @(
"$env:ProgramFiles\NASM\nasm.exe",
"${env:ProgramFiles(x86)}\NASM\nasm.exe",
"$env:LOCALAPPDATA\Programs\NASM\nasm.exe"
)
foreach ($path in $nasmPaths) {
if (Test-Path $path) {
$nasmDir = Split-Path $path
Write-Host " NASM found at: $nasmDir" -ForegroundColor Yellow
Write-Host " Adding to PATH for this session..." -ForegroundColor Yellow
$env:Path = "$env:Path;$nasmDir"
$nasm = Get-Command nasm -ErrorAction SilentlyContinue
break
}
}
if (-not $nasm) {
Write-Host "[Error] NASM not found. Install with: winget install NASM.NASM" -ForegroundColor Red
Write-Host " Then restart PowerShell." -ForegroundColor Red
Write-Host " Or use: .\build.ps1 -Quinn (pure Rust, no NASM needed)" -ForegroundColor Yellow
exit 1
}
}
Write-Host " NASM: $(nasm -v 2>&1 | Select-Object -First 1)" -ForegroundColor Green
Write-Host "`n[Build] Using quiche backend..." -ForegroundColor Yellow
cargo build --release
}
if ($LASTEXITCODE -eq 0) {
Write-Host "`n========================================" -ForegroundColor Green
Write-Host "Build successful!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host "Binaries:"
Write-Host " target\release\quick-entry.exe"
Write-Host " target\release\quick-exit.exe"
Write-Host "`nTest with:"
Write-Host " # Terminal 1: Start exit proxy"
Write-Host " .\target\release\quick-exit.exe --acl-default-allow"
Write-Host ""
Write-Host " # Terminal 2: Start entry proxy"
Write-Host " .\target\release\quick-entry.exe --exit-addr localhost:8443"
} else {
Write-Host "`n[Error] Build failed" -ForegroundColor Red
exit 1
}