<# Идемпотентно доводит Windows-тулчейн до пинов из upstream.txt. Ставит/обновляет только то, что отсутствует или не совпадает по версии — поэтому после `bump-upstream.sh` (смена версии RustDesk -> возможно другой Flutter/vcpkg/LLVM) достаточно прогнать этот скрипт, и сборка соберётся новой версией. Ставит на S:\dev (C: тесный). VS Build Tools 2022 (MSVC+CMake) — предполагается уже установленной. Вызывается автоматически из build-windows.ps1; можно и вручную: pwsh -File scripts\provision-windows.ps1 #> [CmdletBinding()] param() $ErrorActionPreference = 'Stop' $root = Split-Path -Parent $PSScriptRoot # CIDR в NO_PROXY ломает WinHTTP-загрузчики (vcpkg bootstrap и т.п.); есть прямой инет. foreach ($p in 'HTTP_PROXY','HTTPS_PROXY','NO_PROXY','ALL_PROXY','http_proxy','https_proxy','no_proxy') { Set-Item "Env:$p" $null -EA SilentlyContinue } $pins = @{} Get-Content (Join-Path $root 'upstream.txt') | Where-Object { $_ -match '^\s*[A-Z]' } | ForEach-Object { $k,$v = $_ -split '=',2; $pins[$k.Trim()] = $v.Trim() } $FlutterHome = if ($env:FLUTTER_HOME) { $env:FLUTTER_HOME } else { 'S:\dev\flutter' } $VcpkgRoot = if ($env:VCPKG_ROOT) { $env:VCPKG_ROOT } else { 'S:\dev\vcpkg' } $LlvmRoot = 'S:\dev\LLVM' New-Item -ItemType Directory -Force 'S:\dev' | Out-Null Write-Host "== provision-windows == пины из upstream.txt (RustDesk $($pins['RUSTDESK_TAG']))" -ForegroundColor Cyan # --- Rust toolchain + rustfmt --- $rustV = $pins['RUST_VERSION'] if (-not ((rustup toolchain list) -match [regex]::Escape($rustV))) { Write-Host "[rust] ставлю $rustV..." -ForegroundColor Yellow rustup toolchain install "$rustV-x86_64-pc-windows-msvc" | Out-Null } else { Write-Host "[rust] $rustV уже есть" -ForegroundColor Green } rustup component add rustfmt --toolchain "$rustV-x86_64-pc-windows-msvc" | Out-Null # --- Flutter --- $flutterV = $pins['FLUTTER_VERSION'] $have = '' if (Test-Path "$FlutterHome\bin\flutter.bat") { $have = (& "$FlutterHome\bin\flutter.bat" --version 2>$null | Select-String -Pattern 'Flutter (\d+\.\d+\.\d+)').Matches.Groups[1].Value } if ($have -ne $flutterV) { Write-Host "[flutter] нужен $flutterV (есть '$have') — скачиваю..." -ForegroundColor Yellow if (Test-Path $FlutterHome) { Remove-Item -Recurse -Force $FlutterHome } $zip = "S:\dev\flutter_$flutterV.zip" Invoke-WebRequest -UseBasicParsing -Uri "https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_$flutterV-stable.zip" -OutFile $zip tar -xf $zip -C 'S:\dev' Remove-Item $zip & "$FlutterHome\bin\flutter.bat" --version 2>$null | Select-Object -First 1 | Out-Null # прогрев (докачка Dart SDK) } else { Write-Host "[flutter] $flutterV уже есть" -ForegroundColor Green } # --- LLVM (libclang для bindgen/ffigen; VS-бандл его не содержит) --- $llvmV = $pins['LLVM_VERSION'] $haveLlvm = '' if (Test-Path "$LlvmRoot\bin\clang.exe") { $haveLlvm = (& "$LlvmRoot\bin\clang.exe" --version 2>$null | Select-String -Pattern 'clang version (\d+\.\d+\.\d+)').Matches.Groups[1].Value } if ($haveLlvm -ne $llvmV -or -not (Test-Path "$LlvmRoot\bin\libclang.dll")) { Write-Host "[llvm] нужен $llvmV (есть '$haveLlvm') — ставлю..." -ForegroundColor Yellow if (Test-Path $LlvmRoot) { Remove-Item -Recurse -Force $LlvmRoot } $exe = "S:\dev\LLVM-$llvmV-win64.exe" Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmV/LLVM-$llvmV-win64.exe" -OutFile $exe Start-Process -FilePath $exe -ArgumentList '/S',"/D=$LlvmRoot" -Wait Remove-Item $exe -EA SilentlyContinue if (-not (Test-Path "$LlvmRoot\bin\libclang.dll")) { throw "LLVM $llvmV установился без libclang.dll" } } else { Write-Host "[llvm] $llvmV уже есть" -ForegroundColor Green } # --- vcpkg на нужном коммите --- $vcpkgC = $pins['VCPKG_COMMIT_ID'] if (-not (Test-Path "$VcpkgRoot\.git")) { Write-Host "[vcpkg] клонирую..." -ForegroundColor Yellow git clone --quiet https://github.com/microsoft/vcpkg.git $VcpkgRoot } $haveC = (git -C $VcpkgRoot rev-parse HEAD 2>$null) if ($haveC -ne $vcpkgC) { Write-Host "[vcpkg] checkout $vcpkgC (было $($haveC.Substring(0,[Math]::Min(8,$haveC.Length))))..." -ForegroundColor Yellow git -C $VcpkgRoot fetch --quiet origin git -C $VcpkgRoot checkout --quiet $vcpkgC Remove-Item "$VcpkgRoot\vcpkg.exe" -EA SilentlyContinue # tool перепривяжется под новый коммит } else { Write-Host "[vcpkg] на нужном коммите" -ForegroundColor Green } if (-not (Test-Path "$VcpkgRoot\vcpkg.exe")) { # bootstrap через WinHTTP исторически падает на прокси — тянем нужный vcpkg.exe напрямую (IWR). $tag = (Get-Content "$VcpkgRoot\scripts\vcpkg-tool-metadata.txt" -Raw | Select-String 'VCPKG_TOOL_RELEASE_TAG=(\S+)').Matches.Groups[1].Value Write-Host "[vcpkg] тяну vcpkg.exe (tool $tag)..." -ForegroundColor Yellow Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/microsoft/vcpkg-tool/releases/download/$tag/vcpkg.exe" -OutFile "$VcpkgRoot\vcpkg.exe" Set-Content "$VcpkgRoot\vcpkg-version.txt" $tag -NoNewline } Write-Host "== provision-windows: тулчейн соответствует пинам ==" -ForegroundColor Cyan