ci(wtr): fix cargo build PowerShell script and add x86 triple mapping

Two fixes:
1. Replace splat-array invocation with explicit if/else branches.
   The splat was passing a malformed argument (cargo's clap reported
   'unexpected argument "-"').
2. Add 'x86' -> 'i686-pc-windows-msvc' case in the switch and include
   that target in RustInstaller's additionalTargets. The pipeline matrix
   builds x86 too, not just x64/arm64.

Also added a LASTEXITCODE check so cargo build failures surface
properly even with ErrorActionPreference set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Gordon Lam (SH)
2026-05-11 11:22:47 +08:00
parent 754fff6915
commit 31aba26780

View File

@@ -209,7 +209,7 @@ jobs:
# Instead, the registry + source replacement lives in
# src/tools/wtr/.cargo/config.toml — CargoAuthenticate@0 (next step)
# tokens it, and cargo's normal config-file resolution picks it up.
additionalTargets: 'x86_64-pc-windows-msvc aarch64-pc-windows-msvc'
additionalTargets: 'x86_64-pc-windows-msvc i686-pc-windows-msvc aarch64-pc-windows-msvc'
# CargoAuthenticate issues a Bearer token (using System.AccessToken) for
# every Azure Artifacts Cargo feed referenced in the config file.
@@ -230,12 +230,18 @@ jobs:
$ErrorActionPreference = 'Stop'
$triple = switch ('$(BuildPlatform)') {
'x64' { 'x86_64-pc-windows-msvc' }
'x86' { 'i686-pc-windows-msvc' }
'arm64' { 'aarch64-pc-windows-msvc' }
default { 'x86_64-pc-windows-msvc' }
}
$profileArg = if ('$(BuildConfiguration)' -eq 'Debug') { @() } else { @('--release') }
Write-Host "Building wtr for $triple ($('$(BuildConfiguration)'))"
cargo build --manifest-path src/tools/wtr/Cargo.toml --target $triple --frozen @profileArg
$config = '$(BuildConfiguration)'
Write-Host "Building wtr for $triple ($config)"
if ($config -eq 'Release') {
cargo build --manifest-path src/tools/wtr/Cargo.toml --target $triple --frozen --release
} else {
cargo build --manifest-path src/tools/wtr/Cargo.toml --target $triple --frozen
}
if ($LASTEXITCODE -ne 0) { throw "cargo build failed with exit code $LASTEXITCODE" }
displayName: Build src/tools/wtr (Cargo)
- template: .\steps-install-vcpkg.yml