|
| 1 | +name: Windows packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + package: |
| 10 | + name: Package ${{ matrix.label }} |
| 11 | + runs-on: windows-latest |
| 12 | + timeout-minutes: 60 |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - label: windows-x64 |
| 19 | + rust_target: x86_64-pc-windows-msvc |
| 20 | + nuget_arch: amd64 |
| 21 | + vcvars_arch: x64 |
| 22 | + artifact: windbg-tool-windows-x64 |
| 23 | + can_run: true |
| 24 | + - label: windows-arm64 |
| 25 | + rust_target: aarch64-pc-windows-msvc |
| 26 | + nuget_arch: arm64 |
| 27 | + vcvars_arch: x64_arm64 |
| 28 | + artifact: windbg-tool-windows-arm64 |
| 29 | + can_run: false |
| 30 | + |
| 31 | + env: |
| 32 | + CARGO_TERM_COLOR: always |
| 33 | + RUSTFLAGS: -C target-feature=+crt-static |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v5 |
| 38 | + |
| 39 | + - name: Select stable Rust |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + rustup default stable |
| 43 | + rustup target add ${{ matrix.rust_target }} |
| 44 | +
|
| 45 | + - name: Restore debugger dependencies |
| 46 | + shell: pwsh |
| 47 | + run: cargo xtask deps --arch ${{ matrix.nuget_arch }} |
| 48 | + |
| 49 | + - name: Ensure ARM64 MSVC toolset |
| 50 | + if: matrix.nuget_arch == 'arm64' |
| 51 | + shell: pwsh |
| 52 | + run: | |
| 53 | + $ErrorActionPreference = 'Stop' |
| 54 | + $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' |
| 55 | + $installer = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vs_installer.exe' |
| 56 | + if (-not (Test-Path $vswhere)) { |
| 57 | + throw "vswhere.exe was not found at $vswhere" |
| 58 | + } |
| 59 | + if (-not (Test-Path $installer)) { |
| 60 | + throw "vs_installer.exe was not found at $installer" |
| 61 | + } |
| 62 | + $installationPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath |
| 63 | + if (-not $installationPath) { |
| 64 | + throw 'Could not find a Visual Studio installation with the MSVC x64 toolset' |
| 65 | + } |
| 66 | + & $installer modify ` |
| 67 | + --installPath $installationPath ` |
| 68 | + --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ` |
| 69 | + --quiet ` |
| 70 | + --norestart ` |
| 71 | + --nocache ` |
| 72 | + --wait |
| 73 | + if (($LASTEXITCODE -ne 0) -and ($LASTEXITCODE -ne 3010)) { |
| 74 | + exit $LASTEXITCODE |
| 75 | + } |
| 76 | +
|
| 77 | + - name: Build native bridge |
| 78 | + shell: pwsh |
| 79 | + run: | |
| 80 | + $ErrorActionPreference = 'Stop' |
| 81 | + $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' |
| 82 | + $installationPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath |
| 83 | + if (-not $installationPath) { |
| 84 | + throw 'Could not find a Visual Studio installation with the MSVC x64 toolset' |
| 85 | + } |
| 86 | + $vcvars = Join-Path $installationPath 'VC\Auxiliary\Build\vcvarsall.bat' |
| 87 | + cmd /c "`"$vcvars`" ${{ matrix.vcvars_arch }} && cargo xtask native-build --arch ${{ matrix.nuget_arch }} --static-crt" |
| 88 | +
|
| 89 | + - name: Build windbg-tool |
| 90 | + shell: pwsh |
| 91 | + run: | |
| 92 | + $ErrorActionPreference = 'Stop' |
| 93 | + $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' |
| 94 | + $installationPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath |
| 95 | + if (-not $installationPath) { |
| 96 | + throw 'Could not find a Visual Studio installation with the MSVC x64 toolset' |
| 97 | + } |
| 98 | + $vcvars = Join-Path $installationPath 'VC\Auxiliary\Build\vcvarsall.bat' |
| 99 | + cmd /c "`"$vcvars`" ${{ matrix.vcvars_arch }} && cargo build -p windbg-tool --release --target ${{ matrix.rust_target }}" |
| 100 | +
|
| 101 | + - name: Package runtime files |
| 102 | + shell: pwsh |
| 103 | + run: | |
| 104 | + cargo xtask package ` |
| 105 | + --arch ${{ matrix.nuget_arch }} ` |
| 106 | + --target ${{ matrix.rust_target }} ` |
| 107 | + --profile release ` |
| 108 | + --out "target\package\${{ matrix.artifact }}" |
| 109 | +
|
| 110 | + - name: Validate package and create ZIP |
| 111 | + shell: pwsh |
| 112 | + run: | |
| 113 | + $ErrorActionPreference = 'Stop' |
| 114 | +
|
| 115 | + $packageDir = Join-Path $PWD 'target\package\${{ matrix.artifact }}' |
| 116 | + $zipPath = Join-Path $PWD 'target\package\${{ matrix.artifact }}.zip' |
| 117 | + $requiredFiles = @( |
| 118 | + 'windbg-tool.exe', |
| 119 | + 'ttd_replay_bridge.dll', |
| 120 | + 'TTDReplay.dll', |
| 121 | + 'TTDReplayCPU.dll', |
| 122 | + 'dbgeng.dll', |
| 123 | + 'dbgcore.dll', |
| 124 | + 'dbghelp.dll', |
| 125 | + 'dbgmodel.dll', |
| 126 | + 'msdia140.dll', |
| 127 | + 'symsrv.dll', |
| 128 | + 'srcsrv.dll' |
| 129 | + ) |
| 130 | +
|
| 131 | + foreach ($file in $requiredFiles) { |
| 132 | + $path = Join-Path $packageDir $file |
| 133 | + if (-not (Test-Path $path)) { |
| 134 | + throw "Package is missing required file: $file" |
| 135 | + } |
| 136 | + } |
| 137 | +
|
| 138 | + if ('${{ matrix.can_run }}' -eq 'true') { |
| 139 | + Push-Location $packageDir |
| 140 | + try { |
| 141 | + & '.\windbg-tool.exe' discover | Out-Null |
| 142 | + } |
| 143 | + finally { |
| 144 | + Pop-Location |
| 145 | + } |
| 146 | + } |
| 147 | +
|
| 148 | + if (Test-Path $zipPath) { |
| 149 | + Remove-Item $zipPath -Force |
| 150 | + } |
| 151 | + Compress-Archive -Path (Join-Path $packageDir '*') -DestinationPath $zipPath -Force |
| 152 | +
|
| 153 | + Add-Type -AssemblyName System.IO.Compression.FileSystem |
| 154 | + $zip = [System.IO.Compression.ZipFile]::OpenRead($zipPath) |
| 155 | + try { |
| 156 | + $entries = @($zip.Entries | ForEach-Object { $_.FullName.Replace('/', '\') }) |
| 157 | + foreach ($file in $requiredFiles) { |
| 158 | + if ($entries -notcontains $file) { |
| 159 | + throw "ZIP is missing required file: $file" |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + finally { |
| 164 | + $zip.Dispose() |
| 165 | + } |
| 166 | +
|
| 167 | + - name: Upload package |
| 168 | + uses: actions/upload-artifact@v6 |
| 169 | + with: |
| 170 | + name: ${{ matrix.artifact }} |
| 171 | + path: target\package\${{ matrix.artifact }}.zip |
| 172 | + if-no-files-found: error |
0 commit comments