Skip to content
Open
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
63 changes: 16 additions & 47 deletions .github/workflows/build-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build Toolchain
permissions:
contents: read
pull-requests: write
packages: write

on:
workflow_call:
Expand Down Expand Up @@ -33,8 +34,10 @@ jobs:
timeout-minutes: 30

env:
VCPKG_FILE_CACHE: ${{ github.workspace }}\vcpkg-bincache
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg-bincache,readwrite
# Fork pull requests get a read-only GITHUB_TOKEN, so they restore from the
# feed but must not attempt to upload to it.
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,${{ github.event.pull_request.head.repo.fork && 'read' || 'readwrite' }}"
VCPKG_NUGET_REPOSITORY: "https://github.com/${{ github.repository }}.git"
VCPKG_FEATURE_FLAGS: manifests,versions,binarycaching

steps:
Expand Down Expand Up @@ -105,52 +108,26 @@ jobs:
with:
arch: x86

- name: Compute vcpkg cache key parts
if: contains(inputs.preset, 'vcpkg')
id: vcpkg_key
shell: pwsh
run: |
$baseline = (Get-Content vcpkg.json | ConvertFrom-Json)."builtin-baseline"

$triplet = "x86-windows"
if ("${{ inputs.preset }}" -like "x64*") { $triplet = "x64-windows" }

"baseline=$baseline" >> $env:GITHUB_OUTPUT
"triplet=$triplet" >> $env:GITHUB_OUTPUT

Write-Host "vcpkg cache key parts: baseline=$baseline, triplet=$triplet"

- name: Restore vcpkg binary cache
if: contains(inputs.preset, 'vcpkg')
id: vcpkg_cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ github.workspace }}\vcpkg-bincache
key: vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}-${{ hashFiles('triplets/*.cmake') }}
restore-keys: |
vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-
vcpkg-bincache-v3-${{ runner.os }}-

- name: Setup vcpkg
if: contains(inputs.preset, 'vcpkg')
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11.6
with:
runVcpkgInstall: false
doNotCache: false
doNotCache: true

- name: Configure vcpkg to use cached directory
- name: Configure NuGet Source for vcpkg Binary Cache
if: contains(inputs.preset, 'vcpkg')
shell: pwsh
run: |
$cacheDir = "${{ github.workspace }}\vcpkg-bincache"
New-Item -ItemType Directory -Force -Path $cacheDir | Out-Null

# lukka/run-vcpkg sets its own temp cache dir; override to force our cached dir
$env:VCPKG_DEFAULT_BINARY_CACHE = $cacheDir
$env:VCPKG_BINARY_SOURCES = "clear;files,$cacheDir,readwrite"

"VCPKG_DEFAULT_BINARY_CACHE=$cacheDir" >> $env:GITHUB_ENV
"VCPKG_BINARY_SOURCES=$env:VCPKG_BINARY_SOURCES" >> $env:GITHUB_ENV
$nuget = & "$env:VCPKG_ROOT\vcpkg.exe" fetch nuget | Select-Object -Last 1
& $nuget sources add `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ github.repository_owner }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
& $nuget setapikey "${{ secrets.GITHUB_TOKEN }}" `
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
"VCPKG_OVERLAY_TRIPLETS=${{ github.workspace }}\triplets" >> $env:GITHUB_ENV
"VCPKG_INSTALL_OPTIONS=--x-abi-tools-use-exact-versions" >> $env:GITHUB_ENV

Expand All @@ -176,14 +153,6 @@ jobs:
run: |
cmake --build --preset ${{ inputs.preset }}

- name: Save vcpkg binary cache
# Only one job should save to avoid "Unable to reserve cache" conflicts.
if: ${{ contains(inputs.preset, 'vcpkg') && steps.vcpkg_cache.outputs.cache-hit != 'true' && inputs.game == 'Generals' && inputs.preset == 'win32-vcpkg-debug' }}
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ github.workspace }}\vcpkg-bincache
key: vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}-${{ hashFiles('triplets/*.cmake') }}

- name: Collect ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
shell: pwsh
run: |
Expand Down
39 changes: 21 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: GenCI
permissions:
contents: read
pull-requests: write
packages: write

on:
push:
Expand Down Expand Up @@ -47,6 +48,8 @@ jobs:
- 'cmake/**'
- 'Core/**'
- 'Dependencies/**'
- 'triplets/**'
- 'vcpkg.json'

- name: Changes Summary
run: |
Expand Down Expand Up @@ -80,15 +83,15 @@ jobs:
- preset: "win32-debug"
tools: true
extras: true
#- preset: "win32-vcpkg"
# tools: true
# extras: true
#- preset: "win32-vcpkg-profile"
# tools: true
# extras: true
#- preset: "win32-vcpkg-debug"
# tools: true
# extras: true
- preset: "win32-vcpkg"
tools: true
extras: true
- preset: "win32-vcpkg-profile"
tools: true
extras: true
- preset: "win32-vcpkg-debug"
tools: true
extras: true
fail-fast: false
uses: ./.github/workflows/build-toolchain.yml
with:
Expand Down Expand Up @@ -144,15 +147,15 @@ jobs:
- preset: "win32-debug"
tools: true
extras: true
#- preset: "win32-vcpkg"
# tools: true
# extras: true
#- preset: "win32-vcpkg-profile"
# tools: true
# extras: true
#- preset: "win32-vcpkg-debug"
# tools: true
# extras: true
- preset: "win32-vcpkg"
tools: true
extras: true
- preset: "win32-vcpkg-profile"
tools: true
extras: true
- preset: "win32-vcpkg-debug"
tools: true
extras: true
fail-fast: false
uses: ./.github/workflows/build-toolchain.yml
with:
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ cmake --build build/win32 --config Release

### Dependency management

The repository uses a vcpkg manifest (`vcpkg.json`) paired with a lockfile (`vcpkg-lock.json`). When you add or upgrade
dependencies, run `vcpkg install --x-manifest-root . --triplet <triplet>` with `VCPKG_FEATURE_FLAGS=versions` so the
lockfile picks up the new versions and include the updated lockfile in your change. GitHub Actions consumes these ports
through `VCPKG_BINARY_SOURCES=clear;files,<workspace>/vcpkg-bincache,readwrite` (paired with an `actions/cache` entry for
that folder), so the first CI build warms the cache and subsequent builds pull prebuilt binaries instead of
re-compiling everything.
The repository uses a vcpkg manifest (`vcpkg.json`). Dependency versions come from the `builtin-baseline` commit
recorded there, with per-port `overrides` when a specific version is required. Update the baseline to pick up new
versions. GitHub Actions consumes these ports through a vcpkg binary cache backed by a NuGet feed on GitHub
Packages, keyed by vcpkg's own ABI hashes, so the first CI build warms the feed and subsequent builds pull prebuilt
binaries instead of re-compiling everything. Pull requests from forks restore from the feed but cannot write to it.

### Profiling

Expand Down
5 changes: 0 additions & 5 deletions triplets/x86-windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

# Exclude compiler version from ABI hash so that weekly GitHub runner image
# updates don't invalidate the binary cache. Minor MSVC version bumps do not
# cause ABI incompatibilities for this project.
set(VCPKG_DISABLE_COMPILER_TRACKING ON)
48 changes: 0 additions & 48 deletions vcpkg-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"builtin-baseline": "b02e341c927f16d991edbd915d8ea43eac52096c",
"builtin-baseline": "9e593bb18ea69cc5095e012465dcd675a822ed0d",
"dependencies": [
"zlib",
"ffmpeg",
Expand Down
Loading