Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .ai/memory/build/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,38 @@ could reuse an install built for another feature set.
GitHub Actions vcpkg cache keys must also distinguish the requested feature set.
On PR #80, Debug and Release initially shared a key; the Debug job saved its
smaller package cache first, and the Release job could not replace it with the
`full-drivers` packages. PR-scoped caches can also take precedence over a
development-branch cache with the same key. The workflow now saves caches only
from `development` and `main` pushes and lets pull requests restore them.
`main` is the default branch and cannot restore `development`-scoped caches,
so it must save its own. See
[`build.yml`](../../../.github/workflows/build.yml) and the observed run
`43613765529`.
`full-drivers` packages. `main` is the default branch and cannot restore
`development`-scoped caches, so it must save its own.

An exact cache-key hit does not mean vcpkg reuses the packages. Package ABIs
include vcpkg's own scripts, and an unpinned vcpkg clone (vcpkg master moved
past `builtin-baseline`) changed every ABI: run `43765171463` hit all caches
but rebuilt GDAL and its dependencies for 30-86 minutes per job, and the
save-on-miss-only rule never refreshed the stale caches. CI therefore runs
`bootstrap-vcpkg.ps1 -Baseline` (vcpkg at the manifest baseline, full clone
because vcpkg reads older port versions from git history; a depth-1 clone fails
to load `[email protected]`). Separate per-leg dependency jobs save caches under unique
`<prefix><run_id>-<run_attempt>` keys. The sync script prunes unused archives
only after a successful install; after a failed install it retains all
archives, including packages not reached in the install plan. Pull requests
save only when vcpkg added packages; pushes also refresh stale-prefix caches.
An archive is named by the SHA-256 of `share/<port>/vcpkg_abi_info.txt` in the
install tree (verified locally). Each consumer waits only for its matching
platform and configuration dependency job; Release jobs use `-release`
triplets.

The MSBuild parity step must not rebuild on its own: `Compare-CompileCommands.ps1`
without `-MSBuildLog` rebuilds with the default features, which in a
full-driver Release job reinstalled GDAL without `full-drivers` (+25 minutes)
and left the tests and artifacts on the reduced driver set. CI passes the build
step's detailed log instead. See
[`build.yml`](../../../.github/workflows/build.yml).

## References

- [Dependency manifest](../../../vcpkg.json)
- [Shared vcpkg configuration](../../../Directory.Build.props)
- [Feature stamp and runtime-data deployment](../../../Directory.Build.targets)
- [CI binary-cache pruning](../../../build/scripts/Sync-VcpkgBinaryCache.ps1)
- [Build and dependency guide](../../../docs/BUILDING.md#dependencies)
- [GDAL version requirement](../../../docs/gdal-version.md)
116 changes: 116 additions & 0 deletions .github/workflows/build-msbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: MSBuild build

on:
workflow_call:
inputs:
platform:
required: true
type: string
configuration:
required: true
type: string

jobs:
build:
runs-on: windows-2025
timeout-minutes: 180

env:
VCPKG_BINARY_SOURCES: 'clear;files,${{ github.workspace }}\vcpkg-binary-cache,readwrite'
# The runner image does not ship SDK 10.0.28000 yet.
MWG_WINDOWS_SDK: '10.0'

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Compute vcpkg cache key
id: cache_key
shell: pwsh
run: |
$leg = 'vcpkg-binary-${{ runner.os }}-${{ inputs.platform }}-${{ inputs.configuration == 'Release' && 'release-full' || 'tests' }}-'
Add-Content -Path $env:GITHUB_OUTPUT -Value "leg=$leg"
Add-Content -Path $env:GITHUB_OUTPUT -Value "prefix=$leg$env:ImageVersion-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'build/triplets/*.cmake') }}-"

- name: Restore vcpkg binary packages
uses: actions/cache/restore@v6
with:
path: vcpkg-binary-cache
key: ${{ steps.cache_key.outputs.prefix }}${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
${{ steps.cache_key.outputs.prefix }}
${{ steps.cache_key.outputs.leg }}

- name: Bootstrap vcpkg
shell: pwsh
run: ./build/scripts/bootstrap-vcpkg.ps1 -Baseline

- name: Set up MSBuild
uses: microsoft/setup-msbuild@v3

- name: Check build configuration
shell: pwsh
run: ./build/scripts/Test-BuildConfiguration.ps1

# The detailed log feeds the parity baseline below; a clean checkout
# compiles every translation unit, so no second (re)build is needed.
- name: Build
shell: pwsh
run: |
$release = '${{ inputs.configuration }}' -eq 'Release'
# Release builds use the release-only vcpkg triplets.
$vcpkgArguments = @('-p:MwgVcpkgFeatures=tests')
if ($release) {
$vcpkgArguments = @('-p:MwgVcpkgFeatures=tests%3Bfull-drivers', '-p:MwgVcpkgReleaseOnly=true')
}
New-Item -ItemType Directory -Force -Path out/parity | Out-Null
msbuild MapWinGIS6.slnx `
-restore `
-p:Configuration=${{ inputs.configuration }} `
-p:Platform=${{ inputs.platform }} `
-p:MwgWindowsSdk=$env:MWG_WINDOWS_SDK `
@vcpkgArguments `
-m -v:m `
"-flp:logfile=out\parity\msbuild-${{ inputs.configuration }}-${{ inputs.platform }}.log;verbosity=detailed"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

- name: Measure build parity baseline
shell: pwsh
run: |
pwsh -File build/scripts/Compare-CompileCommands.ps1 `
-Configuration ${{ inputs.configuration }} `
-Platform ${{ inputs.platform }} `
-MSBuildLog out/parity/msbuild-${{ inputs.configuration }}-${{ inputs.platform }}.log `
-FailOnLostFlags

- name: Test
shell: pwsh
run: |
foreach ($test in @(
@{ Name = "core"; Project = "MapWinGIS.Core.Tests" },
@{ Name = "core-gdal-init"; Project = "MapWinGIS.Core.GdalInitialization.Tests" },
@{ Name = "activex"; Project = "MapWinGIS.ActiveX.Tests" }
)) {
$exe = "bin/${{ inputs.configuration }}/${{ inputs.platform }}/$($test.Project).exe"
$report = "testresults-$($test.Name)-${{ inputs.platform }}-${{ inputs.configuration }}.xml"
& $exe --gtest_output="xml:$report"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}

- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: testresults-${{ inputs.platform }}-${{ inputs.configuration }}
path: testresults-*-${{ inputs.platform }}-${{ inputs.configuration }}.xml
if-no-files-found: ignore

- name: Upload binaries
if: ${{ inputs.configuration == 'Release' }}
uses: actions/upload-artifact@v7
with:
name: MapWinGIS.Core-${{ inputs.platform }}
path: bin/Release/${{ inputs.platform }}/
if-no-files-found: error
Loading