Files
rusty-path-of-building/packaging/windows/build.ps1
T
faumaray ebf33b62dc
CI / check (push) Successful in 1m28s
CI / windows (push) Successful in 3m27s
Native release / linux (push) Successful in 1m29s
Native release / windows (push) Successful in 3m1s
Native release / publish (push) Successful in 9s
Let the CI Python distribution locate its packaging interpreter
2026-11-27 23:43:54 +03:00

45 lines
2.5 KiB
PowerShell

param(
[string]$OutputDirectory = (Join-Path $PSScriptRoot '..\..\target\dist'),
[string[]]$DllDirectory = @()
)
$ErrorActionPreference = 'Stop'
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
$destination = [IO.Path]::GetFullPath($OutputDirectory)
$dllDirs = @($DllDirectory | ForEach-Object { (Resolve-Path -LiteralPath $_).Path })
if (-not [Environment]::Is64BitProcess) { throw 'Run this build in x64 PowerShell.' }
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$vs = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if ($LASTEXITCODE -ne 0 -or -not $vs) { throw 'Install the Visual Studio C++ x64 build tools and Windows SDK.' }
Import-Module (Join-Path $vs 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vs -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
# A short, fresh target path keeps link.exe below MAX_PATH on service-account runners.
$work = New-Item -ItemType Directory -Path (Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName()))
Push-Location $repo
try {
$env:CARGO_TARGET_DIR = Join-Path $work.FullName 'b'
# With --target, Cargo applies this to target crates only. The encoded setting
# takes precedence over inherited RUSTFLAGS, including on self-hosted runners.
$env:CARGO_ENCODED_RUSTFLAGS = '-Ctarget-feature=+crt-static'
$env:VCPKGRS_DISABLE = '1'
cargo build --locked --release --target x86_64-pc-windows-msvc --features vendored-lua,curl/static-curl
if ($LASTEXITCODE -ne 0) { throw "Windows build failed ($LASTEXITCODE)." }
$binary = Join-Path $env:CARGO_TARGET_DIR 'x86_64-pc-windows-msvc\release\rusty-path-of-building.exe'
# A third-party DLL can itself use the VC runtime. Use the selected toolset's
# app-local redistributables when needed, even on a host with a global redist.
if ($env:VCToolsRedistDir) {
$x64 = Join-Path $env:VCToolsRedistDir 'x64'
if (Test-Path -LiteralPath $x64) {
$dllDirs += @(Get-ChildItem -LiteralPath $x64 -Directory -Filter 'Microsoft.VC*.CRT' | ForEach-Object { $_.FullName })
}
}
python packaging/windows/package_release.py $work.FullName $binary $destination @dllDirs
if ($LASTEXITCODE -ne 0) { throw "Windows package creation or verification failed ($LASTEXITCODE)." }
} finally {
Pop-Location
Remove-Item -LiteralPath $work.FullName -Recurse -Force -ErrorAction Continue
}