Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82c62d4253 |
No files matched your search
@@ -1,92 +0,0 @@
|
||||
name: Merge upstream updates
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '37 2 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: merge-upstream-intel-vm-suspend
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
if: github.repository == 'reims-go/reims-vgpu'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Merge upstream into the maintenance branch
|
||||
id: merge
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TARGET_BRANCH: intel-vm-suspend
|
||||
UPSTREAM_REPO: steelbrain/reims-vgpu
|
||||
UPSTREAM_BRANCH: master
|
||||
GIT_AUTHOR_NAME: YXC0915
|
||||
GIT_AUTHOR_EMAIL: 62410385+yxc0915@users.noreply.github.com
|
||||
GIT_COMMITTER_NAME: 'github-actions[bot]'
|
||||
GIT_COMMITTER_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com'
|
||||
GIT_TERMINAL_PROMPT: '0'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
summary() {
|
||||
printf '%s\n' "$1" | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
}
|
||||
|
||||
# Check ancestry on GitHub first so routine polls do not fetch QEMU history.
|
||||
target_ref=${TARGET_BRANCH//\//%2F}
|
||||
upstream_ref=${UPSTREAM_BRANCH//\//%2F}
|
||||
status=$(gh api "repos/$GITHUB_REPOSITORY/compare/$target_ref...${UPSTREAM_REPO%%/*}:$upstream_ref?per_page=1" --jq .status)
|
||||
case "$status" in
|
||||
identical|behind)
|
||||
summary "$TARGET_BRANCH already contains $UPSTREAM_REPO:$UPSTREAM_BRANCH."
|
||||
exit 0
|
||||
;;
|
||||
ahead|diverged) ;;
|
||||
*)
|
||||
echo "::error::Unexpected upstream comparison status: $status"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
git init --bare --quiet "$RUNNER_TEMP/upstream-sync.git"
|
||||
cd "$RUNNER_TEMP/upstream-sync.git"
|
||||
git remote add origin "https://github.com/$GITHUB_REPOSITORY.git"
|
||||
git remote add upstream "https://github.com/$UPSTREAM_REPO.git"
|
||||
git fetch --no-tags --refmap= origin "refs/heads/$TARGET_BRANCH:refs/remotes/origin/target"
|
||||
git fetch --no-tags --refmap= upstream "refs/heads/$UPSTREAM_BRANCH:refs/remotes/upstream/source"
|
||||
target=$(git rev-parse refs/remotes/origin/target)
|
||||
source=$(git rev-parse refs/remotes/upstream/source)
|
||||
|
||||
# Recheck ancestry using the exact commits that were fetched.
|
||||
if git merge-base --is-ancestor "$source" "$target"; then
|
||||
summary "$TARGET_BRANCH already contains upstream commit $source."
|
||||
exit 0
|
||||
fi
|
||||
if git merge-base --is-ancestor "$target" "$source"; then
|
||||
merged=$source
|
||||
elif tree=$(git merge-tree --write-tree "$target" "$source"); then
|
||||
merged=$(git commit-tree "$tree" -p "$target" -p "$source" \
|
||||
-m "Merge $UPSTREAM_REPO:$UPSTREAM_BRANCH into $TARGET_BRANCH")
|
||||
else
|
||||
result=$?
|
||||
printf '%s\n' "$tree" | sed 's/^/ /'
|
||||
if [[ "$result" != 1 ]]; then
|
||||
exit "$result"
|
||||
fi
|
||||
echo "::warning::Upstream merge has conflicts. The maintenance branch was not updated."
|
||||
summary "Skipped merging $source into $TARGET_BRANCH at $target because of merge conflicts. See the job log."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# A normal push rejects a competing branch update and leaves its work intact.
|
||||
auth=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 -w0)
|
||||
echo "::add-mask::$auth"
|
||||
git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic $auth" \
|
||||
push origin "$merged:refs/heads/$TARGET_BRANCH"
|
||||
summary "Merged upstream commit $source into $TARGET_BRANCH at $merged."
|
||||
@@ -1,358 +0,0 @@
|
||||
name: Publish Runtime Preview
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- "packaging/windows-runtime/**"
|
||||
schedule:
|
||||
- cron: "23 3 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
upstream_commit:
|
||||
description: "Reims vGPU fork commit (empty = runtime branch HEAD)"
|
||||
required: false
|
||||
default: ""
|
||||
publish:
|
||||
description: "Publish the verified preview as a GitHub prerelease"
|
||||
type: boolean
|
||||
default: true
|
||||
supersede:
|
||||
description: "Replace older builds for an automatic maintenance-branch push"
|
||||
type: boolean
|
||||
default: false
|
||||
rebuild:
|
||||
description: "Plan a rebuild of an already published runtime using verified compatibility"
|
||||
type: boolean
|
||||
default: false
|
||||
include_sources:
|
||||
description: "Include MSYS2 copyleft source archive and detached debug symbols (for stable promotion)"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
UPSTREAM_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
||||
UPSTREAM_BRANCH: intel-vm-suspend
|
||||
|
||||
jobs:
|
||||
resolve:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
commit: ${{ steps.r.outputs.commit }}
|
||||
skip: ${{ steps.r.outputs.skip }}
|
||||
steps:
|
||||
- id: r
|
||||
env:
|
||||
WANT: ${{ inputs.upstream_commit }}
|
||||
CURRENT_ONLY: ${{ inputs.supersede }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone -q --filter=blob:none --no-checkout --single-branch --branch "$UPSTREAM_BRANCH" "$UPSTREAM_URL" up
|
||||
commit="$(git -C up rev-parse --verify "${WANT:-HEAD}^{commit}")"
|
||||
git -C up cat-file -e "$commit:reims-go-runtime.json"
|
||||
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
||||
if [[ "$CURRENT_ONLY" == true && "$commit" != "$(git -C up rev-parse HEAD)" ]]; then
|
||||
echo "Skipping superseded runtime commit $commit"
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
build:
|
||||
needs: resolve
|
||||
if: needs.resolve.outputs.skip != 'true'
|
||||
concurrency:
|
||||
group: build-runtime
|
||||
cancel-in-progress: ${{ github.event_name == 'push' || inputs.supersede }}
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 90
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# Select the version inside the build lock, including queued runs.
|
||||
- name: Plan Alpha release
|
||||
id: plan
|
||||
shell: pwsh
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RUNTIME_COMMIT: ${{ needs.resolve.outputs.commit }}
|
||||
REBUILD: ${{ github.event_name == 'push' || inputs.rebuild }}
|
||||
PACKAGING_PUSH: ${{ github.event_name == 'push' }}
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$work = Join-Path $env:RUNNER_TEMP 'reims-vgpu'
|
||||
git config --global core.autocrlf false
|
||||
git clone -q --filter=blob:none --no-checkout --single-branch --branch $env:UPSTREAM_BRANCH $env:UPSTREAM_URL $work
|
||||
if ($LASTEXITCODE) { throw 'runtime clone failed' }
|
||||
$plan = & ./packaging/windows-runtime/scripts/plan-runtime-release.ps1 `
|
||||
-RuntimeRepo $work -RuntimeCommit $env:RUNTIME_COMMIT `
|
||||
-PackagingRepo $env:GITHUB_WORKSPACE -PackagingCommit $env:GITHUB_SHA `
|
||||
-Repository $env:GITHUB_REPOSITORY -Rebuild:($env:REBUILD -eq 'true') `
|
||||
-PackagingPush:($env:PACKAGING_PUSH -eq 'true')
|
||||
"skip=$($plan.Skip.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT
|
||||
if ($plan.Skip) { return }
|
||||
"UPSTREAM_DIR=$work" >> $env:GITHUB_ENV
|
||||
"RELEASE_ID=$($plan.ReleaseId)" >> $env:GITHUB_ENV
|
||||
"SUSPEND_COMPAT_ID=$($plan.SuspendCompatID)" >> $env:GITHUB_ENV
|
||||
"SUSPEND_VERIFICATION=$($plan.Evidence)" >> $env:GITHUB_ENV
|
||||
"SUSPEND_PREDECESSOR=$($plan.Predecessor)" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Setup MSYS2 CLANG64
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
id: msys2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: CLANG64
|
||||
update: true
|
||||
install: >-
|
||||
git curl diffutils make zstd tar mingw-w64-clang-x86_64-toolchain
|
||||
mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-meson
|
||||
mingw-w64-clang-x86_64-ninja mingw-w64-clang-x86_64-pkgconf
|
||||
mingw-w64-clang-x86_64-glib2 mingw-w64-clang-x86_64-pixman
|
||||
mingw-w64-clang-x86_64-gtk3 mingw-w64-clang-x86_64-libslirp
|
||||
mingw-w64-clang-x86_64-libusb mingw-w64-clang-x86_64-usbredir
|
||||
mingw-w64-clang-x86_64-gnutls mingw-w64-clang-x86_64-dtc
|
||||
mingw-w64-clang-x86_64-libva mingw-w64-clang-x86_64-zstd
|
||||
mingw-w64-clang-x86_64-mesa mingw-w64-clang-x86_64-vulkan-loader
|
||||
mingw-w64-clang-x86_64-python mingw-w64-clang-x86_64-python-pip
|
||||
mingw-w64-clang-x86_64-ccache mingw-w64-clang-x86_64-sccache
|
||||
|
||||
- name: Check out the runtime forks and apply dependency patches
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
id: patches
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$work = $env:UPSTREAM_DIR
|
||||
foreach ($d in 'cargo', 'xdg-data', 'xdg-cache') { New-Item -ItemType Directory -Force -Path (Join-Path $env:RUNNER_TEMP $d) | Out-Null }
|
||||
git -C $work checkout -q '${{ needs.resolve.outputs.commit }}'
|
||||
if ($LASTEXITCODE) { throw 'checkout failed' }
|
||||
git -C $work submodule update --init --depth 1 vendor/qemu
|
||||
if ($LASTEXITCODE) { git -C $work submodule update --init vendor/qemu }
|
||||
if ($LASTEXITCODE) { throw 'vendor/qemu submodule failed' }
|
||||
$pins = & ./packaging/windows-runtime/scripts/read-runtime-dependencies.ps1 -RuntimeRepo $work
|
||||
function Get-DependencyCheckout($pin, [string]$path) {
|
||||
git init -q $path
|
||||
if ($LASTEXITCODE) { throw "Could not initialize $path" }
|
||||
git -C $path remote add origin $pin.Url
|
||||
if ($LASTEXITCODE) { throw "Could not add origin for $path" }
|
||||
git -C $path fetch -q --depth 1 origin $pin.Rev
|
||||
if ($LASTEXITCODE) { throw "Could not fetch $($pin.Url)@$($pin.Rev)" }
|
||||
git -C $path checkout -q --detach $pin.Rev
|
||||
if ($LASTEXITCODE) { throw "Could not check out $($pin.Url)@$($pin.Rev)" }
|
||||
Write-Host "Using $($pin.Url)@$($pin.Rev)"
|
||||
}
|
||||
$utilRepo = Join-Path $env:RUNNER_TEMP 'reims-util'
|
||||
$m2vRepo = Join-Path $env:RUNNER_TEMP 'metal2vulkan'
|
||||
Get-DependencyCheckout $pins.Util $utilRepo
|
||||
Get-DependencyCheckout $pins.Metal $m2vRepo
|
||||
$short = (git -C $work rev-parse --short=7 HEAD).Trim()
|
||||
|
||||
# Applies what applies, skips what upstream already has, stops on a
|
||||
# conflict without touching the patch (AGENTS.md rule 4).
|
||||
$resultFile = Join-Path $env:RUNNER_TEMP 'patches.json'
|
||||
try {
|
||||
pwsh -NoProfile -File packaging/windows-runtime/scripts/apply-patch-series.ps1 -ReimsRepo $work -UtilRepo $utilRepo -Metal2VulkanRepo $m2vRepo -ResultFile $resultFile
|
||||
$ok = $LASTEXITCODE -eq 0
|
||||
} finally {
|
||||
if (Test-Path $resultFile) {
|
||||
$r = Get-Content -Raw $resultFile | ConvertFrom-Json
|
||||
"merged=$(@($r.merged) -join ',')" >> $env:GITHUB_OUTPUT
|
||||
"APPLIED_PATCHES=$(@($r.applied) -join ',')" >> $env:GITHUB_ENV
|
||||
}
|
||||
}
|
||||
if (-not $ok) { throw 'patch queue does not apply' }
|
||||
$cargoHome = Join-Path $env:RUNNER_TEMP 'cargo'
|
||||
$m2vChanges = git -C $m2vRepo status --porcelain
|
||||
if ($LASTEXITCODE) { throw 'Could not read metal2vulkan checkout status' }
|
||||
if ($m2vChanges) {
|
||||
$m2vFwd = $m2vRepo.Replace('\', '/')
|
||||
$cargoCfg = @"
|
||||
[patch."$($pins.Metal.Url)"]
|
||||
metal2vulkan = { path = "$m2vFwd/crates/metal2vulkan" }
|
||||
metal2vulkan-runtime = { path = "$m2vFwd/crates/metal2vulkan-runtime" }
|
||||
"@
|
||||
[IO.File]::WriteAllText((Join-Path $cargoHome 'config.toml'), ($cargoCfg.Replace("`r`n", "`n") + "`n"), [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
"REIMS_UTIL_DIR=$utilRepo" >> $env:GITHUB_ENV
|
||||
"METAL2VULKAN_DIR=$m2vRepo" >> $env:GITHUB_ENV
|
||||
"SHORT_COMMIT=$short" >> $env:GITHUB_ENV
|
||||
"CARGO_HOME=$cargoHome" >> $env:GITHUB_ENV
|
||||
"XDG_DATA_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-data')" >> $env:GITHUB_ENV
|
||||
"XDG_CACHE_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-cache')" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Identify the Windows build toolchain
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
id: toolchain
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "$(cygpath -u "$UPSTREAM_DIR")"
|
||||
fingerprint="$({ LC_ALL=C pacman -Q; cat rust-toolchain.toml; } | sha256sum)"
|
||||
week="$(date -u +%G-W%V)"
|
||||
echo "fingerprint=${fingerprint%% *}" >> "$GITHUB_OUTPUT"
|
||||
echo "week=$week" >> "$GITHUB_OUTPUT"
|
||||
echo "Build toolchain: ${fingerprint%% *} (cache bucket: $week)"
|
||||
|
||||
- name: Cache compiler objects and Cargo downloads
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
${{ runner.temp }}/compiler-cache/ccache
|
||||
${{ runner.temp }}/compiler-cache/sccache
|
||||
${{ runner.temp }}/cargo/registry/index
|
||||
${{ runner.temp }}/cargo/registry/cache
|
||||
${{ runner.temp }}/cargo/git/db
|
||||
key: runtime-build-v2-${{ runner.arch }}-${{ steps.toolchain.outputs.fingerprint }}-${{ steps.toolchain.outputs.week }}
|
||||
restore-keys: |
|
||||
runtime-build-v2-${{ runner.arch }}-${{ steps.toolchain.outputs.fingerprint }}-
|
||||
|
||||
- name: Build upstream runtime in MSYS2 CLANG64
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
shell: msys2 {0}
|
||||
env:
|
||||
REIMS_INSTALL_SKIP_HOST_CHECKS: "1"
|
||||
CCACHE_MAXSIZE: 400M
|
||||
CCACHE_COMPILERCHECK: content
|
||||
SCCACHE_CACHE_SIZE: 500M
|
||||
SCCACHE_ALLOW_INCREMENTAL: "1"
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "$(cygpath -u "$UPSTREAM_DIR")"
|
||||
# Native Ninja searches its own directory for the installer's bare
|
||||
# clang/clang++ names before PATH. Put the cache shims beside its CI copy.
|
||||
temp_dir="$(cygpath -u "$RUNNER_TEMP")"
|
||||
tools_dir="$temp_dir/compiler-tools"
|
||||
mkdir -p "$tools_dir"
|
||||
cp "$MINGW_PREFIX/bin/ninja.exe" "$MINGW_PREFIX/lib/ccache/bin/"clang{,++}.exe "$tools_dir/"
|
||||
export PATH="$tools_dir:$PATH"
|
||||
export CCACHE_PATH="$(cygpath -m "$MINGW_PREFIX/bin")"
|
||||
export CCACHE_DIR="$(cygpath -m "$temp_dir")/compiler-cache/ccache"
|
||||
export SCCACHE_DIR="$(cygpath -m "$temp_dir")/compiler-cache/sccache"
|
||||
export RUSTC_WRAPPER="$(cygpath -m "$MINGW_PREFIX/bin/sccache.exe")"
|
||||
ccache --zero-stats
|
||||
sccache --start-server
|
||||
trap 'ccache --show-stats --verbose; sccache --stop-server' EXIT
|
||||
# Upstream's own non-interactive CLANG64 build script.
|
||||
bash scripts/install-ctl.sh --yes
|
||||
util_repo="$(cygpath -u "$REIMS_UTIL_DIR")"
|
||||
if [[ -n "$(git -C "$util_repo" status --porcelain)" ]]; then
|
||||
toolchain="$(sed -n 's/^channel *= *"\([^"]*\)".*/\1/p' rust-toolchain.toml)"
|
||||
export PATH="$(cygpath -u "$CARGO_HOME")/bin:$PATH"
|
||||
CC=clang CXX=clang++ AR=llvm-ar cargo +"$toolchain-x86_64-pc-windows-gnullvm" install \
|
||||
--locked --force --root "$CARGO_HOME" --path "$REIMS_UTIL_DIR"
|
||||
fi
|
||||
|
||||
- name: Package alpha runtime and source archives
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
env:
|
||||
INCLUDE_FULL_SOURCES: ${{ inputs.include_sources }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$outDir = Join-Path $env:RUNNER_TEMP 'releases'
|
||||
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||
# In-process call, so an empty list (every patch already upstream) binds
|
||||
# as an empty array rather than being dropped as an empty argument.
|
||||
$applied = @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
||||
$full = $env:INCLUDE_FULL_SOURCES -eq 'true'
|
||||
& ./packaging/windows-runtime/scripts/pack-runtime.ps1 `
|
||||
-ReimsRepo $env:UPSTREAM_DIR `
|
||||
-UtilRepo $env:REIMS_UTIL_DIR `
|
||||
-Metal2VulkanRepo $env:METAL2VULKAN_DIR `
|
||||
-CargoHome $env:CARGO_HOME `
|
||||
-QemuDir (Join-Path $env:XDG_DATA_HOME 'reims-ctl\qemu\current') `
|
||||
-Msys2 '${{ steps.msys2.outputs.msys2-location }}' `
|
||||
-OutDir $outDir `
|
||||
-TempRoot $env:RUNNER_TEMP `
|
||||
-Channel alpha `
|
||||
-ReleaseId $env:RELEASE_ID `
|
||||
-SuspendCompatID $env:SUSPEND_COMPAT_ID `
|
||||
-PackagingCommit $env:GITHUB_SHA `
|
||||
-Patches $applied `
|
||||
-SkipMsys2Sources:(-not $full) `
|
||||
-SkipSymbols:(-not $full)
|
||||
|
||||
- name: Alpha entry gate
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
env:
|
||||
INCLUDE_FULL_SOURCES: ${{ inputs.include_sources }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$full = $env:INCLUDE_FULL_SOURCES -eq 'true'
|
||||
& ./packaging/windows-runtime/scripts/check-runtime-alpha.ps1 `
|
||||
-OutDir (Join-Path $env:RUNNER_TEMP 'releases') `
|
||||
-Commit $env:RELEASE_ID -RequireSlim -RequiredCapability vm-suspend `
|
||||
-RequiredSuspendCompatID $env:SUSPEND_COMPAT_ID -RequiredPackagingCommit $env:GITHUB_SHA `
|
||||
-Zstd (Join-Path '${{ steps.msys2.outputs.msys2-location }}' 'usr\bin\zstd.exe') `
|
||||
-AppliedPatches @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ }) `
|
||||
-SkipMsys2Sources:(-not $full) `
|
||||
-SkipSymbols:(-not $full)
|
||||
|
||||
- name: Upload alpha artifacts (non-release debug runs only)
|
||||
if: steps.plan.outputs.skip != 'true' && !(github.event_name == 'push' || github.event_name == 'schedule' || inputs.publish)
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: reims-runtime-win-x64-${{ env.RELEASE_ID }}-alpha
|
||||
path: |
|
||||
${{ runner.temp }}/releases/reims-runtime-*.tar.zst
|
||||
${{ runner.temp }}/releases/SHA256SUMS.txt
|
||||
compression-level: 0
|
||||
retention-days: 3
|
||||
|
||||
- name: Publish alpha prerelease (never stable)
|
||||
if: steps.plan.outputs.skip != 'true' && (github.event_name == 'push' || github.event_name == 'schedule' || inputs.publish)
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CURRENT_ONLY: ${{ github.event_name == 'push' || inputs.supersede }}
|
||||
MERGED: ${{ steps.patches.outputs.merged }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if ($env:CURRENT_ONLY -eq 'true') {
|
||||
$ref = "refs/heads/$env:UPSTREAM_BRANCH"
|
||||
$remote = git ls-remote $env:UPSTREAM_URL $ref
|
||||
if ($LASTEXITCODE -ne 0) { throw "Could not query the runtime maintenance ref $ref" }
|
||||
if (!$remote) {
|
||||
Write-Warning "Skipping Alpha publication because $ref no longer exists. The verified archives are available in the workflow artifact."
|
||||
return
|
||||
}
|
||||
if (($remote -split '\s+')[0] -ne '${{ needs.resolve.outputs.commit }}') {
|
||||
Write-Host 'Skipping Alpha publication for a superseded runtime commit.'
|
||||
return
|
||||
}
|
||||
}
|
||||
$c = $env:RELEASE_ID
|
||||
$short = $env:SHORT_COMMIT
|
||||
$sourceRepo = $env:UPSTREAM_URL -replace '\.git$', ''
|
||||
$dir = Join-Path $env:RUNNER_TEMP 'releases'
|
||||
$assets = @("reims-runtime-win-x64-$c.tar.zst", "reims-runtime-src-$c.tar.zst", "reims-runtime-msys2-src-$c.tar.zst", "reims-runtime-symbols-$c.tar.zst", 'SHA256SUMS.txt') |
|
||||
ForEach-Object { Join-Path $dir $_ } |
|
||||
Where-Object { Test-Path -LiteralPath $_ -PathType Leaf }
|
||||
$applied = if ($env:APPLIED_PATCHES) { ($env:APPLIED_PATCHES -split ',' | ForEach-Object { "- ``$_``" }) -join "`n" } else { '- (none)' }
|
||||
$merged = if ($env:MERGED) { "`n`nAlready upstream, skipped (retire from patches/): $env:MERGED" } else { '' }
|
||||
$compatibility = if ($env:SUSPEND_PREDECESSOR) { "`nVerified against $env:SUSPEND_PREDECESSOR. $env:SUSPEND_VERIFICATION" } else { '' }
|
||||
$notes = @"
|
||||
**Alpha** runtime (``$c``), built from [the Reims vGPU fork@$short]($sourceRepo/commit/${{ needs.resolve.outputs.commit }}).
|
||||
|
||||
Preview for Windows x64. Stable promotion requires a real-host smoke test with ``packaging/windows-runtime/scripts/smoke-runtime.ps1`` and human approval.
|
||||
|
||||
Local patches applied (sources and patches are in the attached source packages):
|
||||
$applied$merged
|
||||
|
||||
The optional ``reims-runtime-symbols-$c.tar.zst`` contains matching debug files for crash analysis.
|
||||
|
||||
Packaging commit: ``$env:GITHUB_SHA``
|
||||
Suspend compatibility ID: ``$env:SUSPEND_COMPAT_ID``$compatibility
|
||||
|
||||
Build: $env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID
|
||||
"@
|
||||
gh release create "runtime-$c" @assets --repo $env:GITHUB_REPOSITORY --target '${{ needs.resolve.outputs.commit }}' --prerelease --latest=false --title "Portable Runtime runtime-$c (alpha)" --notes $notes
|
||||
if ($LASTEXITCODE) { throw "gh release create failed ($LASTEXITCODE)" }
|
||||
Generated
+3
@@ -213,6 +213,7 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
[[package]]
|
||||
name = "metal2vulkan"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/steelbrain/metal2vulkan?rev=0b0ac58eb0f69ed3b37007fbdf3b135a46f90699#0b0ac58eb0f69ed3b37007fbdf3b135a46f90699"
|
||||
dependencies = [
|
||||
"ash",
|
||||
"metal2vulkan-air",
|
||||
@@ -223,6 +224,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "metal2vulkan-air"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/steelbrain/metal2vulkan?rev=0b0ac58eb0f69ed3b37007fbdf3b135a46f90699#0b0ac58eb0f69ed3b37007fbdf3b135a46f90699"
|
||||
dependencies = [
|
||||
"sha2 0.11.1",
|
||||
]
|
||||
@@ -230,6 +232,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "metal2vulkan-runtime"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/steelbrain/metal2vulkan?rev=0b0ac58eb0f69ed3b37007fbdf3b135a46f90699#0b0ac58eb0f69ed3b37007fbdf3b135a46f90699"
|
||||
dependencies = [
|
||||
"ash",
|
||||
"libc",
|
||||
|
||||
@@ -13,6 +13,9 @@ description = "Create, boot and manage macOS VMs on QEMU with reims-vgpu"
|
||||
|
||||
[workspace]
|
||||
|
||||
[features]
|
||||
windows-arm64-guest = []
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.104"
|
||||
clap = { version = "4.6.7", features = ["derive", "env", "wrap_help"] }
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
//! `ld.lld`), so the build needs clang and no lld of the host's. Where clang can't build it,
|
||||
//! reims-ctl carries no module, says so as it builds, and refuses to start an arm64 VM.
|
||||
//!
|
||||
//! A reims-ctl for Windows, which runs no arm64 VM (src/host.rs), carries neither the arm64 set
|
||||
//! nor the module.
|
||||
//! The optional Windows arm64 guest build embeds the same assets as other arm64 guest hosts.
|
||||
|
||||
use std::fmt::Write as _;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -24,9 +23,8 @@ fn main() {
|
||||
let crate_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").expect("cargo sets it"));
|
||||
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").expect("cargo sets it"));
|
||||
let out = out_dir.join("set.rs");
|
||||
// A reims-ctl for Windows runs no arm64 VM (src/host.rs), and carries no arm64 guest.
|
||||
let windows = std::env::var("CARGO_CFG_TARGET_OS").is_ok_and(|os| os == "windows");
|
||||
let (set_arm64e, module) = if windows {
|
||||
let (set_arm64e, module) = if windows && !cfg!(feature = "windows-arm64-guest") {
|
||||
("None".to_string(), "None".to_string())
|
||||
} else {
|
||||
(
|
||||
@@ -37,6 +35,12 @@ fn main() {
|
||||
module_code(&crate_dir.join("../../firmware/ambrosia"), &out_dir),
|
||||
)
|
||||
};
|
||||
if windows && cfg!(feature = "windows-arm64-guest") {
|
||||
assert!(
|
||||
set_arm64e != "None" && module != "None",
|
||||
"windows-arm64-guest needs the arm64 guest set and the Ambrosia graphics module"
|
||||
);
|
||||
}
|
||||
let set = format!(
|
||||
"/// guest/prebuilt/set.toml's set, in its order.\n\
|
||||
pub static SET: Option<&[Kext]> = {};\n\
|
||||
|
||||
@@ -367,11 +367,11 @@ fn create_examples_on(host: Host) -> String {
|
||||
# Or with the OpenCore image it booted from, copied, which keeps its Mac too
|
||||
reims-ctl create mac --disk {disk} --opencore {opencore}
|
||||
|
||||
An arm64 guest on an arm64 Mac, arm64 Linux or x86-64 Linux:
|
||||
An arm64 guest on a host with the arm64 guest runtime:
|
||||
|
||||
# Download the current macOS's IPSW from Apple (about 25 GB, kept for the next VM; a
|
||||
# stopped download continues), restore it onto a new 128G disk, with tickets Apple
|
||||
# signs for the VM, and start it. On x86-64 Linux the VM runs emulated (QEMU's TCG),
|
||||
# signs for the VM, and start it. On x86-64 the VM runs emulated (QEMU's TCG),
|
||||
# far slower than on an arm64 host
|
||||
reims-ctl create mac --ipsw latest --start
|
||||
|
||||
@@ -494,8 +494,7 @@ pub struct CreateArgs {
|
||||
/// image's BaseSystem.img, or a DMG, converted to a raw image in the VM's directory
|
||||
#[arg(long)]
|
||||
pub installer: Option<PathBuf>,
|
||||
/// On an arm64 Mac, arm64 Linux or x86-64 Linux: the IPSW to restore an arm64 VM's macOS
|
||||
/// from: latest,
|
||||
/// Restore an arm64 guest on a host with the arm64 guest runtime. Use latest for
|
||||
/// the current macOS, downloaded from Apple once and kept (reims-ctl downloads lists it),
|
||||
/// or an IPSW's path, read where it is. The VM needs one boot, which makes its Data volume,
|
||||
/// and then `reims-restore finish-eacs DIR`
|
||||
@@ -2245,7 +2244,7 @@ mod tests {
|
||||
"{e}"
|
||||
);
|
||||
assert!(
|
||||
e.contains("An arm64 guest on an arm64 Mac, arm64 Linux or x86-64 Linux:"),
|
||||
e.contains("An arm64 guest on a host with the arm64 guest runtime:"),
|
||||
"{e}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1670,7 +1670,7 @@ mod tests {
|
||||
..arm64_spec(&env)
|
||||
});
|
||||
assert!(e.contains("not an existing one"), "{e}");
|
||||
// An IPSW makes no x86-64 VM, and a Windows host runs no arm64 one.
|
||||
// An IPSW selects an arm64 VM, which needs a host that supports it.
|
||||
let x86 = Host {
|
||||
os: crate::host::Os::Linux,
|
||||
arch: crate::host::Arch::X86_64,
|
||||
@@ -1685,7 +1685,7 @@ mod tests {
|
||||
assert!(e.starts_with("an IPSW makes an arm64 VM"), "{e}");
|
||||
let win = Host {
|
||||
os: crate::host::Os::Windows,
|
||||
arch: crate::host::Arch::X86_64,
|
||||
arch: crate::host::Arch::Aarch64,
|
||||
};
|
||||
let e = create_with(arm64_spec(&env), win, &mut |_| {}, &Fake::Succeeds, &cancel)
|
||||
.unwrap_err()
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
//! several times slower than on an arm64 host. On Linux on x86-64 it is the second profile, an
|
||||
//! IPSW's, and q35 the default.
|
||||
//!
|
||||
//! Any other host runs none ([`UNSUPPORTED`]). Windows on x86-64 runs no arm64 VM: its QEMU is
|
||||
//! built for x86-64 guests alone (scripts/install-ctl.sh).
|
||||
//! A Windows x86-64 build with the optional arm64 guest runtime also offers vmapple under TCG.
|
||||
//! Any other host runs none ([`UNSUPPORTED`]).
|
||||
//!
|
||||
//! Another host or guest architecture is another profile (x86-64 guests on an Intel Mac would be
|
||||
//! `q35` on HVF, without the memfd RAM only Linux has): add it here and in `qemu.rs`.
|
||||
@@ -23,8 +23,13 @@ use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
|
||||
/// What reims-ctl tells a host it runs no VMs on, for a create or a start there.
|
||||
pub const UNSUPPORTED: &str = "reims-ctl runs x86-64 VMs on Linux and Windows x86-64 hosts, \
|
||||
and arm64 VMs on arm64 Macs, arm64 Linux and Linux on x86-64";
|
||||
pub const UNSUPPORTED: &str = if cfg!(feature = "windows-arm64-guest") {
|
||||
"reims-ctl runs x86-64 VMs on Linux and Windows x86-64 hosts, and arm64 VMs on arm64 Macs, \
|
||||
arm64 Linux, and x86-64 Linux and Windows"
|
||||
} else {
|
||||
"reims-ctl runs x86-64 VMs on Linux and Windows x86-64 hosts, \
|
||||
and arm64 VMs on arm64 Macs, arm64 Linux and Linux on x86-64"
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Os {
|
||||
@@ -156,6 +161,9 @@ impl Profile {
|
||||
pub fn supported_on(host: Host) -> &'static [Profile] {
|
||||
match (host.os, host.arch) {
|
||||
(Os::Linux, Arch::X86_64) => &[Profile::Q35X86_64, Profile::VmappleArm64],
|
||||
(Os::Windows, Arch::X86_64) if cfg!(feature = "windows-arm64-guest") => {
|
||||
&[Profile::Q35X86_64, Profile::VmappleArm64]
|
||||
}
|
||||
(Os::Windows, Arch::X86_64) => &[Profile::Q35X86_64],
|
||||
(Os::Mac | Os::Linux, Arch::Aarch64) => &[Profile::VmappleArm64],
|
||||
_ => &[],
|
||||
@@ -187,6 +195,7 @@ impl Profile {
|
||||
match self {
|
||||
Profile::Q35X86_64 if cfg!(windows) => "qemu-system-x86_64.exe",
|
||||
Profile::Q35X86_64 => "qemu-system-x86_64",
|
||||
Profile::VmappleArm64 if cfg!(windows) => "qemu-system-aarch64.exe",
|
||||
Profile::VmappleArm64 => "qemu-system-aarch64",
|
||||
}
|
||||
}
|
||||
@@ -233,7 +242,7 @@ impl Profile {
|
||||
/// [`crate::qemu`]'s module doc), and its section committed whole on Windows. The arm64
|
||||
/// machine's memfd is allocated as the guest touches it.
|
||||
pub fn ram_whole_at_start(self, host: Host) -> bool {
|
||||
self == Profile::Q35X86_64 && (self.memfd_ram(host) || self.section_ram(host))
|
||||
self.section_ram(host) || (self == Profile::Q35X86_64 && self.memfd_ram(host))
|
||||
}
|
||||
|
||||
/// Whether a Vulkan GPU can be chosen: the library runs on the host's Vulkan GPUs on Linux
|
||||
@@ -307,7 +316,10 @@ mod tests {
|
||||
assert_eq!(arm.accel_arg(arm_linux), "kvm");
|
||||
assert!(arm.memfd_ram(arm_linux) && arm.gpu_choice(arm_linux));
|
||||
assert!(arm.describe(arm_linux).ends_with("KVM)"));
|
||||
assert_eq!(arm.qemu_binary(), "qemu-system-aarch64");
|
||||
assert_eq!(
|
||||
arm.qemu_binary(),
|
||||
format!("qemu-system-aarch64{}", std::env::consts::EXE_SUFFIX)
|
||||
);
|
||||
for (os, arch) in [
|
||||
(Os::Mac, Arch::X86_64),
|
||||
(Os::Windows, Arch::Aarch64),
|
||||
@@ -326,7 +338,11 @@ mod tests {
|
||||
arch: Arch::X86_64,
|
||||
};
|
||||
let q35 = Profile::Q35X86_64;
|
||||
assert_eq!(Profile::supported_on(windows), [q35]);
|
||||
assert_eq!(windows.default_profile(), Some(q35));
|
||||
assert_eq!(
|
||||
Profile::supported_on(windows).contains(&Profile::VmappleArm64),
|
||||
cfg!(feature = "windows-arm64-guest")
|
||||
);
|
||||
assert_eq!(q35.accel(windows), "whpx");
|
||||
assert!(q35.section_ram(windows) && !q35.memfd_ram(windows));
|
||||
assert!(q35.ram_whole_at_start(windows));
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
//!
|
||||
//! `REIMS_CTL_QEMU` names a QEMU binary to use instead (a build tree's, such as `make qemu`'s
|
||||
//! `build/qemu/qemu-system-x86_64`); `qemu-img` is taken from beside it.
|
||||
//! `REIMS_CTL_QEMU_AARCH64` overrides the arm64 emulator. On Windows its default is the
|
||||
//! arm64 executable beside the x86 emulator in the same portable runtime.
|
||||
|
||||
use crate::host::Profile;
|
||||
use crate::paths;
|
||||
@@ -83,8 +85,28 @@ impl Install {
|
||||
|
||||
/// The QEMU binary for `profile`.
|
||||
pub fn qemu_binary(profile: Profile) -> Result<PathBuf> {
|
||||
if profile == Profile::VmappleArm64
|
||||
&& let Some(p) = std::env::var_os("REIMS_CTL_QEMU_AARCH64")
|
||||
{
|
||||
let arm = paths::native(PathBuf::from(p));
|
||||
if !arm.is_file() {
|
||||
bail!("{} is missing: check REIMS_CTL_QEMU_AARCH64", arm.display());
|
||||
}
|
||||
return Ok(arm);
|
||||
}
|
||||
if let Some(p) = std::env::var_os("REIMS_CTL_QEMU") {
|
||||
return Ok(paths::native(PathBuf::from(p)));
|
||||
let bin = paths::native(PathBuf::from(p));
|
||||
if cfg!(windows) && profile == Profile::VmappleArm64 {
|
||||
let arm = bin.with_file_name(profile.qemu_binary());
|
||||
if !arm.is_file() {
|
||||
bail!(
|
||||
"{} is missing: install the arm64 guest runtime or set REIMS_CTL_QEMU_AARCH64",
|
||||
arm.display()
|
||||
);
|
||||
}
|
||||
return Ok(arm);
|
||||
}
|
||||
return Ok(bin);
|
||||
}
|
||||
let bin = paths::qemu_root()
|
||||
.join("current")
|
||||
|
||||
@@ -836,7 +836,7 @@ mod tests {
|
||||
|
||||
/// A reims-ctl for Windows, which runs no arm64 VM, carries neither the arm64 set nor the
|
||||
/// module (build.rs).
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, not(feature = "windows-arm64-guest")))]
|
||||
#[test]
|
||||
fn a_reims_ctl_for_windows_carries_no_arm64_guest() {
|
||||
assert!(super::SET_ARM64E.is_none());
|
||||
@@ -845,9 +845,10 @@ mod tests {
|
||||
|
||||
/// The module build.rs built is an aarch64 ELF static PIE, the module format Ambrosia loads:
|
||||
/// a checkout whose clang can't build it fails here, not at an arm64 VM's start.
|
||||
#[cfg(not(windows))]
|
||||
#[cfg(any(not(windows), feature = "windows-arm64-guest"))]
|
||||
#[test]
|
||||
fn the_module_is_built() {
|
||||
assert!(!super::SET_ARM64E.expect("the arm64 guest set").is_empty());
|
||||
let elf = AMBROSIA_MODULE.expect(
|
||||
"build.rs built no module for Ambrosia: its warning says why (is clang installed?)",
|
||||
);
|
||||
|
||||
@@ -537,6 +537,8 @@ fn vmapple(vm: &Vm, ctx: &Ctx, a: &mut Vec<String>) -> Result<()> {
|
||||
let mut machine = format!("vmapple,uuid=0x{:016x}", v.ecid);
|
||||
if c.profile.memfd_ram(ctx.host) {
|
||||
machine.push_str(",memory-backend=ram,dump-guest-core=off");
|
||||
} else if c.profile.section_ram(ctx.host) {
|
||||
machine.push_str(",memory-backend=ram");
|
||||
}
|
||||
push(&["-machine", &machine, "-m", &mem]);
|
||||
if c.profile.memfd_ram(ctx.host) {
|
||||
@@ -544,6 +546,11 @@ fn vmapple(vm: &Vm, ctx: &Ctx, a: &mut Vec<String>) -> Result<()> {
|
||||
"-object",
|
||||
&format!("memory-backend-memfd,id=ram,size={mem},share=on"),
|
||||
]);
|
||||
} else if c.profile.section_ram(ctx.host) {
|
||||
push(&[
|
||||
"-object",
|
||||
&format!("memory-backend-ram,id=ram,size={mem},share=on"),
|
||||
]);
|
||||
}
|
||||
push(&["-smp", &c.cpus.to_string()]);
|
||||
push(&["-bios", &boot.ambrosia.to_string_lossy()]);
|
||||
@@ -950,6 +957,31 @@ pub(crate) mod tests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(feature = "windows-arm64-guest")]
|
||||
#[test]
|
||||
fn arm64_on_x86_64_windows_runs_on_tcg_with_a_shared_section() {
|
||||
let host = Host {
|
||||
os: Os::Windows,
|
||||
arch: Arch::X86_64,
|
||||
};
|
||||
let inv = invocation(&arm64_vm(), &arm64_ctx(host)).unwrap();
|
||||
assert!(
|
||||
inv.args
|
||||
.windows(2)
|
||||
.any(|a| a == ["-accel", "tcg,thread=multi"])
|
||||
);
|
||||
assert!(
|
||||
inv.args
|
||||
.windows(2)
|
||||
.any(|a| a == ["-object", "memory-backend-ram,id=ram,size=8192M,share=on"])
|
||||
);
|
||||
assert!(inv.args.windows(2).any(|a| a
|
||||
== [
|
||||
"-machine",
|
||||
"vmapple,uuid=0x9e35f01edc0c5536,memory-backend=ram"
|
||||
]));
|
||||
}
|
||||
|
||||
/// An arm64 VM on an x86-64 Linux host: vmapple under TCG, a thread for each vCPU, in memfd
|
||||
/// RAM, which the library on Linux needs.
|
||||
#[test]
|
||||
|
||||
@@ -853,12 +853,22 @@ fn random_bytes<const N: usize>() -> [u8; N] {
|
||||
.and_then(|mut f| f.read_exact(&mut b))
|
||||
.is_err()
|
||||
{
|
||||
// Windows has no /dev/urandom. The clock alone is no random source there: it counts
|
||||
// 100 ns, so its low bytes hold some 22 bits, the first of them a multiple of 4, and the
|
||||
// pid, shifted past them, changes none. std's RandomState is keyed from the OS's random
|
||||
// source (ProcessPrng on Windows), so a hash it keys is unpredictable; the clock and the
|
||||
// pid are hashed in too.
|
||||
use std::hash::{BuildHasher, Hasher};
|
||||
let t = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default();
|
||||
let seed = t.as_nanos() ^ (std::process::id() as u128) << 64;
|
||||
for (i, x) in b.iter_mut().enumerate() {
|
||||
*x = (seed >> (i * 8)) as u8;
|
||||
let keys = std::collections::hash_map::RandomState::new();
|
||||
for (i, chunk) in b.chunks_mut(8).enumerate() {
|
||||
let mut h = keys.build_hasher();
|
||||
h.write_usize(i);
|
||||
h.write_u128(t.as_nanos());
|
||||
h.write_u32(std::process::id());
|
||||
chunk.copy_from_slice(&h.finish().to_le_bytes()[..chunk.len()]);
|
||||
}
|
||||
}
|
||||
b
|
||||
|
||||
@@ -64,7 +64,7 @@ zip = { version = "9.5.1", default-features = false, features = ["deflate-flate2
|
||||
|
||||
# The space free on a volume (src/sys/windows.rs).
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_Storage_FileSystem"] }
|
||||
windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Ioctl"] }
|
||||
|
||||
[dev-dependencies]
|
||||
# Writes the tests' synthetic IPSWs.
|
||||
|
||||
@@ -475,6 +475,8 @@ impl Files {
|
||||
for (name, size) in [(DISK, disk_size), (AUX_TRIMMED, AUX_SIZE)] {
|
||||
let p = self.part(name);
|
||||
let f = File::create(&p).with_context(|| format!("make {}", p.display()))?;
|
||||
#[cfg(windows)]
|
||||
crate::sys::set_sparse(&f)?;
|
||||
f.set_len(size)
|
||||
.with_context(|| format!("size {} to {size} bytes", p.display()))?;
|
||||
}
|
||||
@@ -501,7 +503,7 @@ impl Files {
|
||||
}
|
||||
let f = File::open(&from).context("open the disk")?;
|
||||
let m = f.metadata()?;
|
||||
let used = crate::sys::allocated(&m);
|
||||
let used = crate::sys::allocated(&from, &m);
|
||||
check_space(&self.dir, free_space(&self.dir)?, used)?;
|
||||
copy_sparse(&f, 0, m.len(), &to, 0)?;
|
||||
Ok(Some(used))
|
||||
@@ -530,9 +532,7 @@ impl Files {
|
||||
if name == EACS_DISK && !p.exists() {
|
||||
continue;
|
||||
}
|
||||
File::open(&p)
|
||||
.and_then(|f| f.sync_all())
|
||||
.with_context(|| format!("flush {}", p.display()))?;
|
||||
sync_image(&p)?;
|
||||
}
|
||||
// The machine identifier goes last; a failed move takes back those made before it.
|
||||
let mut moved = Vec::new();
|
||||
@@ -625,6 +625,8 @@ fn clone_file(from: &Path, to: &Path) -> bool {
|
||||
fn copy_sparse(from: &File, at: u64, len: u64, to: &Path, to_at: u64) -> Result<()> {
|
||||
use reims_apfs::file_at::FileAt as _;
|
||||
let out = File::create(to).with_context(|| format!("make {}", to.display()))?;
|
||||
#[cfg(windows)]
|
||||
crate::sys::set_sparse(&out)?;
|
||||
out.set_len(to_at + len)?;
|
||||
let mut buf = vec![0u8; 1 << 20];
|
||||
let mut done = 0;
|
||||
@@ -759,9 +761,7 @@ fn start_again(dir: &Path) -> Result<()> {
|
||||
let f = File::open(&pre).with_context(|| format!("open {}", pre.display()))?;
|
||||
copy_sparse(&f, 0, f.metadata()?.len(), &part, 0)?;
|
||||
}
|
||||
File::open(&part)
|
||||
.and_then(|f| f.sync_all())
|
||||
.with_context(|| format!("flush {}", part.display()))?;
|
||||
sync_image(&part)?;
|
||||
std::fs::rename(&part, dir.join(DISK)).context("move the restored disk back into place")?;
|
||||
let restored = std::fs::read(dir.join(EACS_AUX))
|
||||
.with_context(|| format!("read {}", dir.join(EACS_AUX).display()))?;
|
||||
@@ -783,13 +783,28 @@ fn put_aux(dir: &Path, trimmed: &[u8]) -> Result<()> {
|
||||
for (name, bytes) in [(AUX_TRIMMED, trimmed), (AUX, &h[..])] {
|
||||
let p = dir.join(name);
|
||||
let tmp = dir.join(format!("{name}.part"));
|
||||
std::fs::write(&tmp, bytes).with_context(|| format!("write {}", tmp.display()))?;
|
||||
File::open(&tmp)?.sync_all()?;
|
||||
{
|
||||
let mut file =
|
||||
File::create(&tmp).with_context(|| format!("create {}", tmp.display()))?;
|
||||
file.write_all(bytes)
|
||||
.with_context(|| format!("write {}", tmp.display()))?;
|
||||
file.sync_all()
|
||||
.with_context(|| format!("flush {}", tmp.display()))?;
|
||||
}
|
||||
std::fs::rename(&tmp, &p).with_context(|| format!("move {} into place", p.display()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// FlushFileBuffers on Windows requires a writable handle even when no further writes are due.
|
||||
fn sync_image(path: &Path) -> Result<()> {
|
||||
OpenOptions::new()
|
||||
.write(true)
|
||||
.open(path)
|
||||
.and_then(|file| file.sync_all())
|
||||
.with_context(|| format!("flush {}", path.display()))
|
||||
}
|
||||
|
||||
/// Virtualization.framework's machine identifier: `{ECID: n}`.
|
||||
fn machine_identifier(ecid: u64) -> Value {
|
||||
let mut d = Dictionary::new();
|
||||
|
||||
@@ -19,6 +19,6 @@ pub fn free_space(dir: &Path) -> Result<u64> {
|
||||
|
||||
/// The space the file `m` describes takes on its file system: its 512-byte blocks, fewer than
|
||||
/// its length where it is sparse.
|
||||
pub fn allocated(m: &std::fs::Metadata) -> u64 {
|
||||
pub fn allocated(_path: &Path, m: &std::fs::Metadata) -> u64 {
|
||||
m.blocks() * 512
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
//! [`super`] on Windows, where reims-ctl makes no arm64 VM (its host.rs), so no restore runs:
|
||||
//! these answer as reims-ctl's code that the restore shares with x86-64 VMs needs them.
|
||||
//! Storage for a restore on Windows.
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use std::os::windows::ffi::OsStrExt as _;
|
||||
use std::os::windows::io::AsRawHandle as _;
|
||||
use std::path::Path;
|
||||
use windows_sys::Win32::Storage::FileSystem::GetDiskFreeSpaceExW;
|
||||
|
||||
@@ -26,8 +26,51 @@ pub fn free_space(dir: &Path) -> Result<u64> {
|
||||
Ok(free)
|
||||
}
|
||||
|
||||
/// The space the file `m` describes takes on its volume, counted as its length: a sparse file's
|
||||
/// holes count as written, so a check of room for its copy asks for more than the copy takes.
|
||||
pub fn allocated(m: &std::fs::Metadata) -> u64 {
|
||||
m.len()
|
||||
/// Mark the empty image before extending it. Volumes without sparse files retain dense images.
|
||||
pub fn set_sparse(file: &std::fs::File) -> Result<()> {
|
||||
use windows_sys::Win32::Foundation::{ERROR_INVALID_FUNCTION, ERROR_NOT_SUPPORTED};
|
||||
use windows_sys::Win32::System::{IO::DeviceIoControl, Ioctl::FSCTL_SET_SPARSE};
|
||||
let mut returned = 0;
|
||||
// SAFETY: the synchronous file handle is live and this control takes no buffers.
|
||||
let ok = unsafe {
|
||||
DeviceIoControl(
|
||||
file.as_raw_handle(),
|
||||
FSCTL_SET_SPARSE,
|
||||
std::ptr::null(),
|
||||
0,
|
||||
std::ptr::null_mut(),
|
||||
0,
|
||||
&mut returned,
|
||||
std::ptr::null_mut(),
|
||||
)
|
||||
};
|
||||
if ok == 0 {
|
||||
let error = std::io::Error::last_os_error();
|
||||
if !matches!(
|
||||
error.raw_os_error().map(|c| c as u32),
|
||||
Some(ERROR_INVALID_FUNCTION | ERROR_NOT_SUPPORTED)
|
||||
) {
|
||||
return Err(error).context("mark restore image sparse");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The disk space its backup needs. Fall back to the logical size if the query fails.
|
||||
pub fn allocated(path: &Path, m: &std::fs::Metadata) -> u64 {
|
||||
use windows_sys::Win32::Foundation::{GetLastError, SetLastError};
|
||||
use windows_sys::Win32::Storage::FileSystem::{GetCompressedFileSizeW, INVALID_FILE_SIZE};
|
||||
let wide: Vec<u16> = path.as_os_str().encode_wide().chain(Some(0)).collect();
|
||||
let mut high = 0;
|
||||
// SAFETY: the string is NUL-terminated and high is writable. Clearing the thread's last
|
||||
// error distinguishes a legitimate all-ones low word from a failed query.
|
||||
unsafe {
|
||||
SetLastError(0);
|
||||
let low = GetCompressedFileSizeW(wide.as_ptr(), &mut high);
|
||||
if low == INVALID_FILE_SIZE && GetLastError() != 0 {
|
||||
m.len()
|
||||
} else {
|
||||
(u64::from(high) << 32) | u64::from(low)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -881,6 +881,10 @@ RvgStatus rvg_graphics_device_set_doorbell(RvgGraphicsDevice *device, void *even
|
||||
//
|
||||
// # Safety
|
||||
// `device` is a live graphics device handle.
|
||||
RvgStatus rvg_graphics_device_set_memory_map(RvgGraphicsDevice *device,
|
||||
const RvgMemoryMap *map,
|
||||
const RvgMemoryRangeFile *files);
|
||||
|
||||
void rvg_graphics_device_reset(RvgGraphicsDevice *device);
|
||||
|
||||
// What the device's display shows now, read back into `dst`: the guest's scanout, or the
|
||||
|
||||
@@ -1023,6 +1023,32 @@ unsafe fn set_doorbell(device: *mut RvgGraphicsDevice, doorbell: RawDoorbell) ->
|
||||
///
|
||||
/// # Safety
|
||||
/// `device` is a live graphics device handle.
|
||||
/// Installs the guest RAM map on a live graphics device (used by hosted ARM64 translators whose
|
||||
/// inner physical address layout is established after PCI realize and before driver handshake).
|
||||
///
|
||||
/// # Safety
|
||||
/// `device` is a live graphics device handle; `map` and `files` obey the same contract as
|
||||
/// `RvgGraphicsDeviceConfig.memory_map` and `memory_files`.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn rvg_graphics_device_set_memory_map(
|
||||
device: *mut RvgGraphicsDevice,
|
||||
map: *const RvgMemoryMap,
|
||||
files: *const RvgMemoryRangeFile,
|
||||
) -> RvgStatus {
|
||||
ffi::export(|| {
|
||||
let d = unsafe { live(device, "rvg_graphics_device_set_memory_map") };
|
||||
let parsed = match unsafe { memory_map(map, files) } {
|
||||
Ok(Some(m)) => m,
|
||||
Ok(None) => return RVG_ERR_INVALID_ARGUMENT,
|
||||
Err(status) => return status,
|
||||
};
|
||||
match d.device.set_memory_map(parsed) {
|
||||
Ok(()) => RVG_OK,
|
||||
Err(err) => status(err),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn rvg_graphics_device_reset(device: *mut RvgGraphicsDevice) {
|
||||
ffi::export(|| {
|
||||
|
||||
@@ -28,8 +28,6 @@ them; its `manual` checks are on a Linux host's guest boot.
|
||||
| `displays=2` | the reims-graphics device's displays, 1 to 4, a window each (QEMU's reims-graphics-pci property; 1 by default) |
|
||||
| `REIMS_VGPU_WINDOW_IMPL=sdl` | macOS, built with the `macos-sdl` feature (on by default): SDL3's window in place of AppKit's ("On macOS through SDL3" below) |
|
||||
| `REIMS_VGPU_WINDOW_CAPTURE=0` | capture off: no window ever captures the keyboard or the pointer ("Capture off" below); reims-ctl sets it for a VM whose capture setting is off |
|
||||
| `REIMS_VGPU_WINDOW_RELEASE_KEYS=Ctrl+Shift+F12` | additional release shortcut for SDL windows on Windows and Linux; when unset, `REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_KEYS` can supply it |
|
||||
| `REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_RELEASE_ON_LEAVE=1` | on Windows and Linux, allow the pointer to leave a captured SDL window and release input when it leaves |
|
||||
|
||||
Unset or unparsable values give the defaults below.
|
||||
`test: env::unset_or_unparsable_values_are_the_defaults`,
|
||||
@@ -702,19 +700,6 @@ runtime's own device. The switches above apply, and `resolution=` too.
|
||||
`test: sdl::shell::the_end_lets_go_of_the_grab_and_the_holds`,
|
||||
`test: sdl::shell::the_pointer_is_held_over_the_image_in_whole_points`,
|
||||
`manual` (the grab and the hold)
|
||||
- An additional release shortcut uses at least one modifier and one to three
|
||||
ordinary keys. The captured title shows the shortcut, and an empty or
|
||||
invalid setting uses the default. The built-in release chord still works
|
||||
with an additional shortcut set.
|
||||
`test: native::sdl_thread::input::custom_shortcut_releases_capture_without_forwarding_its_final_key`,
|
||||
`test: native::sdl_thread::input::custom_shortcut_can_hold_two_regular_keys`,
|
||||
`test: native::sdl_thread::input::invalid_shortcut_keeps_the_default`
|
||||
- With release on mouse leave enabled, capture allows the pointer out of the
|
||||
window. The SDL mouse-leave event lifts held keys and buttons and releases
|
||||
capture. This setting also turns off relative pointer locks in games and
|
||||
at a shared display edge.
|
||||
`test: native::sdl_thread::input::leaving_the_window_releases_mouse_and_keyboard_when_enabled`,
|
||||
`manual` (move the pointer out of a captured SDL window)
|
||||
- Scrolling: the wheel's notches, or, where the host takes smooth
|
||||
scrolling, its lines at 10 points each, in no gesture (SDL gives no
|
||||
phases); the guest gets the device's own direction.
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
//! no window ever captures the keyboard or the pointer ([`crate::capture`]). `1`, `true`,
|
||||
//! `yes` or `on` turns it on. Default: [`CAPTURE_DEFAULT`]. reims-ctl sets it from a VM's
|
||||
//! settings.
|
||||
//! - `REIMS_VGPU_WINDOW_RELEASE_KEYS`: an additional SDL window capture release shortcut,
|
||||
//! such as `Ctrl+Shift+F12`. Reims-Go's capture shortcut plugin can supply it through its
|
||||
//! own namespace. The original release chord remains available.
|
||||
|
||||
use std::sync::OnceLock;
|
||||
|
||||
@@ -28,11 +25,6 @@ pub const SCREENS_VAR: &str = "REIMS_VGPU_WINDOW_SCREENS";
|
||||
pub const IMPL_VAR: &str = "REIMS_VGPU_WINDOW_IMPL";
|
||||
/// The capture switch's variable.
|
||||
pub const CAPTURE_VAR: &str = "REIMS_VGPU_WINDOW_CAPTURE";
|
||||
/// The extra release shortcut for Windows and Linux SDL windows.
|
||||
pub const RELEASE_KEYS_VAR: &str = "REIMS_VGPU_WINDOW_RELEASE_KEYS";
|
||||
/// The same shortcut supplied through the Reims-Go capture shortcut plugin.
|
||||
const PLUGIN_RELEASE_KEYS_VAR: &str = "REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_KEYS";
|
||||
const PLUGIN_RELEASE_ON_LEAVE_VAR: &str = "REIMS_PLUGIN_LOCAL_CAPTURE_SHORTCUT_RELEASE_ON_LEAVE";
|
||||
|
||||
/// Whether a click into the image captures input where the capture switch is unset.
|
||||
pub const CAPTURE_DEFAULT: bool = true;
|
||||
@@ -48,10 +40,6 @@ pub struct Settings {
|
||||
pub window_impl: WindowImpl,
|
||||
/// Whether a click into the image captures input; off, nothing ever does.
|
||||
pub capture: bool,
|
||||
/// Additional shortcut text for the SDL window.
|
||||
pub release_keys: Option<String>,
|
||||
/// Let the mouse leave the SDL window and release input when it does.
|
||||
pub release_on_leave: bool,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
@@ -61,8 +49,6 @@ impl Default for Settings {
|
||||
screens: Vec::new(),
|
||||
window_impl: WindowImpl::AppKit,
|
||||
capture: CAPTURE_DEFAULT,
|
||||
release_keys: None,
|
||||
release_on_leave: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,10 +126,6 @@ pub fn settings() -> &'static Settings {
|
||||
Settings {
|
||||
window_impl: parse_impl(var(IMPL_VAR).as_deref()),
|
||||
capture: parse_capture(var(CAPTURE_VAR).as_deref()),
|
||||
release_keys: var(RELEASE_KEYS_VAR).or_else(|| var(PLUGIN_RELEASE_KEYS_VAR)),
|
||||
release_on_leave: var(PLUGIN_RELEASE_ON_LEAVE_VAR)
|
||||
.as_deref()
|
||||
.is_some_and(parse_switch),
|
||||
..parse(borderless.as_deref(), screens.as_deref())
|
||||
}
|
||||
})
|
||||
|
||||
@@ -81,7 +81,7 @@ use crate::config::{
|
||||
};
|
||||
use crate::game::Game;
|
||||
use crate::geometry::{self, Rect};
|
||||
use crate::keys::{KeyEvent, KeyState, Modifiers};
|
||||
use crate::keys::{KeyEvent, KeyState};
|
||||
use crate::scroll::POINTS_PER_LINE;
|
||||
|
||||
/// How soon after the window gains the keyboard a click is the one that focused it, in
|
||||
@@ -180,99 +180,6 @@ fn fixed(points: f64) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// An additional release shortcut, using USB key positions like SDL's keyboard path.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct ReleaseShortcut {
|
||||
modifiers: Modifiers,
|
||||
keys: Vec<u16>,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl ReleaseShortcut {
|
||||
pub(crate) fn parse(value: &str) -> Option<Self> {
|
||||
let parts = value.split('+').map(str::trim).map(str::to_ascii_uppercase);
|
||||
let mut modifiers = Modifiers::default();
|
||||
let mut keys = Vec::new();
|
||||
let mut key_names = Vec::new();
|
||||
for part in parts {
|
||||
let held = match part.as_str() {
|
||||
"CTRL" => &mut modifiers.control,
|
||||
"ALT" => &mut modifiers.option,
|
||||
"SHIFT" => &mut modifiers.shift,
|
||||
"WIN" | "SUPER" => &mut modifiers.command,
|
||||
_ => {
|
||||
let key = Self::parse_key(&part)?;
|
||||
if keys.len() == 3 || keys.contains(&key) {
|
||||
return None;
|
||||
}
|
||||
keys.push(key);
|
||||
key_names.push(part);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if std::mem::replace(held, true) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
if modifiers == Modifiers::default() || keys.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let mut name = String::new();
|
||||
for (held, label) in [
|
||||
(modifiers.control, "Ctrl+"),
|
||||
(modifiers.option, "Alt+"),
|
||||
(modifiers.shift, "Shift+"),
|
||||
(
|
||||
modifiers.command,
|
||||
if cfg!(windows) { "Win+" } else { "Super+" },
|
||||
),
|
||||
] {
|
||||
if held {
|
||||
name.push_str(label);
|
||||
}
|
||||
}
|
||||
name.push_str(&key_names.join("+"));
|
||||
Some(Self {
|
||||
modifiers,
|
||||
keys,
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_key(key_name: &str) -> Option<u16> {
|
||||
let key = match key_name.as_bytes() {
|
||||
[letter @ b'A'..=b'Z'] => u16::from(*letter - b'A') + 0x04,
|
||||
[digit @ b'1'..=b'9'] => u16::from(*digit - b'1') + 0x1e,
|
||||
[b'0'] => 0x27,
|
||||
_ => {
|
||||
let number = key_name.strip_prefix('F')?.parse::<u16>().ok()?;
|
||||
if !matches!(
|
||||
key_name,
|
||||
"F1" | "F2"
|
||||
| "F3"
|
||||
| "F4"
|
||||
| "F5"
|
||||
| "F6"
|
||||
| "F7"
|
||||
| "F8"
|
||||
| "F9"
|
||||
| "F10"
|
||||
| "F11"
|
||||
| "F12"
|
||||
) {
|
||||
return None;
|
||||
}
|
||||
0x3a + number - 1
|
||||
}
|
||||
};
|
||||
Some(key)
|
||||
}
|
||||
|
||||
pub(crate) fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
/// One window's input decisions (the module doc).
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Input {
|
||||
@@ -280,8 +187,6 @@ pub(crate) struct Input {
|
||||
keys: KeyState,
|
||||
/// Who gets the keyboard.
|
||||
capture: Capture,
|
||||
release_shortcut: Option<ReleaseShortcut>,
|
||||
release_on_leave: bool,
|
||||
/// The `BUTTON_*` bits of the buttons the guest was told are down.
|
||||
buttons: u32,
|
||||
/// The pointer event last sent.
|
||||
@@ -344,30 +249,6 @@ impl Input {
|
||||
Input { capture, ..self }
|
||||
}
|
||||
|
||||
/// Sets an additional shortcut for releasing captured input.
|
||||
pub(crate) fn with_release_shortcut(self, release_shortcut: Option<ReleaseShortcut>) -> Input {
|
||||
Input {
|
||||
release_shortcut,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn with_release_on_leave(self, release_on_leave: bool) -> Input {
|
||||
Input {
|
||||
release_on_leave,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
/// Let the host have the keyboard and pointer when the mouse leaves the window.
|
||||
pub(crate) fn mouse_left(&mut self) -> Reaction {
|
||||
if !self.release_on_leave || !self.is_captured() {
|
||||
return Reaction::default();
|
||||
}
|
||||
self.lift_buttons();
|
||||
self.release_capture()
|
||||
}
|
||||
|
||||
/// Whether the captured pointer has gone past the image's edge.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn is_away(&self) -> bool {
|
||||
@@ -426,26 +307,13 @@ impl Input {
|
||||
/// Where the pointer is held over `image`, the image's rectangle in the window's points: the
|
||||
/// image while captured ([`Capture::pointer_confinement`]).
|
||||
pub(crate) fn pointer_confinement(&self, image: Rect) -> Option<Rect> {
|
||||
if self.release_on_leave {
|
||||
None
|
||||
} else {
|
||||
self.capture.pointer_confinement(image)
|
||||
}
|
||||
self.capture.pointer_confinement(image)
|
||||
}
|
||||
|
||||
/// What the title ends with: the release chord while captured, in the host's OS's names for
|
||||
/// its keys, and that a click captures while not ([`Capture::title_suffix`]).
|
||||
pub(crate) fn title_suffix(&self) -> std::borrow::Cow<'_, str> {
|
||||
if self.is_captured()
|
||||
&& let Some(shortcut) = &self.release_shortcut
|
||||
{
|
||||
return format!(
|
||||
" \u{2014} input captured (press {} to release)",
|
||||
shortcut.name
|
||||
)
|
||||
.into();
|
||||
}
|
||||
self.capture.title_suffix(HOST_OS).into()
|
||||
pub(crate) fn title_suffix(&self) -> &'static str {
|
||||
self.capture.title_suffix(HOST_OS)
|
||||
}
|
||||
|
||||
/// What to send, taken.
|
||||
@@ -477,8 +345,7 @@ impl Input {
|
||||
return;
|
||||
}
|
||||
if let (Some(point), Some(mode)) = (at.point, guest_mode(at)) {
|
||||
if !self.release_on_leave
|
||||
&& self.capture.is_captured()
|
||||
if self.capture.is_captured()
|
||||
&& let Some(motion) = self.motion.clone()
|
||||
&& let Some(hold) = self.game.begin(motion.as_ref(), point)
|
||||
{
|
||||
@@ -489,8 +356,7 @@ impl Input {
|
||||
Some(ToHost::Pointer { at, .. }) => Some(at),
|
||||
_ => None,
|
||||
};
|
||||
if !self.release_on_leave
|
||||
&& self.capture.is_captured()
|
||||
if self.capture.is_captured()
|
||||
&& let Some(beyond) = self.beyond.clone()
|
||||
&& let Some(hold) =
|
||||
self.away
|
||||
@@ -686,18 +552,6 @@ impl Input {
|
||||
}
|
||||
return Reaction::default();
|
||||
}
|
||||
if self.is_captured()
|
||||
&& let Some(shortcut) = &self.release_shortcut
|
||||
&& shortcut.keys.contains(&usage)
|
||||
&& shortcut
|
||||
.keys
|
||||
.iter()
|
||||
.all(|&key| key == usage || self.keys.is_held(key))
|
||||
&& shortcut.modifiers == self.keys.held_modifiers()
|
||||
&& !repeat
|
||||
{
|
||||
return self.release_capture();
|
||||
}
|
||||
if let Some(event) = self.keys.key_down(usage, repeat) {
|
||||
self.out.push(ToHost::Key(event));
|
||||
}
|
||||
@@ -1011,80 +865,6 @@ mod tests {
|
||||
assert_eq!(input.title_suffix(), UNCAPTURED_SUFFIX);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_shortcut_releases_capture_without_forwarding_its_final_key() {
|
||||
let mut input =
|
||||
focused().with_release_shortcut(ReleaseShortcut::parse(" shift + ctrl + f12 "));
|
||||
input.button_down(BUTTON_LEFT, 1_000_000_000, &at((10.0, 10.0)));
|
||||
input.button_up(BUTTON_LEFT, &at((10.0, 10.0)));
|
||||
assert!(input.title_suffix().contains("Ctrl+Shift+F12"));
|
||||
input.take();
|
||||
input.key(0xE0, true, false);
|
||||
input.key(0xE1, true, false);
|
||||
let reaction = input.key(0x45, true, false);
|
||||
assert!(reaction.capture_changed && !input.is_captured());
|
||||
assert_eq!(
|
||||
input.take(),
|
||||
vec![
|
||||
ToHost::Key(KeyEvent::down(0xE0)),
|
||||
ToHost::Key(KeyEvent::down(0xE1)),
|
||||
ToHost::Key(KeyEvent::up(0xE1)),
|
||||
ToHost::Key(KeyEvent::up(0xE0)),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_shortcut_keeps_the_default() {
|
||||
for value in [
|
||||
"",
|
||||
"F12",
|
||||
"Ctrl+Shift",
|
||||
"Ctrl+Ctrl+F12",
|
||||
"Ctrl+F13",
|
||||
"Ctrl+F01",
|
||||
] {
|
||||
assert!(ReleaseShortcut::parse(value).is_none(), "{value:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_shortcut_can_hold_two_regular_keys() {
|
||||
let mut input = focused().with_release_shortcut(ReleaseShortcut::parse("Ctrl+A+Z"));
|
||||
let point = at((10.0, 10.0));
|
||||
input.button_down(BUTTON_LEFT, 1_000_000_000, &point);
|
||||
input.button_up(BUTTON_LEFT, &point);
|
||||
assert!(input.title_suffix().contains("Ctrl+A+Z"));
|
||||
assert!(!input.key(0xe0, true, false).capture_changed);
|
||||
assert!(!input.key(0x04, true, false).capture_changed);
|
||||
assert!(input.key(0x1d, true, false).capture_changed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leaving_the_window_releases_mouse_and_keyboard_when_enabled() {
|
||||
for enabled in [false, true] {
|
||||
let mut input = focused().with_release_on_leave(enabled);
|
||||
let point = at((10.0, 10.0));
|
||||
input.button_down(BUTTON_LEFT, 1_000_000_000, &point);
|
||||
input.key(0x04, true, false);
|
||||
assert!(input.is_captured());
|
||||
assert_eq!(input.pointer_confinement(point.image).is_none(), enabled);
|
||||
input.take();
|
||||
assert_eq!(input.mouse_left().capture_changed, enabled);
|
||||
assert_eq!(input.is_captured(), !enabled);
|
||||
if enabled {
|
||||
let events = input.take();
|
||||
assert!(events.contains(&ToHost::Key(KeyEvent::up(0x04))));
|
||||
assert!(
|
||||
events
|
||||
.iter()
|
||||
.any(|event| matches!(event, ToHost::Pointer { buttons: 0, .. }))
|
||||
);
|
||||
assert!(!input.mouse_left().capture_changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// With capture off, a click in the image is sent but captures nothing, so nothing holds the
|
||||
/// pointer; the pointer outside the image is sent only in a drag; Ctrl, Alt and the GUI key
|
||||
/// are the guest's keys and release nothing; the title says capture is off
|
||||
|
||||
@@ -113,10 +113,6 @@ impl Input {
|
||||
self.0.focus_lost().capture_changed
|
||||
}
|
||||
|
||||
pub(crate) fn mouse_left(&mut self) -> bool {
|
||||
self.0.mouse_left().capture_changed
|
||||
}
|
||||
|
||||
/// Whether input, the keyboard and the pointer, is captured.
|
||||
pub(crate) fn is_captured(&self) -> bool {
|
||||
self.0.is_captured()
|
||||
@@ -128,7 +124,7 @@ impl Input {
|
||||
}
|
||||
|
||||
/// What the title ends with in the current capture state.
|
||||
pub(crate) fn title_suffix(&self) -> std::borrow::Cow<'_, str> {
|
||||
pub(crate) fn title_suffix(&self) -> &'static str {
|
||||
self.0.title_suffix()
|
||||
}
|
||||
|
||||
@@ -215,25 +211,6 @@ pub(crate) fn open(window: &Arc<Window>, borderless: bool, _taken: &[Frame]) ->
|
||||
display.0
|
||||
);
|
||||
let callbacks = window.callbacks();
|
||||
let settings = crate::env::settings();
|
||||
let release_shortcut = settings
|
||||
.release_keys
|
||||
.as_deref()
|
||||
.and_then(input::ReleaseShortcut::parse);
|
||||
if settings
|
||||
.release_keys
|
||||
.as_deref()
|
||||
.is_some_and(|keys| !keys.trim().is_empty())
|
||||
&& release_shortcut.is_none()
|
||||
{
|
||||
log::warn!(target: "reims_vgpu_window", "invalid input release shortcut; using the default");
|
||||
}
|
||||
log::info!(target: "reims_vgpu_window",
|
||||
"input settings: capture={}, release shortcut={}, release on mouse leave={}",
|
||||
settings.capture,
|
||||
release_shortcut.as_ref().map_or("default", input::ReleaseShortcut::name),
|
||||
settings.release_on_leave,
|
||||
);
|
||||
Some(Opened {
|
||||
sdl,
|
||||
asked: size,
|
||||
@@ -244,9 +221,7 @@ pub(crate) fn open(window: &Arc<Window>, borderless: bool, _taken: &[Frame]) ->
|
||||
.and_then(|callbacks| callbacks.beyond.clone()),
|
||||
callbacks.and_then(|callbacks| callbacks.motion),
|
||||
)
|
||||
.with_capture(Capture::with_setting(settings.capture))
|
||||
.with_release_shortcut(release_shortcut)
|
||||
.with_release_on_leave(settings.release_on_leave),
|
||||
.with_capture(Capture::with_setting(crate::env::settings().capture)),
|
||||
),
|
||||
state: State {
|
||||
display,
|
||||
|
||||
@@ -183,6 +183,8 @@ fn start_video() -> bool {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
super::super::windows::install_unicode_input_hook();
|
||||
// SAFETY: SDL's video runs.
|
||||
let kind = unsafe { SDL_RegisterEvents(1) };
|
||||
WAKE.store(kind, Ordering::Release);
|
||||
|
||||
@@ -42,12 +42,19 @@
|
||||
//! taskbar then goes to the bottom of the z-order while the window is active, and that taking
|
||||
//! the mark away leaves the window to the shell's own detection.
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::ffi::c_void;
|
||||
use std::io::Write;
|
||||
use std::net::{SocketAddr, TcpStream};
|
||||
use std::ptr::{NonNull, null, null_mut};
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::mpsc::{self, RecvTimeoutError, SyncSender};
|
||||
use std::time::Duration;
|
||||
|
||||
use sdl3_sys::everything::{
|
||||
SDL_GetPointerProperty, SDL_GetWindowFlags, SDL_GetWindowProperties,
|
||||
SDL_PROP_WINDOW_WIN32_HWND_POINTER, SDL_WINDOW_FULLSCREEN, SDL_Window,
|
||||
MSG as SDL_MSG, SDL_GetPointerProperty, SDL_GetWindowFlags, SDL_GetWindowProperties,
|
||||
SDL_PROP_WINDOW_WIN32_HWND_POINTER, SDL_SetWindowsMessageHook, SDL_WINDOW_FULLSCREEN,
|
||||
SDL_Window,
|
||||
};
|
||||
use windows_sys::Win32::Foundation::{FALSE, HWND, RPC_E_CHANGED_MODE, S_FALSE, S_OK, TRUE};
|
||||
use windows_sys::Win32::System::Com::{
|
||||
@@ -62,6 +69,198 @@ use crate::capture::HostOs;
|
||||
/// The OS whose names the title gives the release chord's keys: Ctrl+Alt+Win (the module doc).
|
||||
pub(super) const HOST_OS: HostOs = HostOs::Windows;
|
||||
|
||||
/// Win32 MSG layout matching winuser.h for SDL_SetWindowsMessageHook.
|
||||
#[repr(C)]
|
||||
struct Win32Msg {
|
||||
/// Target window handle.
|
||||
_hwnd: HWND,
|
||||
/// Message identifier (WM_*).
|
||||
message: u32,
|
||||
/// WPARAM.
|
||||
w_param: usize,
|
||||
/// LPARAM.
|
||||
_l_param: isize,
|
||||
/// Message timestamp (GetMessageTime).
|
||||
time: u32,
|
||||
/// Cursor position (POINT).
|
||||
_pt: [i32; 2],
|
||||
}
|
||||
|
||||
/// WM_KEYDOWN.
|
||||
const WM_KEYDOWN: u32 = 0x0100;
|
||||
/// WM_CHAR.
|
||||
const WM_CHAR: u32 = 0x0102;
|
||||
/// WM_SYSKEYDOWN.
|
||||
const WM_SYSKEYDOWN: u32 = 0x0104;
|
||||
/// WM_UNICHAR.
|
||||
const WM_UNICHAR: u32 = 0x0109;
|
||||
/// WM_IME_CHAR.
|
||||
const WM_IME_CHAR: u32 = 0x0286;
|
||||
/// UNICODE_NOCHAR.
|
||||
const UNICODE_NOCHAR: usize = 0xFFFF;
|
||||
/// VK_PROCESSKEY (host IME intercepted key).
|
||||
const VK_PROCESSKEY: u16 = 0x00E5;
|
||||
/// VK_PACKET (SendInput with KEYEVENTF_UNICODE).
|
||||
const VK_PACKET: u16 = 0x00E7;
|
||||
|
||||
/// Non-blocking channel carrying UTF-16 code units from the SDL UI thread to the HTTP forwarder.
|
||||
static UNICODE_TX: OnceLock<SyncSender<u16>> = OnceLock::new();
|
||||
|
||||
thread_local! {
|
||||
/// Whether the most recent WM_KEYDOWN was unmapped (VK_PACKET or VK_PROCESSKEY).
|
||||
static LAST_KEY_UNMAPPED: Cell<bool> = const { Cell::new(false) };
|
||||
/// Timestamp of the most recent normal WM_KEYDOWN that SDL translates to a USB key.
|
||||
static LAST_MAPPED_KEY_TIME: Cell<u32> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Parses a loopback http://127.0.0.1:<port><path> endpoint from REIMS_GO_INPUT_URL.
|
||||
fn parse_loopback_input_url(raw: &str) -> Option<(SocketAddr, String)> {
|
||||
let rest = raw.trim().strip_prefix("http://127.0.0.1:")?;
|
||||
let (port_str, path) = match rest.find('/') {
|
||||
Some(idx) => (&rest[..idx], &rest[idx..]),
|
||||
None => (rest, "/v1/host-text"),
|
||||
};
|
||||
let port: u16 = port_str.parse().ok()?;
|
||||
if port == 0 || path.contains(['\r', '\n', ' ']) {
|
||||
return None;
|
||||
}
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], port));
|
||||
Some((addr, path.to_owned()))
|
||||
}
|
||||
|
||||
/// Installs a Win32 message hook on SDL's UI thread when REIMS_GO_INPUT_URL and
|
||||
/// REIMS_GO_INPUT_TOKEN are set, forwarding non-keyboard WM_CHAR / WM_UNICHAR /
|
||||
/// WM_IME_CHAR text (remote IMEs, dictation, host IME commits) to the local host bridge.
|
||||
pub(super) fn install_unicode_input_hook() {
|
||||
let Ok(url) = std::env::var("REIMS_GO_INPUT_URL") else {
|
||||
return;
|
||||
};
|
||||
let Ok(token) = std::env::var("REIMS_GO_INPUT_TOKEN") else {
|
||||
return;
|
||||
};
|
||||
if token.is_empty() || token.contains(['\r', '\n']) {
|
||||
return;
|
||||
}
|
||||
let Some((addr, path)) = parse_loopback_input_url(&url) else {
|
||||
log::warn!(target: "reims_vgpu_window", "ignoring non-loopback REIMS_GO_INPUT_URL");
|
||||
return;
|
||||
};
|
||||
let (tx, rx) = mpsc::sync_channel::<u16>(512);
|
||||
if UNICODE_TX.set(tx).is_err() {
|
||||
return;
|
||||
}
|
||||
let _ = std::thread::Builder::new()
|
||||
.name("reims-vgpu.ime".into())
|
||||
.spawn(move || forward_unicode_loop(rx, addr, path, token));
|
||||
// SAFETY: called on SDL's UI thread right after SDL_Init(SDL_INIT_VIDEO).
|
||||
unsafe { SDL_SetWindowsMessageHook(Some(unicode_message_hook), null_mut()) };
|
||||
}
|
||||
|
||||
/// Enqueues a UTF-16 code unit without blocking the Win32 message loop.
|
||||
fn enqueue_utf16(unit: u16) {
|
||||
if unit != 0
|
||||
&& let Some(tx) = UNICODE_TX.get()
|
||||
{
|
||||
let _ = tx.try_send(unit);
|
||||
}
|
||||
}
|
||||
|
||||
/// SDL Win32 message hook: forwards non-physical WM_CHAR / WM_UNICHAR / WM_IME_CHAR
|
||||
/// events to the local input bridge while leaving all physical keyboard events untouched.
|
||||
unsafe extern "C" fn unicode_message_hook(_userdata: *mut c_void, raw_msg: *mut SDL_MSG) -> bool {
|
||||
if raw_msg.is_null() {
|
||||
return true;
|
||||
}
|
||||
// SAFETY: SDL passes a valid pointer to Win32 MSG for the duration of the callback.
|
||||
let msg = unsafe { &*raw_msg.cast::<Win32Msg>() };
|
||||
match msg.message {
|
||||
WM_KEYDOWN | WM_SYSKEYDOWN => {
|
||||
let vk = (msg.w_param & 0xFFFF) as u16;
|
||||
if vk == VK_PACKET || vk == VK_PROCESSKEY {
|
||||
LAST_KEY_UNMAPPED.set(true);
|
||||
} else {
|
||||
LAST_KEY_UNMAPPED.set(false);
|
||||
LAST_MAPPED_KEY_TIME.set(msg.time);
|
||||
}
|
||||
true
|
||||
}
|
||||
WM_CHAR | WM_IME_CHAR => {
|
||||
let unit = (msg.w_param & 0xFFFF) as u16;
|
||||
let non_physical = unit >= 0x80
|
||||
|| LAST_KEY_UNMAPPED.get()
|
||||
|| msg.time != LAST_MAPPED_KEY_TIME.get();
|
||||
if non_physical && (unit >= 0x20 || unit == 0x0D || unit == 0x09) {
|
||||
enqueue_utf16(unit);
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
WM_UNICHAR => {
|
||||
if msg.w_param != UNICODE_NOCHAR
|
||||
&& let Ok(code) = u32::try_from(msg.w_param)
|
||||
&& let Some(ch) = char::from_u32(code)
|
||||
&& (ch >= ' ' || ch == '\r' || ch == '\t')
|
||||
{
|
||||
let mut pair = [0u16; 2];
|
||||
for &mut u in ch.encode_utf16(&mut pair) {
|
||||
enqueue_utf16(u);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Decodes UTF-16 code units, coalesces bursts, and POSTs UTF-8 text to the loopback bridge.
|
||||
fn forward_unicode_loop(rx: mpsc::Receiver<u16>, addr: SocketAddr, path: String, token: String) {
|
||||
let mut units: Vec<u16> = Vec::with_capacity(64);
|
||||
loop {
|
||||
let first = match rx.recv() {
|
||||
Ok(u) => u,
|
||||
Err(_) => return,
|
||||
};
|
||||
units.clear();
|
||||
units.push(first);
|
||||
if first != 0x0D {
|
||||
while units.len() < 128 {
|
||||
match rx.recv_timeout(Duration::from_millis(35)) {
|
||||
Ok(u) => {
|
||||
units.push(u);
|
||||
if u == 0x0D {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(RecvTimeoutError::Timeout) => break,
|
||||
Err(RecvTimeoutError::Disconnected) => break,
|
||||
}
|
||||
}
|
||||
}
|
||||
let text: String = char::decode_utf16(units.iter().copied())
|
||||
.filter_map(Result::ok)
|
||||
.map(|c| if c == '\r' { '\n' } else { c })
|
||||
.collect();
|
||||
if !text.is_empty() {
|
||||
post_loopback_text(addr, &path, &token, &text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends a minimal HTTP/1.1 POST with UTF-8 ext to the local host bridge.
|
||||
fn post_loopback_text(addr: SocketAddr, path: &str, token: &str, text: &str) {
|
||||
let Ok(mut stream) = TcpStream::connect_timeout(&addr, Duration::from_millis(500)) else {
|
||||
return;
|
||||
};
|
||||
let _ = stream.set_write_timeout(Some(Duration::from_millis(500)));
|
||||
let req = format!(
|
||||
"POST {path} HTTP/1.1\r\nHost: 127.0.0.1\r\nAuthorization: Bearer {token}\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
|
||||
text.len()
|
||||
);
|
||||
let _ = stream.write_all(req.as_bytes());
|
||||
let _ = stream.write_all(text.as_bytes());
|
||||
}
|
||||
|
||||
/// The GPU the compositor composites SDL's window on: none known on Windows (the module doc).
|
||||
///
|
||||
/// # Safety
|
||||
|
||||
@@ -388,11 +388,7 @@ impl Shell {
|
||||
// SDL's cursor is the process's: another window may have hidden it.
|
||||
self.over_image = false;
|
||||
self.refresh_cursor();
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
let released = k == SDL_EVENT_WINDOW_MOUSE_LEAVE.0 && self.input.mouse_left();
|
||||
#[cfg(target_os = "macos")]
|
||||
let released = false;
|
||||
released
|
||||
false
|
||||
}
|
||||
_ => os::input_event(self, kind, event),
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, OnceLock, Weak};
|
||||
|
||||
use metal2vulkan_runtime::host_time;
|
||||
@@ -500,13 +500,15 @@ fn pool_range(room: PoolConfig, heaps: u64) -> Option<PoolConfig> {
|
||||
/// machine where no whole GiB of addresses lies from the end of the PCI host's 64-bit window to
|
||||
/// the top quarter of the guest's physical addresses (under KVM and WHPX, to the host's at most)
|
||||
/// (`reims_graphics_pool_room` and `reims_graphics_pool_room_machine` in
|
||||
/// `hw/display/reims-graphics-pci.c`); a Windows host offers the pool to an x86-64 guest alone.
|
||||
/// `hw/display/reims-graphics-pci.c`); Windows ARM64 guests require the pool opt-in.
|
||||
fn no_pool(given: bool, ranged: bool, offered: bool) -> Option<&'static str> {
|
||||
match (given, ranged, offered) {
|
||||
(_, _, true) => None,
|
||||
(false, _, false) => Some("the host gave the device no guest addresses for one"),
|
||||
(true, false, false) => Some("the GPU answers no memory heap"),
|
||||
(true, true, false) => Some("a Windows host offers one to an x86-64 guest alone"),
|
||||
(true, true, false) => {
|
||||
Some("the Shared pool is disabled for ARM64 guests on this Windows host")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,8 +523,16 @@ pub struct GraphicsDevice<P: ApiPlatform = DefaultPlatform> {
|
||||
cursors: Vec<Arc<HostCursor>>,
|
||||
/// The stage-3 decoder and the device handle it drives, shared with the device's [`Host`],
|
||||
/// which feeds it the control ring's stage-3 messages; held here for the tests' look at it.
|
||||
#[cfg(any(test, feature = "testkit"))]
|
||||
control: Arc<GraphicsControl<P>>,
|
||||
/// Host feature/budget atomics shared with CallbackHost so hosted ARM64 translators can
|
||||
/// install the guest RAM map before the guest graphics driver handshakes.
|
||||
platform_ref: Arc<P>,
|
||||
features_atom: Arc<AtomicU64>,
|
||||
features_16k_atom: Arc<AtomicU64>,
|
||||
deferred_budget_atom: Arc<AtomicU64>,
|
||||
base_features: u64,
|
||||
in_place_features: u64,
|
||||
own_memory_budget: u64,
|
||||
/// What display 0's window shows, where there is one: the tests draw it.
|
||||
#[cfg(test)]
|
||||
shown: Option<Arc<Shown>>,
|
||||
@@ -612,11 +622,17 @@ impl<P: ApiPlatform> GraphicsDevice<P> {
|
||||
// The guest's processes take blocks of it for their buffers' slabs (`POOL`). An
|
||||
// arm64 guest's processes use the blocks write-back, as an x86-64 guest's do: arm64
|
||||
// boots under TCG and HVF ran on them with no fault (docs/graphics-kext/design.md,
|
||||
// "The Shared pool"). A Windows host offers it to an x86-64 guest alone, whose cost
|
||||
// under WHP was measured beside the region's (docs/qemu.md, "Windows hosts: the
|
||||
// Shared pool"): an arm64 guest runs under TCG there, where it was not measured.
|
||||
// "The Shared pool"). Windows offers it by default to x86-64 guests. Its cost under
|
||||
// WHP was measured beside the region's (docs/qemu.md, "Windows hosts: the Shared
|
||||
// pool"). Windows ARM64 guests can opt in to measure the TCG path.
|
||||
let arm64_pool_opt_in = cfg!(windows)
|
||||
&& config.guest_arch == GuestArch::Arm64
|
||||
&& std::env::var_os("REIMS_VGPU_ARM64_SHARED_POOL")
|
||||
.is_some_and(|value| value == "1");
|
||||
let pool_ledger = (shared_pool.as_ref())
|
||||
.filter(|_| !cfg!(windows) || config.guest_arch == GuestArch::X86_64)
|
||||
.filter(|_| {
|
||||
!cfg!(windows) || config.guest_arch == GuestArch::X86_64 || arm64_pool_opt_in
|
||||
})
|
||||
.map(Pool::ledger);
|
||||
// The one line of a device with no pool, whatever kept it from one.
|
||||
if let Some(why) = no_pool(
|
||||
@@ -1042,11 +1058,16 @@ impl<P: ApiPlatform> GraphicsDevice<P> {
|
||||
Arc::new(HostCursor::new(&platform, glyph, show, moved))
|
||||
})
|
||||
.collect();
|
||||
let vt_feats = vt_features(&vt);
|
||||
let base_features = (features & !pages_features & !RGFX_FEATURE_PAGES_16K) | vt_feats;
|
||||
let features_atom = Arc::new(AtomicU64::new(features | vt_feats));
|
||||
let features_16k_atom = Arc::new(AtomicU64::new(features_16k));
|
||||
let deferred_budget_atom = Arc::new(AtomicU64::new(deferred_budget));
|
||||
let host = Box::new(CallbackHost {
|
||||
callbacks: config.callbacks,
|
||||
features: features | vt_features(&vt),
|
||||
features_16k,
|
||||
deferred_budget,
|
||||
features: Arc::clone(&features_atom),
|
||||
features_16k: Arc::clone(&features_16k_atom),
|
||||
deferred_budget: Arc::clone(&deferred_budget_atom),
|
||||
control: Arc::clone(&control),
|
||||
vt,
|
||||
vt_seen: Arc::default(),
|
||||
@@ -1128,8 +1149,14 @@ impl<P: ApiPlatform> GraphicsDevice<P> {
|
||||
device,
|
||||
cursors,
|
||||
ending: Arc::downgrade(&control),
|
||||
#[cfg(any(test, feature = "testkit"))]
|
||||
control,
|
||||
platform_ref: Arc::clone(&platform),
|
||||
features_atom,
|
||||
features_16k_atom,
|
||||
deferred_budget_atom,
|
||||
base_features,
|
||||
in_place_features: in_place,
|
||||
own_memory_budget: own_memory,
|
||||
#[cfg(test)]
|
||||
shown,
|
||||
reads,
|
||||
@@ -1139,6 +1166,45 @@ impl<P: ApiPlatform> GraphicsDevice<P> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Installs the guest RAM map after device creation (for hosted ARM64 translators whose
|
||||
/// inner physical layout is established during guest boot, before the graphics driver
|
||||
/// handshakes). Enables zero-copy `RGFX_FEATURE_SURFACE_PAGES` and page-backed buffers.
|
||||
pub fn set_memory_map(&self, map: MemoryMap) -> Result<(), Error> {
|
||||
entry::run(|_| {
|
||||
if map.ranges().is_empty() {
|
||||
return Err(Error::InvalidArgument);
|
||||
}
|
||||
let lease: GuestMemoryLease = Arc::from(self.platform_ref.guest_memory(&map));
|
||||
let memory = CoreMemoryMap::new(Arc::clone(&self.platform_ref), &map.to_core())
|
||||
.ok_or(Error::InvalidArgument)?;
|
||||
let mut decoder = self.control.decoder();
|
||||
decoder.set_guest_memory(memory, lease);
|
||||
decoder.start_views_age();
|
||||
let pages_features = if decoder.surface_pages_available() {
|
||||
self.in_place_features
|
||||
| u64::from(RGFX_FEATURE_SURFACE_CACHE)
|
||||
| u64::from(RGFX_FEATURE_SURFACE_DEFERRED)
|
||||
| RGFX_FEATURE_SURFACE_DEFERRED_CARRY
|
||||
| cache_every(P::SURFACE_SHAPES, self.pool.is_some())
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let (features, features_16k) =
|
||||
if pages_features != 0 && decoder.surface_pages_need_16k() {
|
||||
(self.base_features | RGFX_FEATURE_PAGES_16K, pages_features)
|
||||
} else {
|
||||
(self.base_features | pages_features, 0)
|
||||
};
|
||||
let offerable = features | features_16k;
|
||||
let deferred = deferred_budget(offerable, self.own_memory_budget);
|
||||
decoder.set_deferred_budget(deferred);
|
||||
self.deferred_budget_atom.store(deferred, Ordering::Release);
|
||||
self.features_16k_atom.store(features_16k, Ordering::Release);
|
||||
self.features_atom.store(features, Ordering::Release);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// The host mapped the pool's piece at `physical_address` it was asked to add
|
||||
/// ([`GraphicsCallbacks::pool_add`]): the guest's address space has it from now on. Any
|
||||
/// thread, the host's lock held or not; waits for nothing and calls back never.
|
||||
@@ -4326,15 +4392,13 @@ impl<P: ApiPlatform> GraphicsControl<P> {
|
||||
struct CallbackHost<P: ApiPlatform> {
|
||||
/// The host's callbacks: the device raises its interrupt through them.
|
||||
callbacks: GraphicsCallbacks,
|
||||
/// The `RGFX_FEATURE_*` the decoder carries out, fixed at the device's make: the guest reads
|
||||
/// them on a vCPU, which takes no lock of the decoder's.
|
||||
features: u64,
|
||||
/// Those it carries out only for a guest that takes `RGFX_FEATURE_PAGES_16K`, also fixed at
|
||||
/// the make: the guest RAM's on a host of 16 KiB pages, else none.
|
||||
features_16k: u64,
|
||||
/// The deferred blocks' budget ([`deferred_budget`]), read once at the device's make, so the
|
||||
/// kext's one read holds.
|
||||
deferred_budget: u64,
|
||||
/// The `RGFX_FEATURE_*` the decoder carries out: the guest reads them on a vCPU without
|
||||
/// taking a decoder lock; updated atomically if hosted guest RAM is installed before handshake.
|
||||
features: Arc<AtomicU64>,
|
||||
/// Those it carries out only for a guest that takes `RGFX_FEATURE_PAGES_16K`.
|
||||
features_16k: Arc<AtomicU64>,
|
||||
/// The deferred blocks' budget ([`deferred_budget`]).
|
||||
deferred_budget: Arc<AtomicU64>,
|
||||
/// The stage-3 decoder, fed the stage-3 messages of ring 0 and of the queues' rings.
|
||||
control: Arc<GraphicsControl<P>>,
|
||||
/// The host's side of VideoToolbox's paravirtual messages ([`paravirt`]), over the decoders
|
||||
@@ -4480,15 +4544,15 @@ impl<P: ApiPlatform> Host for CallbackHost<P> {
|
||||
}
|
||||
|
||||
fn features(&self) -> u64 {
|
||||
self.features
|
||||
self.features.load(Ordering::Acquire)
|
||||
}
|
||||
|
||||
fn features_with_16k_pages(&self) -> u64 {
|
||||
self.features_16k
|
||||
self.features_16k.load(Ordering::Acquire)
|
||||
}
|
||||
|
||||
fn deferred_budget(&self) -> u64 {
|
||||
self.deferred_budget
|
||||
self.deferred_budget.load(Ordering::Acquire)
|
||||
}
|
||||
|
||||
fn surface_pages(
|
||||
|
||||
@@ -13729,7 +13729,7 @@ fn the_no_pool_line_names_why_the_device_offers_no_pool() {
|
||||
);
|
||||
assert_eq!(
|
||||
no_pool(true, true, false),
|
||||
Some("a Windows host offers one to an x86-64 guest alone")
|
||||
Some("the Shared pool is disabled for ARM64 guests on this Windows host")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13878,8 +13878,13 @@ fn a_guest_s_pool_block_is_taken_held_by_its_heap_and_given_back() {
|
||||
assert_eq!(device.decoder_object_count(), 0);
|
||||
}
|
||||
|
||||
/// A guest of either architecture is offered the pool on a Linux or macOS host, an x86-64 guest on
|
||||
/// a Windows host too, and a guest of a device with none is offered none
|
||||
/// The test runner supplies the expected state in a separate process for each setting.
|
||||
fn expect_windows_arm64_pool() -> bool {
|
||||
cfg!(windows)
|
||||
&& std::env::var_os("REIMS_VGPU_TEST_EXPECT_ARM64_POOL").is_some_and(|value| value == "1")
|
||||
}
|
||||
|
||||
/// Hosts with a pool offer both pool features. On Windows, ARM64 guests require an opt-in.
|
||||
#[test]
|
||||
fn a_guest_of_either_architecture_is_offered_the_pool() {
|
||||
let pool_of = |guest_arch: GuestArch| {
|
||||
@@ -13900,11 +13905,16 @@ fn a_guest_of_either_architecture_is_offered_the_pool() {
|
||||
let offered = u64::from(device.mmio_read(RGFX_REG_FEATURES_HI.into())) << 32;
|
||||
(
|
||||
offered & RGFX_FEATURE_POOL != 0,
|
||||
offered & RGFX_FEATURE_POOL_ADDRESSES != 0,
|
||||
device.control.shared_pool.is_some(),
|
||||
)
|
||||
};
|
||||
assert_eq!(pool_of(GuestArch::Arm64), (!cfg!(windows), !cfg!(windows)));
|
||||
assert_eq!(pool_of(GuestArch::X86_64), (true, true));
|
||||
let arm64_pool_expected = !cfg!(windows) || expect_windows_arm64_pool();
|
||||
assert_eq!(
|
||||
pool_of(GuestArch::Arm64),
|
||||
(arm64_pool_expected, arm64_pool_expected, arm64_pool_expected)
|
||||
);
|
||||
assert_eq!(pool_of(GuestArch::X86_64), (true, true, true));
|
||||
let raised = Arc::new(AtomicU32::new(0));
|
||||
assert!(headless(&raised).control.shared_pool.is_none());
|
||||
}
|
||||
@@ -14045,7 +14055,7 @@ fn managed_at_copy_is_offered_only_on_a_unified_gpu_of_rt_with_the_pool() {
|
||||
assert_eq!(offered & RGFX_FEATURE_MANAGED_AT_COPY, 0);
|
||||
}
|
||||
|
||||
/// An x86-64 guest that took `POOL_ADDRESSES` beside `POOL` is answered each block's GPU address:
|
||||
/// A guest that took `POOL_ADDRESSES` beside `POOL` is answered each block's GPU address:
|
||||
/// on a platform whose pool blocks have none, the host's picks from 2^45 up, each block's span
|
||||
/// its pages and a guard page on the 32 KiB granule; a heap over the block at that address is
|
||||
/// pinned there
|
||||
@@ -14067,7 +14077,11 @@ fn a_guest_that_took_pool_addresses_is_answered_each_block_s_gpu_address() {
|
||||
physical_address: BASE,
|
||||
physical_length: 4 << 30,
|
||||
}),
|
||||
guest_arch: GuestArch::X86_64,
|
||||
guest_arch: if expect_windows_arm64_pool() {
|
||||
GuestArch::Arm64
|
||||
} else {
|
||||
GuestArch::X86_64
|
||||
},
|
||||
..GraphicsConfig::default()
|
||||
};
|
||||
let device = GraphicsDevice::with_platform(Arc::new(FakePlatform::new()), config).unwrap();
|
||||
|
||||
@@ -212,7 +212,8 @@ std::string rgfxFamilyNameOf(const char *name);
|
||||
std::string rgfxVendorNameOf(const char *name);
|
||||
|
||||
/// The `name` an x86-64 guest's Metal device answers where the host names its GPU `hostName`
|
||||
/// (the device info's name, NUL-terminated): rgfxX86Name (guest/kext/src/RgfxDeviceName.hpp). It is
|
||||
/// (the device info's name, NUL-terminated): the kext's x86-64 name (rgfxX86Name,
|
||||
/// guest/kext/src/RgfxDeviceName.hpp), which the kext states as the GPU's `model` too. That is
|
||||
/// "AMD - " and the host's name with the vendor words "Intel" and "NVIDIA" taken out, in any
|
||||
/// case, each with a mark directly after it ("(R)", "(TM)", "®", "™") and then one space, on
|
||||
/// every type of GPU (integrated, discrete, virtual, CPU, other): "AMD - Iris(R) Xe Graphics
|
||||
|
||||
@@ -1519,7 +1519,7 @@ static NSString *rgfxHostNameOf(const RgfxCaps &caps)
|
||||
return @"reims-graphics";
|
||||
}
|
||||
|
||||
// On an x86-64 guest the Metal compatibility name (rgfxMetalNameOf): "AMD - " and the
|
||||
// On an x86-64 guest the x86-64 name, the kext's `model` there (rgfxMetalNameOf): "AMD - " and the
|
||||
// host's name without "Intel" and "NVIDIA", on every type of GPU: "AMD - GeForce RTX 3090",
|
||||
// "AMD - Iris(R) Xe Graphics (RPL-P)". On an arm64 guest the host's name.
|
||||
- (NSString *)name
|
||||
|
||||
@@ -551,7 +551,9 @@ bool RgfxAccelerator::start(IOService *provider)
|
||||
setProperty("VRAM,totalMB", memory.vramMB, 32);
|
||||
}
|
||||
}
|
||||
// The host GPU's name as the PCI `model` that System Information shows as its Chipset Model.
|
||||
// The GPU's name, as a Mac's GPU states it (RgfxDeviceName.hpp): `model` on the PCI device,
|
||||
// which System Information shows as its Chipset Model. On an arm64 guest a host that gave no
|
||||
// name has none stated.
|
||||
{
|
||||
uint8_t model[kRgfxDeviceModelMax];
|
||||
const size_t length = readDeviceModel(model);
|
||||
|
||||
@@ -432,7 +432,7 @@ public:
|
||||
// false where the region is not mapped.
|
||||
bool readMemorySize(RgfxMemorySize *out) const;
|
||||
// The GPU's `model` bytes, from the host's device name (RgfxDeviceName.hpp): how many, 0
|
||||
// where the region is not mapped or the host gave no name.
|
||||
// where the region is not mapped or, on an arm64 guest, the host gave no name.
|
||||
size_t readDeviceModel(uint8_t (&out)[kRgfxDeviceModelMax]) const;
|
||||
|
||||
// Shared events' ports (RgfxSharedEventUserClient.hpp): the client of ours that holds context
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// RgfxDeviceName: the PCI model the kext states to the guest and the compatibility name the
|
||||
// x86-64 Metal bundle answers. Both use the host's name from RgfxDeviceInfo. The PCI model
|
||||
// keeps the host's name on both architectures. The x86-64 Metal name adds "AMD - " and drops
|
||||
// the vendor words "Intel" and "NVIDIA" (rgfxX86Name, used by the bundle's rgfxMetalNameOf).
|
||||
// RgfxDeviceName: the GPU name the kext states to the guest, from the host's device name in the
|
||||
// device info (RgfxDeviceInfo's name_len and name, written at RGFX_DEVICE_INFO_OFFSET when the
|
||||
// device is made). On an arm64 guest it is the host's name whole. On an x86-64 guest it is the
|
||||
// x86-64 name (rgfxX86Name): "AMD - " and the host's name without the vendor words "Intel" and
|
||||
// "NVIDIA", on every host GPU. The bundle's Metal device answers the same name as its `name`
|
||||
// on either guest (rgfxMetalNameOf, guest/bundle/src/RgfxCaps.hpp).
|
||||
//
|
||||
// A Mac's GPU states its name as its IOPCIDevice's `model`, an OSData of the name's bytes, which
|
||||
// System Information shows as the GPU's "Chipset Model"; without one it shows "Graphics" and the
|
||||
@@ -9,8 +11,9 @@
|
||||
// 630's `model` is its 22 bytes and a NUL, the AMD Radeon Pro 5300M's its 20 bytes with none,
|
||||
// and System Information names both. So the kext sets `model` as the Intel's is: the name's
|
||||
// bytes, then a NUL. The host's name is its first name_len bytes (at most RGFX_DEVICE_NAME_LEN),
|
||||
// cut at a NUL among them. The kext publishes no model when the host supplies no name
|
||||
// (name_len 0 or a NUL first).
|
||||
// cut at a NUL among them. On an arm64 guest, a host that gave no name (name_len 0, or a NUL
|
||||
// first) has none stated; on an x86-64 guest it has "AMD - reims-graphics", as the bundle
|
||||
// answers.
|
||||
//
|
||||
// Why the x86-64 name holds no vendor word: WindowServer's compositor (SkyLight, read from its
|
||||
// code) takes a Metal device whose name holds "Intel" for an Intel GPU, and then scales a
|
||||
@@ -22,8 +25,9 @@
|
||||
// macOS 26.7.2 and 15.8.2. The compositor's other test, a name holding "NVIDIA", is the other
|
||||
// vendor word: without either, every host takes the path of an AMD GPU's Mac.
|
||||
//
|
||||
// Header-only and free of the kernel's headers, so the native tests and Metal bundle can
|
||||
// build it too.
|
||||
// Header-only and free of the kernel's headers, so its native tests (tests/device_name_test.cpp,
|
||||
// built for the x86-64 kext's rules and, as device_name_arm64_test, the arm64e kext's) build it
|
||||
// as the kext does, and the bundle builds rgfxX86Name as the kext does.
|
||||
//
|
||||
// Our own code; it depends only on the committed wire header.
|
||||
#ifndef RGFX_DEVICE_NAME_HPP_
|
||||
@@ -34,6 +38,10 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef RGFX_GUEST_ARM64
|
||||
#define RGFX_GUEST_ARM64 0
|
||||
#endif
|
||||
|
||||
// The bytes of RgfxDeviceInfo the kext reads for the name: from name_len to the name's end.
|
||||
static constexpr uint64_t kRgfxDeviceNameFirst = offsetof(RgfxDeviceInfo, name_len);
|
||||
static constexpr uint64_t kRgfxDeviceNameEnd = offsetof(RgfxDeviceInfo, name) + RGFX_DEVICE_NAME_LEN;
|
||||
@@ -46,8 +54,8 @@ static constexpr size_t kRgfxX86NamePrefixLen = sizeof(kRgfxX86NamePrefix) - 1;
|
||||
// The most bytes of an x86-64 name: the prefix, a whole name field and a NUL.
|
||||
static constexpr size_t kRgfxX86NameMax = kRgfxX86NamePrefixLen + RGFX_DEVICE_NAME_LEN + 1;
|
||||
|
||||
// The most bytes of `model`: the full name field and a NUL.
|
||||
static constexpr size_t kRgfxDeviceModelMax = RGFX_DEVICE_NAME_LEN + 1;
|
||||
// The most bytes of `model`: the x86-64 name's, the longer of the two guests'.
|
||||
static constexpr size_t kRgfxDeviceModelMax = kRgfxX86NameMax;
|
||||
|
||||
// The vendor words the x86-64 name holds none of, and the marks it takes out with one directly
|
||||
// before them: "(R)" and "(TM)", and the UTF-8 of "®" and "™". In lower case: each matches in
|
||||
@@ -130,7 +138,7 @@ inline size_t rgfxX86Name(const uint8_t *name, size_t length, char (&out)[kRgfxX
|
||||
return kRgfxX86NamePrefixLen + n;
|
||||
}
|
||||
|
||||
// `model`'s bytes into `out`, from a name_len and the name field's
|
||||
// `model`'s bytes on an arm64 guest into `out`, from a name_len and the name field's
|
||||
// RGFX_DEVICE_NAME_LEN bytes: the host's name and a NUL. How many, its NUL counted, or 0 when
|
||||
// the host gave no name.
|
||||
inline size_t rgfxDeviceModel(uint32_t nameLen, const uint8_t *name, uint8_t (&out)[kRgfxDeviceModelMax])
|
||||
@@ -147,14 +155,23 @@ inline size_t rgfxDeviceModel(uint32_t nameLen, const uint8_t *name, uint8_t (&o
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
// `model`'s bytes out of the device info span.
|
||||
// `model`'s bytes on an x86-64 guest into `out`, from a name_len and the name field's
|
||||
// RGFX_DEVICE_NAME_LEN bytes: the x86-64 name (rgfxX86Name) and a NUL. How many, its NUL
|
||||
// counted; never 0.
|
||||
inline size_t rgfxDeviceModelX86(uint32_t nameLen, const uint8_t *name, uint8_t (&out)[kRgfxDeviceModelMax])
|
||||
{
|
||||
return rgfxX86Name(name, nameLen, reinterpret_cast<char (&)[kRgfxX86NameMax]>(out)) + 1;
|
||||
}
|
||||
|
||||
// `model`'s bytes out of the device info's bytes from kRgfxDeviceNameFirst to kRgfxDeviceNameEnd,
|
||||
// as the kext's guest takes them (RGFX_GUEST_ARM64).
|
||||
inline size_t rgfxDeviceModelFrom(const uint8_t *span, uint8_t (&out)[kRgfxDeviceModelMax])
|
||||
{
|
||||
uint32_t nameLen = 0;
|
||||
for (unsigned i = 0; i < sizeof(nameLen); i++)
|
||||
nameLen |= static_cast<uint32_t>(span[i]) << (8 * i);
|
||||
const uint8_t *name = span + (offsetof(RgfxDeviceInfo, name) - kRgfxDeviceNameFirst);
|
||||
return rgfxDeviceModel(nameLen, name, out);
|
||||
return RGFX_GUEST_ARM64 ? rgfxDeviceModel(nameLen, name, out) : rgfxDeviceModelX86(nameLen, name, out);
|
||||
}
|
||||
|
||||
#endif // RGFX_DEVICE_NAME_HPP_
|
||||
@@ -1,5 +1,10 @@
|
||||
// The native test of the PCI model bytes the kext publishes on either architecture.
|
||||
// The bytes come from the host name, bounded by its length, field size, and any NUL.
|
||||
// The native test of RgfxDeviceName.hpp: the `model` bytes the kext states on the PCI device, from
|
||||
// the host's device name, as each guest's kext takes it (built twice: device_name_test for the
|
||||
// x86-64 kext, device_name_arm64_test with RGFX_GUEST_ARM64 for the arm64e kext). Both cut the
|
||||
// host's name at its length, at the field and at a NUL, and end it with a NUL, as an Intel Mac's
|
||||
// Intel UHD Graphics 630 states its own (measured, macOS 26.7.1). The arm64e kext states the
|
||||
// host's name whole, and none for no name. The x86-64 kext states the x86-64 name, "AMD - " and
|
||||
// the host's name without "Intel" and "NVIDIA", and "AMD - reims-graphics" for no name.
|
||||
#include "RgfxDeviceName.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -38,18 +43,40 @@ bool is(const uint8_t *model, size_t n, const char *want)
|
||||
return n == len + 1 && !std::memcmp(model, want, len) && model[len] == 0;
|
||||
}
|
||||
|
||||
#if !RGFX_GUEST_ARM64
|
||||
// Whether `s` holds "intel" or "nvidia" in any ASCII case.
|
||||
bool holdsVendorWord(const uint8_t *s, size_t n)
|
||||
{
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
for (const char *vendor : kRgfxVendorWords) {
|
||||
if (rgfxMatchAnyCase(s + i, n - i, vendor))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// The x86-64 name of `host` through the device info.
|
||||
bool x86NameIs(const char *host, const char *want)
|
||||
{
|
||||
uint8_t model[kRgfxDeviceModelMax];
|
||||
const size_t n = fromDeviceInfo(static_cast<uint32_t>(std::strlen(host)), host, std::strlen(host), model);
|
||||
return is(model, n, want) && !holdsVendorWord(model, n);
|
||||
}
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
uint8_t model[kRgfxDeviceModelMax];
|
||||
const char intel[] = "Intel UHD Graphics 630";
|
||||
const char nvidia[] = "NVIDIA GeForce RTX 5090";
|
||||
const char nvidia[] = "NVIDIA GeForce RTX 5080 Laptop GPU";
|
||||
uint8_t full[RGFX_DEVICE_NAME_LEN];
|
||||
for (size_t i = 0; i < sizeof(full); i++)
|
||||
full[i] = static_cast<uint8_t>('A' + i % 26);
|
||||
size_t n = 0;
|
||||
|
||||
#if RGFX_GUEST_ARM64
|
||||
// A host GPU's name: its bytes and a NUL, as the Intel GPU's 23 bytes of `model`.
|
||||
n = fromDeviceInfo(22, intel, 22, model);
|
||||
check(n == 23, "a 22-byte name is 23 bytes of model");
|
||||
@@ -81,6 +108,49 @@ int main()
|
||||
// A NUL inside the length: the name up to it.
|
||||
n = fromDeviceInfo(10, "AMD\0Radeon", 10, model);
|
||||
check(is(model, n, "AMD"), "a NUL inside the length ends the name");
|
||||
#else
|
||||
// A host GPU's name: "AMD - " and the name without its vendor words, then a NUL.
|
||||
check(x86NameIs(intel, "AMD - UHD Graphics 630"), "Intel's word and its space go");
|
||||
check(x86NameIs(nvidia, "AMD - GeForce RTX 5080 Laptop GPU"), "NVIDIA's word and its space go");
|
||||
check(x86NameIs("Intel(R) Iris(R) Xe Graphics (RPL-P)", "AMD - Iris(R) Xe Graphics (RPL-P)"),
|
||||
"a mark after the word goes with it; a later one stays");
|
||||
check(x86NameIs("Intel(R) UHD Graphics 630 (CFL GT2)", "AMD - UHD Graphics 630 (CFL GT2)"),
|
||||
"the UHD 630 on Linux");
|
||||
check(x86NameIs("Intel(R) Arc(tm) A770 Graphics (DG2)", "AMD - Arc(tm) A770 Graphics (DG2)"),
|
||||
"the A770");
|
||||
check(x86NameIs("NVIDIA GeForce RTX 3090", "AMD - GeForce RTX 3090"), "the 3090");
|
||||
check(x86NameIs("AMD Radeon 780M Graphics (RADV PHOENIX)",
|
||||
"AMD - AMD Radeon 780M Graphics (RADV PHOENIX)"),
|
||||
"an AMD GPU's name whole");
|
||||
check(x86NameIs("intel(tm) nViDiA\xc2\xae X\xe2\x84\xa2", "AMD - X\xe2\x84\xa2"),
|
||||
"any case and either UTF-8 mark; a mark after no word stays");
|
||||
check(x86NameIs("InNVIDIAtel(R) X", "AMD - X"), "a word that taking one out leaves goes too");
|
||||
check(x86NameIs("Mesa Intel", "AMD - Mesa "), "a word at the end; the space before it stays");
|
||||
|
||||
// No name, or nothing left: "reims-graphics" after the prefix; a NUL first is no name.
|
||||
check(fromDeviceInfo(0, intel, 22, model) == 21 && is(model, 21, "AMD - reims-graphics"),
|
||||
"name_len 0 is AMD - reims-graphics");
|
||||
n = fromDeviceInfo(5, "\0abcd", 5, model);
|
||||
check(is(model, n, "AMD - reims-graphics"), "a NUL first is no name");
|
||||
check(x86NameIs("NVIDIA", "AMD - reims-graphics"), "a name of a vendor word alone leaves none");
|
||||
check(x86NameIs("Intel(R) ", "AMD - reims-graphics"), "a word, its mark and its space leave none");
|
||||
|
||||
// A whole field, 256 bytes and no NUL in it: the prefix, all of them, then a NUL.
|
||||
n = fromDeviceInfo(RGFX_DEVICE_NAME_LEN, full, sizeof(full), model);
|
||||
check(n == kRgfxDeviceModelMax, "a full field is the prefix, 256 bytes and a NUL");
|
||||
check(!std::memcmp(model, "AMD - ", 6) && !std::memcmp(model + 6, full, sizeof(full)) &&
|
||||
model[kRgfxDeviceModelMax - 1] == 0,
|
||||
"every byte of a full field after the prefix, NUL-ended");
|
||||
// A length past the field reads the field alone, never the bytes after it (architecture_name).
|
||||
n = fromDeviceInfo(UINT32_MAX, full, sizeof(full), model);
|
||||
check(n == kRgfxDeviceModelMax && model[kRgfxDeviceModelMax - 1] == 0, "a length past the field is cut to it");
|
||||
|
||||
// A length short of the name: its first bytes; a NUL inside the length ends it.
|
||||
n = fromDeviceInfo(11, nvidia, sizeof(nvidia) - 1, model);
|
||||
check(is(model, n, "AMD - GeFo"), "name_len bounds the name before its words go");
|
||||
n = fromDeviceInfo(10, "AMD\0Radeon", 10, model);
|
||||
check(is(model, n, "AMD - AMD"), "a NUL inside the length ends the name");
|
||||
#endif
|
||||
|
||||
// The span the kext reads holds name_len and the whole field, and lies inside the device info.
|
||||
check(kRgfxDeviceNameFirst == offsetof(RgfxDeviceInfo, name_len), "the span starts at name_len");
|
||||
@@ -88,6 +158,6 @@ int main()
|
||||
"the span ends at the name field's end");
|
||||
check(kRgfxDeviceNameEnd <= sizeof(RgfxDeviceInfo), "the span ends inside the device info");
|
||||
|
||||
std::printf("device_name_test: OK (%d checks)\n", checks);
|
||||
std::printf("device_name_test: OK (%d checks, %s kext)\n", checks, RGFX_GUEST_ARM64 ? "arm64e" : "x86-64");
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -24,7 +24,7 @@ Arch = "arm64e"
|
||||
MinKernel = "23.0.0"
|
||||
MaxKernel = ""
|
||||
Comment = "The reims-graphics display and accelerator"
|
||||
sha256 = "efacd163e0b230f95ce7a43c05c87771e504137ffd6d675a14468cddc7865605"
|
||||
sha256 = "33a086b90fa116b3cf0c6bb826c27f8a55cd83f15522ee794e20186d469bdbc7"
|
||||
|
||||
[[kext]]
|
||||
BundlePath = "RgfxGate.kext"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
# when a source or an output differs from its SHA-256 here (guest/tools/prebuilt.py).
|
||||
# [built] records the local toolchain; every input is in the tree.
|
||||
[built]
|
||||
xcode = "unknown"
|
||||
sdk = "MacOSX.sdk"
|
||||
xcode = "Xcode 27.2 Build version 27B52"
|
||||
sdk = "MacOSX27.2.sdk"
|
||||
clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
|
||||
[sources]
|
||||
@@ -27,7 +27,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/bundle/src/RgfxBuffer.h" = "4b54841a30b0559c424b8aed06fcd5edd7c172cda1bf9fd5c892e30dc066ec7d"
|
||||
"guest/bundle/src/RgfxBuffer.mm" = "360a494bb58668c4c66ce468b8ac39a10ccdad16e97a538ef48a6c8fa7cadbec"
|
||||
"guest/bundle/src/RgfxCaps.cpp" = "d6020aeff1adcef0b74e9bbc51dea8d849f88355e019927ee9e8fb96a3007d12"
|
||||
"guest/bundle/src/RgfxCaps.hpp" = "4c8e0dba604b37d4509f54518f24337090fab595c5ed12c15d13298ad195f5dd"
|
||||
"guest/bundle/src/RgfxCaps.hpp" = "7063a6821533fdf44d66b4363aa14ba3a4d5321b2f3df62e2e3ff16ea9764a48"
|
||||
"guest/bundle/src/RgfxClMode.cpp" = "c5d5127ef251d119cb104015676d16a475f615680b83d48eba32c48b76e39a5c"
|
||||
"guest/bundle/src/RgfxClMode.hpp" = "138c803295021645c2854f3e9cb34dac96d485719d5447151ff9168c698e7a1a"
|
||||
"guest/bundle/src/RgfxCommandObjects.h" = "cd504d3df8e3560758a926d31742e052bdda77e76c2c2c23e2dc6ae07346b9bc"
|
||||
@@ -111,7 +111,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/bundle/src/RgfxMetalDevice+Unsupported.mm" = "a424349b2a969a53609b34ae3f4b72cc2e2c9378605ba780520eeb22643c535c"
|
||||
"guest/bundle/src/RgfxMetalDevice+Video.mm" = "aa53c5a15243b11155c9342ab1c7867ff5e19ced9272471f9ea76e95db01d9af"
|
||||
"guest/bundle/src/RgfxMetalDevice.h" = "92708ff70a7693edebc6402a8c68fa16ed1982c27d885a74ac56f6a92b4a10a9"
|
||||
"guest/bundle/src/RgfxMetalDevice.mm" = "f1fa5b4c56b61766dd0f89f63be3eeeef51d927b51eef0065c7c79f3de50bcdc"
|
||||
"guest/bundle/src/RgfxMetalDevice.mm" = "420bd3f1c54f87eb33d27e62427b4b1c967af8976193dd8f01b02794839e3fe8"
|
||||
"guest/bundle/src/RgfxMetalError.h" = "e4440b3c0d0617ad118f16aa56fc9cfb0e7ebbf0ef2d3f8e16b27df9fd1f9803"
|
||||
"guest/bundle/src/RgfxMetalPrivate.h" = "18196f21ce0808a37c8d8913fab72e16e032c7c73064b6a81618bb9f06a478f2"
|
||||
"guest/bundle/src/RgfxMetallibWriter.cpp" = "a9f0e9a4a2ef80729470051130d201806f59d0c4d1803129a3662e4afc389f13"
|
||||
@@ -333,8 +333,8 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/kext/src/ReimsGraphicsMobile.cpp" = "b73a2e5f5b061453817c5d0b18211a2d0782f5971f02d90b0fb7f930365086de"
|
||||
"guest/kext/src/ReimsGraphicsPointer.cpp" = "255f049c3a5244a148d80fd25ef3388001ba180c58901e3620451c3158908f0e"
|
||||
"guest/kext/src/RgfxAccelTypes.hpp" = "c65e032a617cda503b2534c68bec87947d7856accda676f35a1affa145998259"
|
||||
"guest/kext/src/RgfxAccelerator.cpp" = "e05bf13fb97b0e2fbc133dc83c451dd6b063323c8f2b26d67e82b8de9912ecd4"
|
||||
"guest/kext/src/RgfxAccelerator.hpp" = "148d63554b5a5eaaaf280651d0f493b3741dbaf444808554f88af0e6bc670ce8"
|
||||
"guest/kext/src/RgfxAccelerator.cpp" = "319e1148d2644e922ed2c30859019392764c9e64328594c1f593c5c4fe890030"
|
||||
"guest/kext/src/RgfxAccelerator.hpp" = "2711b9225040feae3e45bb8057a60b30f5d17d83d953eadc82c2db91e83e28c5"
|
||||
"guest/kext/src/RgfxAcceleratorContexts.cpp" = "77f39e6d4750dfb0f1ff5a614b9d419362f159a8eac48b18673181a01d3f0451"
|
||||
"guest/kext/src/RgfxAcceleratorLocks.cpp" = "171e708b5fb87abbf39423aa08fb0343ca8dd1777f47e125288a296940667124"
|
||||
"guest/kext/src/RgfxAcceleratorSurfaces.cpp" = "54c72029acb78f19cc41e80ab1e646b1bb402af45ec0f073dc07eb2236f5baa0"
|
||||
@@ -358,7 +358,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/kext/src/RgfxDeferredAnswers.hpp" = "b7b62b567e38da8ce27d89aa47b1001f56f8f7afeda0def2b550b1f7ad9b18c6"
|
||||
"guest/kext/src/RgfxDeviceControl.cpp" = "53c7c6a722ef4d7edeb5756eb04091d4a56f397dc5aef83c3637b1c0f129b934"
|
||||
"guest/kext/src/RgfxDeviceControl.hpp" = "c1357b80ee2141e1e2fd57213f3c9361cb497b8c6490a0b6aff8c64649be48c6"
|
||||
"guest/kext/src/RgfxDeviceName.hpp" = "7085045ea0c9ca3215e58ea43f0a23309a9ba8145e9c2d5ede541093a293f9c1"
|
||||
"guest/kext/src/RgfxDeviceName.hpp" = "b242e0ccdce31c3c454bc3a4d64b13c30e574b25379a0833973dcecbbb1146d3"
|
||||
"guest/kext/src/RgfxDisplayBounds.hpp" = "c1e8fe52f89bcb25ee178f4e0ea4ac53396109fd934348408692d21d1931ecf7"
|
||||
"guest/kext/src/RgfxDisplayIdentity.hpp" = "ce4328b8e255f942aea0f0dc097e2e80eb4a8d7e126ea0f342fd116252357731"
|
||||
"guest/kext/src/RgfxDisplayModes.hpp" = "62026ac6fa3febe5ce403fbfe026760f0434b70cc47e5d74c191fa5509ae12cd"
|
||||
@@ -464,7 +464,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"Graft-arm64e.kext/Contents/Info.plist" = "fa8533d5ec06430f3ede502e6f9e739e9c8c3f6b6909c46d854effe6028cbc7f"
|
||||
"Graft-arm64e.kext/Contents/MacOS/Graft" = "2f405e84ddd1414b6ac32e813a4369a6d4681d9c6e7331b933bb719761b1a31a"
|
||||
"ReimsGraphics.kext/Contents/Info.plist" = "9683153587659c4bd4d5c52167eff1f3d2ae51dae575f60c15a27d89240f46c5"
|
||||
"ReimsGraphics.kext/Contents/MacOS/ReimsGraphics" = "efacd163e0b230f95ce7a43c05c87771e504137ffd6d675a14468cddc7865605"
|
||||
"ReimsGraphics.kext/Contents/MacOS/ReimsGraphics" = "33a086b90fa116b3cf0c6bb826c27f8a55cd83f15522ee794e20186d469bdbc7"
|
||||
"RgfxGate.kext/Contents/Info.plist" = "7b78d915fab4d36e6cdb3f40aa2a6c1e7224f30158ee879af23451d2e6969992"
|
||||
"RgfxGate.kext/Contents/MacOS/RgfxGate" = "deb1696453b7d754547abc24e3fa30e5affea059bd19d2d732bee243054a300e"
|
||||
"set.toml" = "a0be05b8801df322a6d2276bb41821682c473157227fa29c7aef46e5ff171868"
|
||||
"set.toml" = "a4da2409f25dd7bf12260de752c38c474b60d4b2d993810a44de0f4b07cb6dfd"
|
||||
Binary file not shown.
@@ -24,7 +24,7 @@ Arch = "x86_64"
|
||||
MinKernel = "20.0.0"
|
||||
MaxKernel = ""
|
||||
Comment = "The reims-graphics display, accelerator and device control"
|
||||
sha256 = "c8b23bcde87d6d0415d09cbdf47ad444afe0c0ea2f51dca1a4583be8bea75f6e"
|
||||
sha256 = "d0277f202173dcecc35bce8aa2ec84cd9d53759a0fd34c26e913bcd65a191d50"
|
||||
|
||||
[[kext]]
|
||||
BundlePath = "RgfxGate.kext"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
# when a source or an output differs from its SHA-256 here (guest/tools/prebuilt.py).
|
||||
# [built] records the local toolchain; every input is in the tree.
|
||||
[built]
|
||||
xcode = "unknown"
|
||||
sdk = "MacOSX.sdk"
|
||||
xcode = "Xcode 27.2 Build version 27B52"
|
||||
sdk = "MacOSX27.2.sdk"
|
||||
clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
|
||||
[sources]
|
||||
@@ -27,7 +27,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/bundle/src/RgfxBuffer.h" = "4b54841a30b0559c424b8aed06fcd5edd7c172cda1bf9fd5c892e30dc066ec7d"
|
||||
"guest/bundle/src/RgfxBuffer.mm" = "360a494bb58668c4c66ce468b8ac39a10ccdad16e97a538ef48a6c8fa7cadbec"
|
||||
"guest/bundle/src/RgfxCaps.cpp" = "d6020aeff1adcef0b74e9bbc51dea8d849f88355e019927ee9e8fb96a3007d12"
|
||||
"guest/bundle/src/RgfxCaps.hpp" = "4c8e0dba604b37d4509f54518f24337090fab595c5ed12c15d13298ad195f5dd"
|
||||
"guest/bundle/src/RgfxCaps.hpp" = "7063a6821533fdf44d66b4363aa14ba3a4d5321b2f3df62e2e3ff16ea9764a48"
|
||||
"guest/bundle/src/RgfxClMode.cpp" = "c5d5127ef251d119cb104015676d16a475f615680b83d48eba32c48b76e39a5c"
|
||||
"guest/bundle/src/RgfxClMode.hpp" = "138c803295021645c2854f3e9cb34dac96d485719d5447151ff9168c698e7a1a"
|
||||
"guest/bundle/src/RgfxCommandObjects.h" = "cd504d3df8e3560758a926d31742e052bdda77e76c2c2c23e2dc6ae07346b9bc"
|
||||
@@ -111,7 +111,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/bundle/src/RgfxMetalDevice+Unsupported.mm" = "a424349b2a969a53609b34ae3f4b72cc2e2c9378605ba780520eeb22643c535c"
|
||||
"guest/bundle/src/RgfxMetalDevice+Video.mm" = "aa53c5a15243b11155c9342ab1c7867ff5e19ced9272471f9ea76e95db01d9af"
|
||||
"guest/bundle/src/RgfxMetalDevice.h" = "92708ff70a7693edebc6402a8c68fa16ed1982c27d885a74ac56f6a92b4a10a9"
|
||||
"guest/bundle/src/RgfxMetalDevice.mm" = "f1fa5b4c56b61766dd0f89f63be3eeeef51d927b51eef0065c7c79f3de50bcdc"
|
||||
"guest/bundle/src/RgfxMetalDevice.mm" = "420bd3f1c54f87eb33d27e62427b4b1c967af8976193dd8f01b02794839e3fe8"
|
||||
"guest/bundle/src/RgfxMetalError.h" = "e4440b3c0d0617ad118f16aa56fc9cfb0e7ebbf0ef2d3f8e16b27df9fd1f9803"
|
||||
"guest/bundle/src/RgfxMetalPrivate.h" = "18196f21ce0808a37c8d8913fab72e16e032c7c73064b6a81618bb9f06a478f2"
|
||||
"guest/bundle/src/RgfxMetallibWriter.cpp" = "a9f0e9a4a2ef80729470051130d201806f59d0c4d1803129a3662e4afc389f13"
|
||||
@@ -333,8 +333,8 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/kext/src/ReimsGraphicsMobile.cpp" = "b73a2e5f5b061453817c5d0b18211a2d0782f5971f02d90b0fb7f930365086de"
|
||||
"guest/kext/src/ReimsGraphicsPointer.cpp" = "255f049c3a5244a148d80fd25ef3388001ba180c58901e3620451c3158908f0e"
|
||||
"guest/kext/src/RgfxAccelTypes.hpp" = "c65e032a617cda503b2534c68bec87947d7856accda676f35a1affa145998259"
|
||||
"guest/kext/src/RgfxAccelerator.cpp" = "e05bf13fb97b0e2fbc133dc83c451dd6b063323c8f2b26d67e82b8de9912ecd4"
|
||||
"guest/kext/src/RgfxAccelerator.hpp" = "148d63554b5a5eaaaf280651d0f493b3741dbaf444808554f88af0e6bc670ce8"
|
||||
"guest/kext/src/RgfxAccelerator.cpp" = "319e1148d2644e922ed2c30859019392764c9e64328594c1f593c5c4fe890030"
|
||||
"guest/kext/src/RgfxAccelerator.hpp" = "2711b9225040feae3e45bb8057a60b30f5d17d83d953eadc82c2db91e83e28c5"
|
||||
"guest/kext/src/RgfxAcceleratorContexts.cpp" = "77f39e6d4750dfb0f1ff5a614b9d419362f159a8eac48b18673181a01d3f0451"
|
||||
"guest/kext/src/RgfxAcceleratorLocks.cpp" = "171e708b5fb87abbf39423aa08fb0343ca8dd1777f47e125288a296940667124"
|
||||
"guest/kext/src/RgfxAcceleratorSurfaces.cpp" = "54c72029acb78f19cc41e80ab1e646b1bb402af45ec0f073dc07eb2236f5baa0"
|
||||
@@ -358,7 +358,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"guest/kext/src/RgfxDeferredAnswers.hpp" = "b7b62b567e38da8ce27d89aa47b1001f56f8f7afeda0def2b550b1f7ad9b18c6"
|
||||
"guest/kext/src/RgfxDeviceControl.cpp" = "53c7c6a722ef4d7edeb5756eb04091d4a56f397dc5aef83c3637b1c0f129b934"
|
||||
"guest/kext/src/RgfxDeviceControl.hpp" = "c1357b80ee2141e1e2fd57213f3c9361cb497b8c6490a0b6aff8c64649be48c6"
|
||||
"guest/kext/src/RgfxDeviceName.hpp" = "7085045ea0c9ca3215e58ea43f0a23309a9ba8145e9c2d5ede541093a293f9c1"
|
||||
"guest/kext/src/RgfxDeviceName.hpp" = "b242e0ccdce31c3c454bc3a4d64b13c30e574b25379a0833973dcecbbb1146d3"
|
||||
"guest/kext/src/RgfxDisplayBounds.hpp" = "c1e8fe52f89bcb25ee178f4e0ea4ac53396109fd934348408692d21d1931ecf7"
|
||||
"guest/kext/src/RgfxDisplayIdentity.hpp" = "ce4328b8e255f942aea0f0dc097e2e80eb4a8d7e126ea0f342fd116252357731"
|
||||
"guest/kext/src/RgfxDisplayModes.hpp" = "62026ac6fa3febe5ce403fbfe026760f0434b70cc47e5d74c191fa5509ae12cd"
|
||||
@@ -464,7 +464,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)"
|
||||
"Graft.kext/Contents/Info.plist" = "fa8533d5ec06430f3ede502e6f9e739e9c8c3f6b6909c46d854effe6028cbc7f"
|
||||
"Graft.kext/Contents/MacOS/Graft" = "04a1d44c0c80c20a71f3a662c46b56a1732b8134f095fb2ac57ec790f72baf72"
|
||||
"ReimsGraphics.kext/Contents/Info.plist" = "ae0dafd3b6c36c24d1c92467d8203d76360eb6e4f6ad5c496167a21033b2c209"
|
||||
"ReimsGraphics.kext/Contents/MacOS/ReimsGraphics" = "c8b23bcde87d6d0415d09cbdf47ad444afe0c0ea2f51dca1a4583be8bea75f6e"
|
||||
"ReimsGraphics.kext/Contents/MacOS/ReimsGraphics" = "d0277f202173dcecc35bce8aa2ec84cd9d53759a0fd34c26e913bcd65a191d50"
|
||||
"RgfxGate.kext/Contents/Info.plist" = "7b78d915fab4d36e6cdb3f40aa2a6c1e7224f30158ee879af23451d2e6969992"
|
||||
"RgfxGate.kext/Contents/MacOS/RgfxGate" = "90d8327eb2243b820dd90ce29e4be79a80516f3e6341137b76e9b575ea3d10eb"
|
||||
"set.toml" = "dcdad1148a389c4be577c0641f3f3942031df313983e09f5a445cb783a7e6a42"
|
||||
"set.toml" = "49182c19c3d961b251901e19a09016df684f1f102527a0d3274697eaaf3dbab5"
|
||||
@@ -1 +0,0 @@
|
||||
patches/*.patch -text
|
||||
@@ -1,200 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate acts) or agreed
|
||||
to in writing, shall any Contributor be liable to You for damages,
|
||||
including any direct, indirect, special, incidental, or consequential
|
||||
damages of any character arising as a result of this License or out of
|
||||
the use or inability to use the Work (including but not limited to damages
|
||||
for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2026 Reims-Go contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,30 +0,0 @@
|
||||
# Third-Party Notices
|
||||
|
||||
The build and packaging scripts were migrated from Reims-Go and are licensed
|
||||
under the Apache License, Version 2.0 (see `LICENSE` alongside the scripts).
|
||||
Local compatibility patches under `patches/` use terms compatible with their
|
||||
target upstream projects (see `patches/LICENSE`).
|
||||
|
||||
The portable runtime bundle (`reims-runtime-win-x64-<commit>.tar.zst`) contains
|
||||
precompiled binaries built from the following upstream open-source projects.
|
||||
Each runtime release ships the matching source package, `NOTICE.md`, and
|
||||
`licenses/`:
|
||||
|
||||
1. **reims-vgpu / reims-ctl**
|
||||
- Upstream: https://github.com/steelbrain/reims-vgpu
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
2. **metal2vulkan / metal2vulkan-runtime**
|
||||
- Upstream: https://github.com/steelbrain/metal2vulkan
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
3. **reims-util**
|
||||
- Upstream: https://github.com/steelbrain/reims-util
|
||||
- License: `GPL-2.0-or-later OR LGPL-3.0-or-later`
|
||||
4. **QEMU (qemu-reims-vgpu fork)**
|
||||
- Upstream: https://github.com/steelbrain/qemu-reims-vgpu
|
||||
- License: `GPL-2.0-only` / `GPL-2.0-or-later` (and component licenses in QEMU)
|
||||
5. **MSYS2 CLANG64 runtime libraries, libva, Mesa vaon12**
|
||||
- Upstream: https://github.com/msys2/MINGW-packages
|
||||
- License: Respective open-source licenses of each packaged DLL (bundled under `licenses/msys2/` in the runtime archive)
|
||||
|
||||
No Apple proprietary files, macOS installers, recovery images, or SMC keys are
|
||||
included in this repository or in any runtime bundle.
|
||||
@@ -1,11 +0,0 @@
|
||||
# Licensing for `patches/`
|
||||
|
||||
Unlike the rest of the Reims-Go repository (which is licensed under the Apache
|
||||
License, Version 2.0), patch files in this directory are intended to be applied
|
||||
to and contributed back to their respective upstream repositories. To maintain
|
||||
strict license compatibility with each target codebase:
|
||||
|
||||
- `qemu-*.patch` (targeting `vendor/qemu` / QEMU) are licensed under
|
||||
**GPL-2.0-or-later**.
|
||||
- `reims-*.patch` (targeting `steelbrain/reims-vgpu` or `steelbrain/reims-util`) are
|
||||
dual-licensed under **GPL-2.0-or-later OR LGPL-3.0-or-later**.
|
||||
@@ -1,44 +0,0 @@
|
||||
# 运行时源码与依赖补丁
|
||||
|
||||
便携运行时由本仓库的 [Preview CI](../../../.github/workflows/runtime-preview.yml) 构建,使用以下源码分支。
|
||||
|
||||
| 组件 | 源码 | 维护范围 |
|
||||
| :--- | :--- | :--- |
|
||||
| Reims vGPU | [`reims-go/reims-vgpu`](https://github.com/reims-go/reims-vgpu/tree/intel-vm-suspend) | GPU 挂起重放、窗口和 CLI 兼容性修复 |
|
||||
| QEMU | [`reims-go/qemu-reims-vgpu`](https://github.com/reims-go/qemu-reims-vgpu/tree/intel-vm-suspend) | Windows WHPX、文件迁移和设备状态保存恢复 |
|
||||
| metal2vulkan | [`reims-go/metal2vulkan`](https://github.com/reims-go/metal2vulkan/tree/development) | Vulkan 渲染、附件反馈和 GPU 地址重放 |
|
||||
| reims-util | [`reims-go/reims-util`](https://github.com/reims-go/reims-util/tree/development) | OpenCore 和 macOS 安装介质,包括并发离线下载 |
|
||||
|
||||
Reims vGPU 用 `vendor/qemu` 固定 QEMU 提交,用 `Cargo.toml` 和 `Cargo.lock` 固定 metal2vulkan,用 `crates/reims-ctl/src/reims_util.rs` 固定 reims-util。CI 根据这些固定值检出依赖,在运行时清单和对应源码包中记录四个组件的仓库及实际提交。
|
||||
|
||||
Alpha 编号与挂起兼容判定见 [Alpha 运行时编号与挂起兼容性规范](../versioning.md)。
|
||||
|
||||
## 构建时应用的依赖补丁
|
||||
|
||||
[`series.txt`](series.txt) 目前为空。临时补丁按清单顺序应用,冲突会停止构建。客户端的运行时包格式见[便携运行时规范](https://github.com/Nwflower/Reims-Go/blob/main/docs/portable-runtime-spec.md)。
|
||||
|
||||
---
|
||||
|
||||
## 关注中的上游 PR 与演进
|
||||
|
||||
跟踪仓库:[`steelbrain/reims-vgpu`](https://github.com/steelbrain/reims-vgpu) 与 [`steelbrain/reims-util`](https://github.com/steelbrain/reims-util)。
|
||||
|
||||
| 上游方向 / PR | 价值与影响 | 合入后的跟进动作 |
|
||||
| :--- | :--- | :--- |
|
||||
| `#153` 图形呈现 | Windows NVIDIA MAILBOX/FIFO 首帧优化,改善高帧率与首帧延迟 | 随每日 `alpha` 构建进入冒烟验证 |
|
||||
| `#152` 平台层 | 原生 Windows Vulkan 后端,降低图形适配开销 | 升级运行时并对比帧率与稳定性 |
|
||||
| `#107` 图形内存 | 采样纹理回读就地消费,减少内存拷贝 | 随运行时升级纳入 |
|
||||
| `#123` 窗口体验 | `Ctrl+Alt+Enter` 运行中热切全屏 | 同步界面快捷键提示 |
|
||||
| `#172` 窗口体验 | Windows 拖动窗口动态贴合,消除缩放黑边 | 验证多显示器与高 DPI 缩放 |
|
||||
| `Win → Command` | 自由指针模式下 Windows 键映射 macOS Command | 合入后移除前端相关提示 |
|
||||
| `reims-util` 语言参数 | 支持 `opencore --lang` 并在重建 OpenCore 时保留 `prev-lang:kbd` | 合入后可逐步简化本仓 `internal/opencore` 补丁重写 |
|
||||
|
||||
---
|
||||
|
||||
## 补丁退役检查表
|
||||
|
||||
每日构建会跳过已合入的等价补丁,并在日志中报告。确认后按以下步骤清理。
|
||||
|
||||
1. 删除 `patches/` 下对应的 `.patch` 文件,并同步更新 [`series.txt`](series.txt) 与本文件。
|
||||
2. 等待下一次定时构建,或在 Reims vGPU fork 手动触发 [Preview 工作流](https://github.com/reims-go/reims-vgpu/actions/workflows/runtime-preview.yml)。
|
||||
3. 在真实宿主运行 [`smoke-runtime.ps1`](../scripts/smoke-runtime.ps1) 完成冒烟并人工确认后,将对应 Release 升级为 `stable`。
|
||||
@@ -1,6 +0,0 @@
|
||||
# Patch queue, in the order the patches are applied (see patches/README.md).
|
||||
# One patch per line: <target> <file>.
|
||||
# Runtime components are built from the pinned Reims-Go organization forks.
|
||||
# The queue is reserved for temporary patches to those pinned checkouts.
|
||||
# CI (runtime-preview.yml via scripts/apply-patch-series.ps1) and
|
||||
# scripts/pack-runtime.ps1 both read this file; add or retire patches here.
|
||||
@@ -1,102 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Apply the patch queue in patches/series.txt to the checked-out upstream sources.
|
||||
|
||||
.DESCRIPTION
|
||||
For each patch, in series order:
|
||||
- applies cleanly -> apply it;
|
||||
- already in the tree -> skip it (git apply --reverse --check passes: on a
|
||||
fresh upstream clone this means merged upstream);
|
||||
- neither -> stop with an error. Patches are never edited
|
||||
automatically (AGENTS.md rule 4).
|
||||
|
||||
Writes the result as JSON to -ResultFile:
|
||||
{ "applied": ["a.patch", ...], "merged": ["b.patch", ...], "conflict": "c.patch" | null }
|
||||
so CI can pass the applied list to pack-runtime.ps1 (manifest states only what
|
||||
was really applied, AGENTS.md rule 5) and report merged or conflicting patches.
|
||||
|
||||
.EXAMPLE
|
||||
pwsh -File scripts/apply-patch-series.ps1 -ReimsRepo $env:RUNNER_TEMP\reims-vgpu -UtilRepo $env:RUNNER_TEMP\reims-util -Metal2VulkanRepo $env:RUNNER_TEMP\metal2vulkan -ResultFile patches.json
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ReimsRepo,
|
||||
[string]$ResultFile = '',
|
||||
[string]$UtilRepo = '',
|
||||
[string]$Metal2VulkanRepo = ''
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$patchesDir = Join-Path $repoRoot 'patches'
|
||||
$repositories = @{
|
||||
'reims-vgpu' = $ReimsRepo
|
||||
'vendor/qemu' = Join-Path $ReimsRepo 'vendor\qemu'
|
||||
'reims-util' = $UtilRepo
|
||||
'metal2vulkan' = $Metal2VulkanRepo
|
||||
}
|
||||
|
||||
function Read-PatchSeries {
|
||||
$series = Join-Path $patchesDir 'series.txt'
|
||||
foreach ($line in Get-Content -LiteralPath $series) {
|
||||
$t = $line.Trim()
|
||||
if (-not $t -or $t.StartsWith('#')) { continue }
|
||||
$parts = $t -split '\s+'
|
||||
if ($parts.Count -ne 2 -or -not $repositories.ContainsKey($parts[0])) {
|
||||
throw "Bad line in patches/series.txt: '$line'"
|
||||
}
|
||||
[pscustomobject]@{ Target = $parts[0]; Name = $parts[1] }
|
||||
}
|
||||
}
|
||||
|
||||
$result = [ordered]@{ applied = @(); merged = @(); conflict = $null }
|
||||
function Save-Result {
|
||||
if ($ResultFile) {
|
||||
[IO.File]::WriteAllText($ResultFile, ($result | ConvertTo-Json -Depth 3), [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
}
|
||||
|
||||
$series = @(Read-PatchSeries)
|
||||
if (-not $UtilRepo -and $series.Target -contains 'reims-util') {
|
||||
throw 'Pass -UtilRepo with a checkout at the reims-util revision pinned by reims-ctl.'
|
||||
}
|
||||
if (-not $Metal2VulkanRepo -and $series.Target -contains 'metal2vulkan') {
|
||||
throw 'Pass -Metal2VulkanRepo with a checkout at the metal2vulkan revision pinned by reims-vgpu.'
|
||||
}
|
||||
|
||||
foreach ($p in $series) {
|
||||
$file = Join-Path $patchesDir $p.Name
|
||||
if (-not (Test-Path -LiteralPath $file)) { throw "Patch listed in series.txt is missing: $file" }
|
||||
$dir = $repositories[$p.Target]
|
||||
# git -C into a missing or uninitialised submodule falls back to the outer
|
||||
# repository, where "git apply" silently skips paths outside the current
|
||||
# directory and reports success. Require $dir to be its own work tree.
|
||||
$top = (& git -C $dir rev-parse --show-toplevel 2>$null)
|
||||
if ($LASTEXITCODE -ne 0 -or -not $top -or
|
||||
[IO.Path]::GetFullPath($top.Trim()).TrimEnd([char[]]'\/') -ne [IO.Path]::GetFullPath($dir).TrimEnd([char[]]'\/')) {
|
||||
throw "$dir is not a checked-out git work tree for $($p.Target)"
|
||||
}
|
||||
|
||||
& git -C $dir apply --check $file 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
& git -C $dir apply $file
|
||||
if ($LASTEXITCODE -ne 0) { throw "git apply $($p.Name) failed after a clean --check" }
|
||||
Write-Host "applied $($p.Target) $($p.Name)"
|
||||
$result.applied += $p.Name
|
||||
continue
|
||||
}
|
||||
& git -C $dir apply --reverse --check $file 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "merged $($p.Target) $($p.Name) (already in the tree: merged upstream? retire it per spec section 5 rule 4)"
|
||||
$result.merged += $p.Name
|
||||
continue
|
||||
}
|
||||
$result.conflict = $p.Name
|
||||
Save-Result
|
||||
# Show git's own reason in the log.
|
||||
& git -C $dir apply --check $file
|
||||
throw "$($p.Name) neither applies nor is already upstream in $dir. Stop: don't edit patches automatically (AGENTS.md rule 4)."
|
||||
}
|
||||
$global:LASTEXITCODE = 0
|
||||
Save-Result
|
||||
@@ -1,174 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Entry gate for the alpha channel (portable-runtime-spec.md section 6), run by
|
||||
CI on the packed release files before anything is published.
|
||||
|
||||
.DESCRIPTION
|
||||
Fails unless all of these hold:
|
||||
1. The runtime, both source packages and SHA256SUMS.txt exist. Slim
|
||||
releases also require the matching detached symbols archive.
|
||||
2. SHA256SUMS.txt lists all release archives and every hash matches.
|
||||
3. manifest.json in the runtime names -Commit, channel "alpha", the source
|
||||
package, and exactly the patches in -AppliedPatches.
|
||||
4. The runtime's own qemu-system-x86_64.exe, run with a PATH holding only
|
||||
the runtime and Windows (no MSYS2), lists reims-graphics-pci in
|
||||
"-device help".
|
||||
|
||||
This is not the stable gate: promotion to stable still needs the real-host
|
||||
smoke test (scripts/smoke-runtime.ps1) and a person's approval.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$OutDir,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Commit,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Zstd,
|
||||
[string[]]$AppliedPatches = @(),
|
||||
[string]$RequiredCapability = '',
|
||||
[string]$RequiredSuspendCompatID = '',
|
||||
[string]$RequiredPackagingCommit = '',
|
||||
[switch]$RequireSlim,
|
||||
[switch]$SkipMsys2Sources,
|
||||
[switch]$SkipSymbols,
|
||||
# Only for checking packages built before the 2026-11-28 rename ("candidate").
|
||||
[string]$ExpectChannel = 'alpha',
|
||||
[string]$TempRoot = $env:RUNNER_TEMP
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$AppliedPatches = @($AppliedPatches | ForEach-Object { $_ -split ',' } | ForEach-Object { $_.Trim() } | Where-Object { $_ })
|
||||
|
||||
$names = @{
|
||||
runtime = "reims-runtime-win-x64-$Commit.tar.zst"
|
||||
source = "reims-runtime-src-$Commit.tar.zst"
|
||||
sums = 'SHA256SUMS.txt'
|
||||
}
|
||||
if (-not $SkipMsys2Sources) {
|
||||
$names.msys2 = "reims-runtime-msys2-src-$Commit.tar.zst"
|
||||
}
|
||||
|
||||
$symbolsName = "reims-runtime-symbols-$Commit"
|
||||
if ((-not $SkipSymbols) -and ($RequireSlim -or (Test-Path -LiteralPath (Join-Path $OutDir "$symbolsName.tar.zst")))) {
|
||||
$names.symbols = "$symbolsName.tar.zst"
|
||||
}
|
||||
# 1. All assets for this layout.
|
||||
foreach ($k in $names.Keys) {
|
||||
$p = Join-Path $OutDir $names[$k]
|
||||
if (-not (Test-Path -LiteralPath $p)) { throw "Missing release asset: $($names[$k])" }
|
||||
}
|
||||
Write-Host "PASS $($names.Count) release assets present"
|
||||
|
||||
# 2. Sums cover the archives and match.
|
||||
$sums = @{}
|
||||
foreach ($line in Get-Content -LiteralPath (Join-Path $OutDir $names.sums)) {
|
||||
if ($line -match '^([0-9a-fA-F]{64})\s+\*?(.+)$') { $sums[$Matches[2].Trim()] = $Matches[1].ToLowerInvariant() }
|
||||
}
|
||||
foreach ($k in ($names.Keys | Where-Object { $_ -ne 'sums' })) {
|
||||
$n = $names[$k]
|
||||
if (-not $sums.ContainsKey($n)) { throw "SHA256SUMS.txt has no entry for $n" }
|
||||
$got = (Get-FileHash -Algorithm SHA256 -LiteralPath (Join-Path $OutDir $n)).Hash.ToLowerInvariant()
|
||||
if ($got -ne $sums[$n]) { throw "SHA256 mismatch for ${n}: listed $($sums[$n]), actual $got" }
|
||||
}
|
||||
Write-Host 'PASS SHA256SUMS.txt covers and matches all archives'
|
||||
|
||||
# Extract the runtime.
|
||||
$work = Join-Path $TempRoot ("alpha-gate-" + [guid]::NewGuid())
|
||||
New-Item -ItemType Directory -Force -Path $work | Out-Null
|
||||
try {
|
||||
$tar = Join-Path $work 'runtime.tar'
|
||||
& $Zstd -d -q -f (Join-Path $OutDir $names.runtime) -o $tar
|
||||
if ($LASTEXITCODE -ne 0) { throw "zstd failed ($LASTEXITCODE)" }
|
||||
# Windows' own bsdtar: GNU tar from Git/MSYS2 reads "D:" as a remote host.
|
||||
& (Join-Path $env:SystemRoot 'System32\tar.exe') -xf $tar -C $work
|
||||
if ($LASTEXITCODE -ne 0) { throw "tar failed ($LASTEXITCODE)" }
|
||||
Remove-Item -LiteralPath $tar -Force
|
||||
$root = Join-Path $work "reims-runtime-win-x64-$Commit"
|
||||
|
||||
# 3. Manifest states what was really built.
|
||||
$m = Get-Content -Raw -LiteralPath (Join-Path $root 'manifest.json') | ConvertFrom-Json
|
||||
if ($m.commit -ne $Commit) { throw "manifest commit is $($m.commit), expected $Commit" }
|
||||
if ($m.channel -ne $ExpectChannel) { throw "manifest channel is $($m.channel), expected $ExpectChannel" }
|
||||
if ($m.source_package -ne $names.source) { throw "manifest source_package is $($m.source_package), expected $($names.source)" }
|
||||
if ($RequiredCapability -and $RequiredCapability -notin $m.capabilities) { throw "manifest lacks capability $RequiredCapability" }
|
||||
if ($RequiredSuspendCompatID -and ($m.suspend_compat_id -cne $RequiredSuspendCompatID -or
|
||||
$Commit -cnotmatch ('^' + [regex]::Escape($RequiredSuspendCompatID) + '(?:-p[1-9][0-9]*)?$'))) {
|
||||
throw "manifest suspend_compat_id is $($m.suspend_compat_id), expected $RequiredSuspendCompatID for $Commit"
|
||||
}
|
||||
if ($RequiredPackagingCommit -and $m.packaging_commit -cne $RequiredPackagingCommit) {
|
||||
throw "manifest packaging_commit is $($m.packaging_commit), expected $RequiredPackagingCommit"
|
||||
}
|
||||
$files = @(Get-ChildItem -LiteralPath $root -Recurse -File)
|
||||
if ($m.file_count -ne $files.Count) { throw "manifest file_count is $($m.file_count), actual $($files.Count)" }
|
||||
$rawBytes = [int64](($files | Measure-Object Length -Sum).Sum)
|
||||
if ($m.raw_bytes -ne $rawBytes) { throw "manifest raw_bytes is $($m.raw_bytes), actual $rawBytes" }
|
||||
$declared = @($m.patches | ForEach-Object { $_.name })
|
||||
if (($declared -join ',') -ne ($AppliedPatches -join ',')) {
|
||||
throw "manifest patches [$($declared -join ', ')] differ from those applied [$($AppliedPatches -join ', ')]"
|
||||
}
|
||||
Write-Host "PASS manifest: commit $Commit, channel $($m.channel), patches [$($declared -join ', ')]"
|
||||
|
||||
if ($m.symbols_package -or $names.symbols) {
|
||||
if (!$names.symbols -or $m.symbols_package -ne $names.symbols) { throw 'Missing or mismatched symbols package' }
|
||||
$symTar = Join-Path $work 'symbols.tar'
|
||||
& $Zstd -d -q -f (Join-Path $OutDir $names.symbols) -o $symTar
|
||||
if ($LASTEXITCODE) { throw 'Cannot decompress symbols package' }
|
||||
$members = & (Join-Path $env:SystemRoot 'System32\tar.exe') -tf $symTar
|
||||
if ($LASTEXITCODE) { throw 'Cannot list symbols package' }
|
||||
foreach ($rel in 'bin/reims-ctl.exe','bin/reims-util.exe','qemu/bin/qemu-system-x86_64.exe','qemu/bin/qemu-img.exe','qemu/bin/reims-vgpu-compile.exe') {
|
||||
$hash = (Get-FileHash -LiteralPath (Join-Path $root $rel) -Algorithm SHA256).Hash
|
||||
if ($hash -ne $m.sha256.$rel) { throw "Manifest hash mismatch for $rel" }
|
||||
if ("$symbolsName/$rel.debug" -notin $members) { throw "Missing debug file for $rel" }
|
||||
}
|
||||
foreach ($rel in 'qemu/bin/libva.dll','qemu/bin/libva_win32.dll','qemu/bin/vaon12_drv_video.dll','NOTICE.md','MSYS2-PACKAGES.txt') {
|
||||
if (!(Test-Path -LiteralPath (Join-Path $root $rel) -PathType Leaf)) { throw "Missing runtime dependency: $rel" }
|
||||
}
|
||||
Write-Host 'PASS stripped executable hashes, detached debug members and video driver files'
|
||||
} elseif ($RequireSlim) {
|
||||
foreach ($rel in 'bin/reims-ctl.exe','bin/reims-util.exe','qemu/bin/qemu-system-x86_64.exe','qemu/bin/qemu-img.exe','qemu/bin/reims-vgpu-compile.exe') {
|
||||
$hash = (Get-FileHash -LiteralPath (Join-Path $root $rel) -Algorithm SHA256).Hash
|
||||
if ($hash -ne $m.sha256.$rel) { throw "Manifest hash mismatch for $rel" }
|
||||
}
|
||||
foreach ($rel in 'qemu/bin/libva.dll','qemu/bin/libva_win32.dll','qemu/bin/vaon12_drv_video.dll','NOTICE.md','MSYS2-PACKAGES.txt') {
|
||||
if (!(Test-Path -LiteralPath (Join-Path $root $rel) -PathType Leaf)) { throw "Missing runtime dependency: $rel" }
|
||||
}
|
||||
Write-Host 'PASS stripped executable hashes and video driver files (light alpha)'
|
||||
}
|
||||
|
||||
# 4. QEMU runs from the bundle alone and has the reims device.
|
||||
$qemuBin = Join-Path $root 'qemu\bin'
|
||||
$psi = [Diagnostics.ProcessStartInfo]::new((Join-Path $qemuBin 'qemu-system-x86_64.exe'), '-device help')
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.WorkingDirectory = $qemuBin
|
||||
$psi.Environment['PATH'] = "$qemuBin;$env:SystemRoot\System32;$env:SystemRoot"
|
||||
$proc = [Diagnostics.Process]::Start($psi)
|
||||
$errTask = $proc.StandardError.ReadToEndAsync()
|
||||
$out = $proc.StandardOutput.ReadToEnd()
|
||||
if (-not $proc.WaitForExit(120000)) { $proc.Kill(); throw 'qemu -device help timed out' }
|
||||
$err = $errTask.Result
|
||||
if ($proc.ExitCode -ne 0) { throw "qemu -device help exited $($proc.ExitCode): $err" }
|
||||
if ($out -notmatch 'reims-graphics-pci') { throw "qemu -device help does not list reims-graphics-pci`n$out`n$err" }
|
||||
Write-Host 'PASS qemu-system-x86_64 -device help lists reims-graphics-pci (no MSYS2 on PATH)'
|
||||
if ($names.symbols -or $RequireSlim) {
|
||||
$oldPath = $env:PATH
|
||||
$img = Join-Path $qemuBin 'qemu-img.exe'
|
||||
try {
|
||||
$env:PATH = $psi.Environment['PATH']
|
||||
foreach ($exe in 'reims-ctl.exe','reims-util.exe') {
|
||||
& (Join-Path $root "bin/$exe") --version
|
||||
if ($LASTEXITCODE) { throw "$exe --version failed ($LASTEXITCODE)" }
|
||||
}
|
||||
$disk = Join-Path $work 'test.qcow2'
|
||||
& $img create -f qcow2 $disk 32M
|
||||
if ($LASTEXITCODE) { throw "qemu-img create failed ($LASTEXITCODE)" }
|
||||
$info = & $img info --output=json $disk
|
||||
if ($LASTEXITCODE -or (($info -join "`n" | ConvertFrom-Json).'virtual-size' -ne 32MB)) { throw 'qemu-img info failed' }
|
||||
} finally { $env:PATH = $oldPath }
|
||||
Write-Host 'PASS CLI versions and qcow2 creation / inspection (no MSYS2 on PATH)'
|
||||
}
|
||||
} finally {
|
||||
Remove-Item -Recurse -Force -LiteralPath $work -ErrorAction SilentlyContinue
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Pack the sources of the copyleft MSYS2 packages whose DLLs a runtime bundles,
|
||||
as a separate release asset.
|
||||
|
||||
.DESCRIPTION
|
||||
Reads the "# Packages" list from a runtime's MSYS2-PACKAGES.txt, looks up each
|
||||
package's source name (%BASE%) and licenses in the local pacman database, and
|
||||
keeps the packages whose license requires source (GPL / LGPL / MPL) unless an
|
||||
alternative licence without those can be chosen (for example "GPL OR FTL").
|
||||
|
||||
For each kept package it downloads <base>-<version>.src.tar.zst and its .sig
|
||||
from repo.msys2.org (cached in -CacheDir), checks the signature against the
|
||||
MSYS2 keyring with gpgv, and packs them into
|
||||
reims-runtime-msys2-src-<commit>.tar.zst in -OutDir. The archive's hash is
|
||||
added to -OutDir\SHA256SUMS.txt (an existing line for it is replaced).
|
||||
|
||||
Published in the same GitHub Release as the runtime, so the sources are
|
||||
offered from the same place as the binaries (GPLv2 §3, LGPL-2.1 §6).
|
||||
|
||||
.EXAMPLE
|
||||
pwsh -File scripts/pack-msys2-sources.ps1 -PackagesFile MSYS2-PACKAGES.txt -Commit 3731afd -OutDir D:\Data\reims-go\releases\3731afd-candidate
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)] [string]$PackagesFile,
|
||||
[Parameter(Mandatory)] [string]$Commit,
|
||||
[Parameter(Mandatory)] [string]$OutDir,
|
||||
[string]$Msys2 = 'D:\DevTools\msys64',
|
||||
[string]$CacheDir = 'D:\Data\reims-go\releases\msys2-sources-cache',
|
||||
[string]$TempRoot = 'D:\Build\Temp',
|
||||
[string]$Mirror = 'https://repo.msys2.org/mingw/sources'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot 'runtime-zstd.ps1')
|
||||
$localDb = Join-Path $Msys2 'var\lib\pacman\local'
|
||||
$bash = Join-Path $Msys2 'usr\bin\bash.exe'
|
||||
$zstd = Resolve-Zstd -Msys2 $Msys2
|
||||
|
||||
function Write-Utf8([string]$path, [string]$text) {
|
||||
[IO.File]::WriteAllText($path, $text.Replace("`r`n", "`n"), [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
|
||||
function Read-Desc([string]$name, [string]$version) {
|
||||
$file = Join-Path $localDb "$name-$version\desc"
|
||||
if (-not (Test-Path -LiteralPath $file)) {
|
||||
throw "$name $version is not in the local pacman database ($file): was MSYS2 updated after the runtime was built?"
|
||||
}
|
||||
$fields = @{}
|
||||
$key = $null
|
||||
foreach ($line in Get-Content -LiteralPath $file) {
|
||||
if ($line -match '^%(\w+)%$') { $key = $Matches[1]; $fields[$key] = @(); continue }
|
||||
if ($key -and $line -ne '') { $fields[$key] += $line }
|
||||
}
|
||||
return $fields
|
||||
}
|
||||
|
||||
# A licence entry needs source unless one OR-alternative is free of copyleft.
|
||||
# Entries prefixed "documentation:" cover only docs, which aren't shipped.
|
||||
function Test-NeedsSource([string[]]$licenses) {
|
||||
foreach ($entry in $licenses) {
|
||||
if ($entry -like 'documentation:*') { continue }
|
||||
$expr = $entry -replace '^spdx:', ''
|
||||
$alternatives = $expr -split '\s+OR\s+'
|
||||
$allCopyleft = $true
|
||||
foreach ($alt in $alternatives) {
|
||||
if ($alt -notmatch 'GPL|MPL') { $allCopyleft = $false }
|
||||
}
|
||||
if ($allCopyleft) { return $true }
|
||||
}
|
||||
return $false
|
||||
}
|
||||
|
||||
function To-MsysPath([string]$winPath) {
|
||||
$p = $winPath -replace '\\', '/'
|
||||
if ($p -match '^([A-Za-z]):(.*)$') { return '/' + $Matches[1].ToLower() + $Matches[2] }
|
||||
return $p
|
||||
}
|
||||
|
||||
# ── 1. Which packages need source ────────────────────────────
|
||||
$text = Get-Content -Raw -LiteralPath $PackagesFile
|
||||
$section = ($text -split '# Packages[^\n]*\n', 2)[1]
|
||||
if (-not $section) { throw "No '# Packages' section in $PackagesFile" }
|
||||
$packages = $section -split "`n" | Where-Object { $_ -match '^\S+ \S+$' } | ForEach-Object {
|
||||
$n, $v = $_ -split ' '
|
||||
$d = Read-Desc $n $v
|
||||
[pscustomobject]@{
|
||||
Name = $n
|
||||
Version = $v
|
||||
Base = $d['BASE'][0]
|
||||
Licenses = $d['LICENSE']
|
||||
Needs = (Test-NeedsSource $d['LICENSE'])
|
||||
}
|
||||
}
|
||||
$needed = @($packages | Where-Object Needs | Sort-Object Base, Version -Unique)
|
||||
Write-Host ("==> {0} of {1} packages need source; {2} source archives" -f @($packages | Where-Object Needs).Count, $packages.Count, $needed.Count)
|
||||
|
||||
# ── 2. Download and verify ───────────────────────────────────
|
||||
New-Item -ItemType Directory -Force -Path $CacheDir, $OutDir | Out-Null
|
||||
foreach ($p in $needed) {
|
||||
$file = "$($p.Base)-$($p.Version).src.tar.zst"
|
||||
foreach ($f in @($file, "$file.sig")) {
|
||||
$dest = Join-Path $CacheDir $f
|
||||
if (-not (Test-Path -LiteralPath $dest)) {
|
||||
Write-Host " downloading $f"
|
||||
Invoke-WebRequest -Uri "$Mirror/$f" -OutFile "$dest.part" -UserAgent 'reims-go-packager'
|
||||
Move-Item -LiteralPath "$dest.part" -Destination $dest -Force
|
||||
}
|
||||
}
|
||||
$cache = To-MsysPath $CacheDir
|
||||
$out = & $bash -lc "LC_ALL=C gpgv --keyring /etc/pacman.d/gnupg/pubring.gpg '$cache/$file.sig' '$cache/$file' 2>&1"
|
||||
if ($LASTEXITCODE -ne 0) { throw "Signature check failed for ${file}:`n$out" }
|
||||
$signer = ($out | Select-String 'Good signature from "([^"]+)"').Matches.Groups[1].Value
|
||||
$p | Add-Member -NotePropertyName File -NotePropertyValue $file
|
||||
$p | Add-Member -NotePropertyName Signer -NotePropertyValue $signer
|
||||
}
|
||||
|
||||
# ── 3. Pack ──────────────────────────────────────────────────
|
||||
$name = "reims-runtime-msys2-src-$Commit"
|
||||
$stage = Join-Path $TempRoot "pack-$name"
|
||||
if (Test-Path -LiteralPath $stage) { Remove-Item -Recurse -Force -LiteralPath $stage }
|
||||
$dir = Join-Path $stage $name
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $dir 'sources') | Out-Null
|
||||
foreach ($p in $needed) {
|
||||
Copy-Item -LiteralPath (Join-Path $CacheDir $p.File) -Destination (Join-Path $dir 'sources')
|
||||
Copy-Item -LiteralPath (Join-Path $CacheDir "$($p.File).sig") -Destination (Join-Path $dir 'sources')
|
||||
}
|
||||
|
||||
$rows = foreach ($p in ($packages | Sort-Object Name)) {
|
||||
$lic = ($p.Licenses -join '; ') -replace '\|', '/'
|
||||
$src = if ($p.Needs) { "``sources/$("$($p.Base)-$($p.Version).src.tar.zst")``" } else { '— (permissive licence; text in the runtime''s licenses/)' }
|
||||
"| ``$($p.Name -replace '^mingw-w64-clang-x86_64-', '')`` | $($p.Version) | $lic | $src |"
|
||||
}
|
||||
Write-Utf8 (Join-Path $dir 'README.md') @"
|
||||
# MSYS2 package sources for reims-runtime-win-x64-$Commit
|
||||
|
||||
The runtime's ``qemu/bin`` bundles DLLs from MSYS2 CLANG64 packages. This archive
|
||||
holds, unmodified, the source packages of every one whose licence requires source
|
||||
(GPL, LGPL or MPL with no permissive alternative), exactly as MSYS2 publishes them
|
||||
at $Mirror, each with its detached signature (``.sig``), checked with gpgv
|
||||
against the MSYS2 keyring when this archive was made.
|
||||
|
||||
A ``.src.tar.zst`` contains the PKGBUILD, the upstream source tarball and MSYS2's
|
||||
patches: ``makepkg-mingw`` in an MSYS2 shell rebuilds the package.
|
||||
|
||||
| Package | Version | Licence | Source |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
$($rows -join "`n")
|
||||
"@
|
||||
|
||||
$tar = Join-Path $TempRoot "$name.tar"
|
||||
& tar.exe -cf $tar -C $stage $name
|
||||
if ($LASTEXITCODE -ne 0) { throw 'tar failed' }
|
||||
$archive = Join-Path $OutDir "$name.tar.zst"
|
||||
& $zstd -T0 -3 -q -f $tar -o $archive # contents are already compressed
|
||||
if ($LASTEXITCODE -ne 0) { throw 'zstd failed' }
|
||||
Remove-Item -LiteralPath $tar -Force
|
||||
Remove-Item -Recurse -Force -LiteralPath $stage
|
||||
|
||||
# ── 4. SHA256SUMS.txt ────────────────────────────────────────
|
||||
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $archive).Hash.ToLowerInvariant()
|
||||
$sums = Join-Path $OutDir 'SHA256SUMS.txt'
|
||||
$lines = @()
|
||||
if (Test-Path -LiteralPath $sums) {
|
||||
$lines = @(Get-Content -LiteralPath $sums | Where-Object { $_ -and $_ -notmatch " $([regex]::Escape("$name.tar.zst"))$" })
|
||||
}
|
||||
$lines += "$hash $name.tar.zst"
|
||||
Write-Utf8 $sums (($lines -join "`n") + "`n")
|
||||
|
||||
Write-Host '==> Done' -ForegroundColor Green
|
||||
'{0} {1:N1} MB ({2} source archives, all signatures good)' -f $archive, ((Get-Item $archive).Length / 1MB), $needed.Count
|
||||
@@ -1,636 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Pack a portable reims-vgpu runtime for Windows x64, its matching source
|
||||
package, and SHA256SUMS.txt, ready to publish as a GitHub Release.
|
||||
|
||||
.DESCRIPTION
|
||||
Outputs, in -OutDir (all five are assets of one GitHub Release):
|
||||
reims-runtime-win-x64-<commit>.tar.zst runtime (bin/, qemu/, manifest.json,
|
||||
NOTICE.md, licenses/, patches/,
|
||||
MSYS2-PACKAGES.txt)
|
||||
reims-runtime-src-<commit>.tar.zst corresponding source: pristine upstream
|
||||
trees at the built commits + patches/
|
||||
reims-runtime-msys2-src-<commit>.tar.zst sources of the copyleft MSYS2 packages
|
||||
whose DLLs are bundled (pack-msys2-sources.ps1)
|
||||
reims-runtime-symbols-<commit>.tar.zst detached debug files for the five programs
|
||||
SHA256SUMS.txt all four archives
|
||||
|
||||
manifest.json (schema 2) states what the package was really built from:
|
||||
upstream commit, vendor/qemu commit, reims-util and metal2vulkan commits,
|
||||
every local patch with its SHA256, and the channel. A package built with
|
||||
patches is never described as pure upstream (AGENTS.md rule 5).
|
||||
|
||||
The patches come from patches/series.txt (in that order). -Patches narrows
|
||||
them to the ones really applied to the build tree (CI passes the list from
|
||||
apply-patch-series.ps1, which skips patches already merged upstream).
|
||||
Before packing, the build tree's diff must equal the declared patches, so
|
||||
the source package matches the binaries, and any other change in the
|
||||
build trees is refused. A mismatch stops the script.
|
||||
|
||||
.EXAMPLE
|
||||
pwsh -File scripts/pack-runtime.ps1 -Channel alpha
|
||||
pwsh -File scripts/pack-runtime.ps1 -Patches reims-util-parallel-offline-download.patch,metal2vulkan-snapshot-replay.patch
|
||||
#>
|
||||
[CmdletBinding(PositionalBinding = $false)]
|
||||
param(
|
||||
[string]$ReimsRepo = 'D:\DevTools\reims-vgpu',
|
||||
[string]$UtilRepo = '',
|
||||
[string]$Metal2VulkanRepo = '',
|
||||
[string]$CargoHome = 'D:\DevTools\cargo',
|
||||
[string]$QemuDir = 'D:\Data\macos-vm-lab\reims\data\reims-ctl\qemu\current',
|
||||
[string]$Msys2 = 'D:\DevTools\msys64',
|
||||
[string]$OutDir = 'D:\Data\reims-go\releases',
|
||||
[string]$TempRoot = 'D:\Build\Temp',
|
||||
# Channel at build time. A runtime is promoted to stable by turning its
|
||||
# GitHub prerelease into a release, never by repacking (spec section 6).
|
||||
[ValidateSet('alpha', 'stable')]
|
||||
[string]$Channel = 'alpha',
|
||||
[int]$ZstdLevel = 15,
|
||||
# Release identifier for archive names and manifest.commit (defaults to short
|
||||
# upstream commit; e.g. "3731afd-p2" for a patch-queue rebuild of 3731afd).
|
||||
[string]$ReleaseId = '',
|
||||
[ValidatePattern('^(?:[0-9a-f]{7,40})?$')]
|
||||
[string]$SuspendCompatID = '',
|
||||
[ValidatePattern('^(?:[0-9a-f]{40})?$')]
|
||||
[string]$PackagingCommit = '',
|
||||
# Names from patches/series.txt actually applied. Not given: all of them.
|
||||
# Given but empty: none (every patch already upstream).
|
||||
[string[]]$Patches = @(),
|
||||
# Omit the 110 MB MSYS2 copyleft source bundle (e.g. for frequent alpha previews;
|
||||
# include for stable releases or dedicated toolchain source releases).
|
||||
[switch]$SkipMsys2Sources,
|
||||
# Omit the ~95 MB detached debug symbols archive (binaries are still stripped).
|
||||
[switch]$SkipSymbols
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot 'runtime-zstd.ps1')
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$patchesDir = Join-Path $repoRoot 'patches'
|
||||
$CargoBin = Join-Path $CargoHome 'bin'
|
||||
|
||||
function Invoke-Native([string]$exe, [string[]]$argv) {
|
||||
& $exe @argv
|
||||
if ($LASTEXITCODE -ne 0) { throw "$exe $($argv -join ' ') failed ($LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
function Invoke-GitApply([string]$repo, [string]$patchText, [switch]$Check) {
|
||||
$psi = [Diagnostics.ProcessStartInfo]::new()
|
||||
$psi.FileName = (Get-Command git).Source
|
||||
$psi.WorkingDirectory = $repo
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.RedirectStandardInput = $true
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.ArgumentList.Add('apply')
|
||||
if ($Check) { $psi.ArgumentList.Add('--check') }
|
||||
$psi.ArgumentList.Add('-')
|
||||
$proc = [Diagnostics.Process]::Start($psi)
|
||||
$proc.StandardInput.NewLine = "`n"
|
||||
$proc.StandardInput.Write($patchText)
|
||||
$proc.StandardInput.Close()
|
||||
$stdout = $proc.StandardOutput.ReadToEnd()
|
||||
$stderr = $proc.StandardError.ReadToEnd()
|
||||
$proc.WaitForExit()
|
||||
if ($proc.ExitCode) { throw "git apply failed in $repo ($($proc.ExitCode)): $stdout$stderr" }
|
||||
}
|
||||
|
||||
function Get-Sha256([string]$path) {
|
||||
(Get-FileHash -Algorithm SHA256 -LiteralPath $path).Hash.ToLowerInvariant()
|
||||
}
|
||||
|
||||
function Write-Utf8([string]$path, [string]$text) {
|
||||
[IO.File]::WriteAllText($path, $text.Replace("`r`n", "`n"), [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
|
||||
function New-TarZst([string]$parent, [string]$name, [string]$archive) {
|
||||
$tar = Join-Path $TempRoot "$name.tar"
|
||||
Invoke-Native 'tar.exe' @('-cf', $tar, '-C', $parent, $name)
|
||||
# --long=27 (128 MiB window) deduplicates shared QEMU code across x86_64 and aarch64
|
||||
# binaries while staying within default zstd CLI and Go decoder window limits.
|
||||
Invoke-Native $zstd @('-T0', '--long=27', "-$ZstdLevel", '-q', '-f', $tar, '-o', $archive)
|
||||
Remove-Item -LiteralPath $tar -Force
|
||||
}
|
||||
|
||||
# ── 1. Inputs and provenance ─────────────────────────────────
|
||||
function Get-GitHubSource([string]$Url, [string]$Fallback) {
|
||||
if ($Url -match '^(?:https://(?:[^/@]+@)?github\.com/|git@github\.com:)([\w.-]+/[\w.-]+?)(?:\.git)?/?$') {
|
||||
return "https://github.com/$($Matches[1])"
|
||||
}
|
||||
return "https://github.com/$Fallback"
|
||||
}
|
||||
|
||||
$ctlExe = Join-Path $CargoBin 'reims-ctl.exe'
|
||||
$utilExe = Join-Path $CargoBin 'reims-util.exe'
|
||||
$qemuExe = Join-Path $QemuDir 'bin\qemu-system-x86_64.exe'
|
||||
foreach ($p in @($ctlExe, $utilExe, $qemuExe)) {
|
||||
if (-not (Test-Path -LiteralPath $p)) { throw "Required runtime binary not found: $p" }
|
||||
}
|
||||
|
||||
$commit = (git -C $ReimsRepo rev-parse --short HEAD).Trim()
|
||||
$fullCommit = (git -C $ReimsRepo rev-parse HEAD).Trim()
|
||||
$id = if ($ReleaseId -and $ReleaseId.Trim()) { $ReleaseId.Trim() } else { $commit }
|
||||
if ($SuspendCompatID -and $id -cnotmatch ('^' + [regex]::Escape($SuspendCompatID) + '(?:-p[1-9][0-9]*)?$')) {
|
||||
throw "Suspend compatibility ID $SuspendCompatID does not match release $id"
|
||||
}
|
||||
$qemuRepo = Join-Path $ReimsRepo 'vendor\qemu'
|
||||
$qemuCommit = (git -C $qemuRepo rev-parse HEAD).Trim()
|
||||
$reimsOrigin = git -C $ReimsRepo config --get remote.origin.url 2>$null
|
||||
$qemuOrigin = git -C $ReimsRepo config --file .gitmodules --get submodule.vendor/qemu.url
|
||||
$reimsSource = Get-GitHubSource $reimsOrigin 'steelbrain/reims-vgpu'
|
||||
$qemuSource = Get-GitHubSource $qemuOrigin 'steelbrain/qemu-reims-vgpu'
|
||||
$capabilities = @()
|
||||
$runtimeFeatures = Join-Path $ReimsRepo 'reims-go-runtime.json'
|
||||
if (Test-Path -LiteralPath $runtimeFeatures) {
|
||||
$capabilities = @((Get-Content -Raw -LiteralPath $runtimeFeatures | ConvertFrom-Json).capabilities)
|
||||
}
|
||||
|
||||
$pins = & (Join-Path $PSScriptRoot 'read-runtime-dependencies.ps1') -RuntimeRepo $ReimsRepo
|
||||
$utilCommit = $pins.Util.Rev
|
||||
$m2vCommit = $pins.Metal.Rev
|
||||
$checkouts = Join-Path $CargoHome 'git\checkouts'
|
||||
$utilTree = if ($UtilRepo) {
|
||||
(Resolve-Path -LiteralPath $UtilRepo).Path
|
||||
} else {
|
||||
Get-ChildItem -LiteralPath $checkouts -Directory -Filter 'reims-util-*' |
|
||||
ForEach-Object { Join-Path $_.FullName $utilCommit.Substring(0, 7) } |
|
||||
Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
||||
}
|
||||
if (-not $utilTree) { throw "reims-util source at $utilCommit not found" }
|
||||
$actualUtil = git -C $utilTree rev-parse HEAD
|
||||
if ($LASTEXITCODE -ne 0 -or $actualUtil -ne $utilCommit) { throw "reims-util checkout must be at $utilCommit" }
|
||||
|
||||
$m2vTree = if ($Metal2VulkanRepo) {
|
||||
(Resolve-Path -LiteralPath $Metal2VulkanRepo).Path
|
||||
} else {
|
||||
Get-ChildItem -LiteralPath $checkouts -Directory -Filter 'metal2vulkan-*' -ErrorAction SilentlyContinue |
|
||||
ForEach-Object { Join-Path $_.FullName $m2vCommit.Substring(0, 7) } |
|
||||
Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
||||
}
|
||||
if (-not $m2vTree) { throw "metal2vulkan source at $m2vCommit not found (pass -Metal2VulkanRepo or check $checkouts)" }
|
||||
$actualM2v = (git -C $m2vTree rev-parse HEAD).Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or $actualM2v -ne $m2vCommit) { throw "metal2vulkan checkout must be at $m2vCommit (got $actualM2v)" }
|
||||
|
||||
$qemuVersionLine = (& $qemuExe --version | Select-Object -First 1).Trim()
|
||||
$utilVersionLine = (& $utilExe --version | Select-Object -First 1).Trim()
|
||||
|
||||
# ── 2. Patches must equal the build tree's diffs ─────────────
|
||||
$repositories = @{
|
||||
'reims-vgpu' = $ReimsRepo
|
||||
'vendor/qemu' = $qemuRepo
|
||||
'reims-util' = $utilTree
|
||||
'metal2vulkan' = $m2vTree
|
||||
}
|
||||
$series = @(foreach ($line in Get-Content -LiteralPath (Join-Path $patchesDir 'series.txt')) {
|
||||
$t = $line.Trim()
|
||||
if (-not $t -or $t.StartsWith('#')) { continue }
|
||||
$parts = $t -split '\s+'
|
||||
if ($parts.Count -ne 2 -or -not $repositories.ContainsKey($parts[0])) { throw "Bad line in patches/series.txt: '$line'" }
|
||||
[pscustomobject]@{ Target = $parts[0]; Name = $parts[1] }
|
||||
})
|
||||
# PowerShell -File passes "a,b" as one string: accept both forms.
|
||||
$Patches = @($Patches | ForEach-Object { $_ -split ',' } | ForEach-Object { $_.Trim() } | Where-Object { $_ })
|
||||
foreach ($n in $Patches) {
|
||||
if ($n -notin $series.Name) { throw "-Patches names $n, which is not in patches/series.txt" }
|
||||
}
|
||||
$patchSpecs = @()
|
||||
$usePatchList = $PSBoundParameters.ContainsKey('Patches')
|
||||
foreach ($e in $series) {
|
||||
if ($usePatchList -and $e.Name -notin $Patches) { continue }
|
||||
$file = Join-Path $patchesDir $e.Name
|
||||
if (-not (Test-Path -LiteralPath $file)) { throw "Patch missing: $file" }
|
||||
# Files the patch touches ("--- a/x" / "+++ b/x", and each "diff --git a/x b/y" header, which a
|
||||
# binary patch has alone), to scope the diff checks.
|
||||
$paths = @(Get-Content -LiteralPath $file | ForEach-Object {
|
||||
if ($_ -match '^(?:---|\+\+\+) [ab]/(.+?)\s*$') { $Matches[1] }
|
||||
elseif ($_ -match '^diff --git a/(.+?) b/(.+?)\s*$') { $Matches[1]; $Matches[2] }
|
||||
} | Select-Object -Unique)
|
||||
$patchSpecs += @{
|
||||
Name = $e.Name
|
||||
Target = $e.Target
|
||||
Repo = $repositories[$e.Target]
|
||||
Paths = $paths
|
||||
}
|
||||
}
|
||||
# Avoid colliding with the [string[]]$Patches parameter (PowerShell variable
|
||||
# names are case-insensitive; reusing $patches coerces every entry to a string).
|
||||
$patchEntries = @()
|
||||
# Group patches by repo so multi-patch stacks (e.g. 2-3 QEMU WHPX patches) are
|
||||
# verified together against a clean HEAD export with zero undeclared diff.
|
||||
$byTarget = [ordered]@{}
|
||||
foreach ($ps in $patchSpecs) {
|
||||
$file = Join-Path $patchesDir $ps.Name
|
||||
if (-not (Test-Path -LiteralPath $file)) { throw "Patch missing: $file" }
|
||||
if (-not $byTarget.Contains($ps.Target)) {
|
||||
$byTarget[$ps.Target] = [Collections.Generic.List[hashtable]]::new()
|
||||
}
|
||||
$byTarget[$ps.Target].Add($ps)
|
||||
$patchEntries += [ordered]@{ name = $ps.Name; target = $ps.Target; sha256 = (Get-Sha256 $file) }
|
||||
}
|
||||
foreach ($targetName in $byTarget.Keys) {
|
||||
$group = $byTarget[$targetName]
|
||||
$repo = $group[0].Repo
|
||||
$paths = @($group | ForEach-Object { $_.Paths } | Where-Object { $_ } | Select-Object -Unique)
|
||||
# Use --full-index so blob hash abbreviation lengths match regardless of
|
||||
# object count between the upstream clone and the single-commit verify repo.
|
||||
$diffArgs = @('-C', $repo, '-c', 'core.autocrlf=false', 'diff', '--full-index')
|
||||
if ($paths.Count) { $diffArgs += '--'; $diffArgs += $paths }
|
||||
# The mode on an "index" line is the file's, not the change's: the verify tree is extracted by
|
||||
# tar on Windows, which keeps no executable bit, so a changed executable (a prebuilt kext) reads
|
||||
# 100644 there and 100755 here. A change of mode has its own "old mode"/"new mode" lines, which
|
||||
# stay compared.
|
||||
$indexMode = '(?m)^(index [0-9a-f]+\.\.[0-9a-f]+) [0-7]{6}$'
|
||||
$treeDiff = ((& git @diffArgs | Out-String).Replace("`r`n", "`n") -replace $indexMode, '$1').TrimEnd()
|
||||
|
||||
# Apply the declared patch stack to a clean temporary clone of HEAD and compare diffs byte-for-byte.
|
||||
$verifyDir = Join-Path $TempRoot ("patch-verify-" + [guid]::NewGuid())
|
||||
try {
|
||||
New-Item -ItemType Directory -Force -Path $verifyDir | Out-Null
|
||||
$headRev = (git -C $repo rev-parse HEAD).Trim()
|
||||
Invoke-Native 'git' @('init', '-q', $verifyDir)
|
||||
Invoke-Native 'git' @('-C', $verifyDir, 'config', 'core.autocrlf', 'false')
|
||||
Invoke-Native 'git' @('-C', $verifyDir, 'config', 'core.eol', 'lf')
|
||||
Invoke-Native 'git' @('-C', $verifyDir, 'config', 'core.filemode', 'false')
|
||||
Write-Utf8 (Join-Path $verifyDir '.gitattributes') '* text eol=lf`n'
|
||||
$tar = Join-Path $TempRoot ("patch-verify-" + [guid]::NewGuid() + '.tar')
|
||||
Invoke-Native 'git' @('-C', $repo, 'archive', '--format=tar', '-o', $tar, $headRev)
|
||||
Invoke-Native 'tar.exe' @('-xf', $tar, '-C', $verifyDir)
|
||||
Remove-Item -LiteralPath $tar -Force
|
||||
# bsdtar expands the upstream LF bytes, but Windows text tools used
|
||||
# during extraction must not decide the comparison's line endings.
|
||||
foreach ($file in Get-ChildItem -LiteralPath $verifyDir -Recurse -File) {
|
||||
if ($file.LinkType) { continue }
|
||||
$bytes = [IO.File]::ReadAllBytes($file.FullName)
|
||||
$text = [Text.Encoding]::UTF8.GetString($bytes)
|
||||
if ($text.Contains([char]0)) { continue }
|
||||
$lf = $text.Replace("`r`n", "`n")
|
||||
if ($lf -cne $text) {
|
||||
[IO.File]::WriteAllText($file.FullName, $lf, [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
}
|
||||
Invoke-Native 'git' @('-C', $verifyDir, '-c', 'user.name=verify', '-c', 'user.email=verify@local', 'add', '-A')
|
||||
Invoke-Native 'git' @('-C', $verifyDir, '-c', 'user.name=verify', '-c', 'user.email=verify@local', 'commit', '-q', '-m', 'base')
|
||||
Invoke-Native 'git' @('-C', $verifyDir, 'add', '--renormalize', '.')
|
||||
Invoke-Native 'git' @('-C', $verifyDir, '-c', 'user.name=verify', '-c', 'user.email=verify@local', 'commit', '-q', '--allow-empty', '-m', 'normalize-lf')
|
||||
foreach ($ps in $group) {
|
||||
$pf = Join-Path $patchesDir $ps.Name
|
||||
# .patch files may be checked out with CRLF on Windows. Keep the
|
||||
# authoritative file intact while comparing its LF representation
|
||||
# with a Git tree archived and indexed with LF line endings.
|
||||
$patchLf = Join-Path $TempRoot ("patch-lf-" + [guid]::NewGuid() + '.patch')
|
||||
$patchText = [IO.File]::ReadAllText($pf).Replace("`r`n", "`n")
|
||||
[IO.File]::WriteAllText($patchLf, $patchText, [Text.UTF8Encoding]::new($false))
|
||||
Invoke-GitApply $verifyDir $patchText -Check
|
||||
Invoke-GitApply $verifyDir $patchText
|
||||
Remove-Item -LiteralPath $patchLf -Force
|
||||
}
|
||||
$expectedDiff = ((& git -C $verifyDir -c core.autocrlf=false diff --full-index | Out-String).Replace("`r`n", "`n") -replace $indexMode, '$1').TrimEnd()
|
||||
if ($treeDiff -ne $expectedDiff) {
|
||||
$treeStat = (& git -C $repo diff --stat -- @paths | Out-String).Trim()
|
||||
$expStat = (& git -C $verifyDir diff --stat | Out-String).Trim()
|
||||
Write-Host "Build tree diff --stat:`n$treeStat"
|
||||
Write-Host "Expected patch stack diff --stat:`n$expStat"
|
||||
throw "Patch stack ($(($group | ForEach-Object { $_.Name }) -join ', ')) does not match the build tree's diff in $repo. Stop: don't edit patches automatically (AGENTS.md rule 4)."
|
||||
}
|
||||
# Also verify newly created (untracked) files added by patches byte-for-byte.
|
||||
$addedFiles = @(& git -C $verifyDir ls-files --others --exclude-standard | Where-Object { $_ })
|
||||
foreach ($rel in $addedFiles) {
|
||||
$expPath = Join-Path $verifyDir ($rel -replace '/', '\')
|
||||
$treePath = Join-Path $repo ($rel -replace '/', '\')
|
||||
if (-not (Test-Path -LiteralPath $treePath -PathType Leaf)) {
|
||||
throw "Patch stack expected new file $rel in $repo, but it is missing."
|
||||
}
|
||||
$expText = [IO.File]::ReadAllText($expPath).Replace("`r`n", "`n")
|
||||
$treeText = [IO.File]::ReadAllText($treePath).Replace("`r`n", "`n")
|
||||
if ($treeText -cne $expText) {
|
||||
throw "New file $rel in $repo does not match the declared patch stack. Stop: don't edit patches automatically (AGENTS.md rule 4)."
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (Test-Path -LiteralPath $verifyDir) { Remove-Item -Recurse -Force -LiteralPath $verifyDir }
|
||||
}
|
||||
}
|
||||
# Anything else changed in the build trees is undeclared: refuse.
|
||||
function Get-Undeclared([string]$repo, [string]$target, [string[]]$statusArgs) {
|
||||
$declared = @($patchSpecs | Where-Object { $_.Target -eq $target } | ForEach-Object { $_.Paths })
|
||||
@(& git -C $repo status --porcelain @statusArgs | Where-Object {
|
||||
$path = $_.Substring(3).Trim('"')
|
||||
$path -notin $declared
|
||||
})
|
||||
}
|
||||
$otherCtl = Get-Undeclared $ReimsRepo 'reims-vgpu' @('--ignore-submodules=all')
|
||||
$otherQemu = Get-Undeclared $qemuRepo 'vendor/qemu' @('--untracked-files=no')
|
||||
$utilStatusArgs = if ($UtilRepo) { '--untracked-files=all' } else { '--untracked-files=no' }
|
||||
$otherUtil = Get-Undeclared $utilTree 'reims-util' @($utilStatusArgs)
|
||||
$m2vStatusArgs = if ($Metal2VulkanRepo) { '--untracked-files=all' } else { '--untracked-files=no' }
|
||||
$otherM2v = Get-Undeclared $m2vTree 'metal2vulkan' @($m2vStatusArgs)
|
||||
if ($otherCtl.Count -or $otherQemu.Count -or $otherUtil.Count -or $otherM2v.Count) {
|
||||
throw "Undeclared changes in the build trees:`n$($otherCtl + $otherQemu + $otherUtil + $otherM2v -join "`n")"
|
||||
}
|
||||
|
||||
$bundleName = "reims-runtime-win-x64-$id"
|
||||
$srcName = "reims-runtime-src-$id"
|
||||
$symbolsName = "reims-runtime-symbols-$id"
|
||||
$stageRoot = Join-Path $TempRoot "pack-$id"
|
||||
$bundleDir = Join-Path $stageRoot $bundleName
|
||||
$srcDir = Join-Path $stageRoot $srcName
|
||||
if (Test-Path -LiteralPath $stageRoot) { Remove-Item -Recurse -Force -LiteralPath $stageRoot }
|
||||
New-Item -ItemType Directory -Force -Path "$bundleDir\bin", "$bundleDir\qemu", "$bundleDir\licenses", "$bundleDir\patches", $srcDir, $OutDir | Out-Null
|
||||
|
||||
# ── 3. Runtime bundle ────────────────────────────────────────
|
||||
Write-Host "==> Staging $bundleName ($Channel)"
|
||||
$resolvedQemu = (Get-Item -LiteralPath $QemuDir).Target
|
||||
if (-not $resolvedQemu) { $resolvedQemu = $QemuDir }
|
||||
$keyFiles = @(& (Join-Path $PSScriptRoot 'stage-runtime-binaries.ps1') -CargoBin $CargoBin -QemuDir $resolvedQemu `
|
||||
-BundleDir $bundleDir -SymbolsDir (Join-Path $stageRoot $symbolsName) -Objcopy (Join-Path $Msys2 'clang64/bin/llvm-objcopy.exe') | ForEach-Object { $_ })
|
||||
$expectedKeyFiles = @('bin/reims-ctl.exe', 'bin/reims-util.exe', 'qemu/bin/qemu-system-x86_64.exe',
|
||||
'qemu/bin/qemu-img.exe', 'qemu/bin/reims-vgpu-compile.exe')
|
||||
if ($keyFiles.Count -ne 5 -or (Compare-Object $expectedKeyFiles $keyFiles)) {
|
||||
$keyFiles | ForEach-Object { Write-Host "Unexpected stager output [$($_.GetType().FullName)]: $_" }
|
||||
throw 'Binary stager did not return exactly the five expected executable paths'
|
||||
}
|
||||
|
||||
Copy-Item -LiteralPath (Join-Path $repoRoot 'NOTICE.md') -Destination "$bundleDir\NOTICE.md"
|
||||
foreach ($ps in $patchSpecs) { Copy-Item -LiteralPath (Join-Path $patchesDir $ps.Name) -Destination "$bundleDir\patches\" }
|
||||
Copy-Item -LiteralPath (Join-Path $patchesDir 'README.md') -Destination "$bundleDir\patches\README.md"
|
||||
if (Test-Path -LiteralPath (Join-Path $patchesDir 'LICENSE')) {
|
||||
Copy-Item -LiteralPath (Join-Path $patchesDir 'LICENSE') -Destination "$bundleDir\patches\LICENSE"
|
||||
}
|
||||
# The order the patches above were applied in (only those really applied).
|
||||
Write-Utf8 "$bundleDir\patches\series.txt" ((($patchSpecs | ForEach-Object { '{0,-12} {1}' -f $_.Target, $_.Name }) -join "`n") + "`n")
|
||||
$licenses = @{
|
||||
'reims-vgpu-LICENSE.txt' = (Join-Path $ReimsRepo 'LICENSE')
|
||||
'qemu-COPYING.txt' = (Join-Path $qemuRepo 'COPYING')
|
||||
'qemu-COPYING.LIB.txt' = (Join-Path $qemuRepo 'COPYING.LIB')
|
||||
}
|
||||
foreach ($k in $licenses.Keys) {
|
||||
if (Test-Path -LiteralPath $licenses[$k]) { Copy-Item -LiteralPath $licenses[$k] -Destination (Join-Path "$bundleDir\licenses" $k) }
|
||||
}
|
||||
if (Test-Path -LiteralPath (Join-Path $ReimsRepo 'LICENSES')) {
|
||||
Copy-Item -Path (Join-Path $ReimsRepo 'LICENSES\*') -Destination "$bundleDir\licenses\" -Recurse -Force
|
||||
}
|
||||
|
||||
# MSYS2 CLANG64 DLLs: owning package and version, and where its source is.
|
||||
Write-Host '==> Listing MSYS2 packages of bundled DLLs'
|
||||
$bash = Join-Path $Msys2 'usr\bin\bash.exe'
|
||||
$dlls = @(Get-ChildItem -LiteralPath "$bundleDir\qemu\bin" -Filter '*.dll' -File | Sort-Object Name)
|
||||
$metadataScript = (Join-Path $PSScriptRoot 'read-msys2-package-metadata.sh').Replace('\', '/')
|
||||
$dllPaths = @($dlls | ForEach-Object { "/clang64/bin/$($_.Name)" })
|
||||
$expectedPaths = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal)
|
||||
foreach ($path in $dllPaths) { [void]$expectedPaths.Add($path) }
|
||||
$rows = @(& $bash -lc 'script=$1; shift; source "$script"' -- $metadataScript @dllPaths)
|
||||
if ($LASTEXITCODE -ne 0) { throw "MSYS2 package metadata lookup failed ($LASTEXITCODE)" }
|
||||
$owners = @{}
|
||||
$licensesByPackage = @{}
|
||||
foreach ($row in $rows) {
|
||||
$type, $key, $value, $version = $row -split "`t", 4
|
||||
switch ($type) {
|
||||
'owned' {
|
||||
if (!$expectedPaths.Remove($key) -or !$value -or !$version) {
|
||||
throw "Unexpected MSYS2 ownership row: $row"
|
||||
}
|
||||
$owners[$key] = [pscustomobject]@{ Package = $value; Version = $version }
|
||||
}
|
||||
'unowned' {
|
||||
if (!$expectedPaths.Remove($key) -or $value) {
|
||||
throw "Unexpected MSYS2 ownership row: $row"
|
||||
}
|
||||
}
|
||||
'license' {
|
||||
if (!$key -or !$value -or !$value.StartsWith('/clang64/share/licenses/', [StringComparison]::Ordinal) -or $version) {
|
||||
throw "Unexpected MSYS2 license row: $row"
|
||||
}
|
||||
if (!$licensesByPackage.ContainsKey($key)) {
|
||||
$licensesByPackage[$key] = [Collections.Generic.List[string]]::new()
|
||||
}
|
||||
$licensesByPackage[$key].Add($value)
|
||||
}
|
||||
default { throw "Unexpected MSYS2 package metadata row: $row" }
|
||||
}
|
||||
}
|
||||
if ($expectedPaths.Count -ne 0) { throw "MSYS2 ownership lookup did not answer for $($expectedPaths -join ', ')" }
|
||||
|
||||
$pkgLines = [Collections.Generic.List[string]]::new()
|
||||
$pkgSet = [ordered]@{}
|
||||
$pkgNames = [ordered]@{}
|
||||
foreach ($d in $dlls) {
|
||||
$owner = $owners["/clang64/bin/$($d.Name)"]
|
||||
if ($owner) {
|
||||
$pkgLines.Add("$($d.Name)`t$($owner.Package)`t$($owner.Version)")
|
||||
$pkgSet["$($owner.Package) $($owner.Version)"] = $true
|
||||
$pkgNames[$owner.Package] = $true
|
||||
} else {
|
||||
$pkgLines.Add("$($d.Name)`t(not from an MSYS2 package: built with qemu, source in the source package)`t-")
|
||||
}
|
||||
}
|
||||
# Bundle each MSYS2 package's installed license texts under licenses/msys2/.
|
||||
$msysLicRoot = Join-Path $bundleDir 'licenses\msys2'
|
||||
foreach ($owner in $pkgNames.Keys) {
|
||||
$licFiles = $licensesByPackage[$owner]
|
||||
foreach ($lf in $licFiles) {
|
||||
$rel = $lf.Substring('/clang64/share/licenses/'.Length)
|
||||
$srcFile = Join-Path $Msys2 ($lf.TrimStart('/') -replace '/', '\')
|
||||
if (Test-Path -LiteralPath $srcFile -PathType Leaf) {
|
||||
$dstFile = Join-Path $msysLicRoot ($rel -replace '/', '\')
|
||||
[void][IO.Directory]::CreateDirectory((Split-Path -Parent $dstFile))
|
||||
Copy-Item -LiteralPath $srcFile -Destination $dstFile -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
$msysText = @"
|
||||
# DLLs bundled in qemu/bin and the MSYS2 CLANG64 packages they come from
|
||||
# (pacman -Qo on the build machine, $(Get-Date -Format 'yyyy-MM-dd')).
|
||||
#
|
||||
# Sources: every package whose licence requires source (GPL / LGPL / MPL) is in
|
||||
# reims-runtime-msys2-src-$id.tar.zst, published beside this runtime.
|
||||
# The same files are also at:
|
||||
# https://repo.msys2.org/mingw/sources/ (<package>-<version>.src.tar.zst, by pkgbase)
|
||||
# https://github.com/msys2/MINGW-packages (build recipes)
|
||||
# Licenses: bundled under licenses/msys2/ from each package's /clang64/share/licenses/ in MSYS2.
|
||||
|
||||
DLL`tPACKAGE`tVERSION
|
||||
$($pkgLines -join "`n")
|
||||
|
||||
# Packages ($($pkgSet.Count))
|
||||
$($pkgSet.Keys -join "`n")
|
||||
"@
|
||||
Write-Utf8 "$bundleDir\MSYS2-PACKAGES.txt" $msysText
|
||||
|
||||
# ── 4. Source bundle ─────────────────────────────────────────
|
||||
Write-Host "==> Staging $srcName"
|
||||
function Export-GitTree([string]$repo, [string]$rev, [string]$dest) {
|
||||
New-Item -ItemType Directory -Force -Path $dest | Out-Null
|
||||
$tar = Join-Path $TempRoot ("git-export-" + [guid]::NewGuid() + '.tar')
|
||||
Invoke-Native 'git' @('-C', $repo, 'archive', '--format=tar', '-o', $tar, $rev)
|
||||
Invoke-Native 'tar.exe' @('-xf', $tar, '-C', $dest)
|
||||
Remove-Item -LiteralPath $tar -Force
|
||||
}
|
||||
Export-GitTree $ReimsRepo $fullCommit (Join-Path $srcDir "reims-vgpu-$commit")
|
||||
Export-GitTree $qemuRepo $qemuCommit (Join-Path $srcDir "reims-vgpu-$commit\vendor\qemu")
|
||||
# QEMU's meson wraps downloaded for this build (dtc, keycodemapdb, ...): part of what was built.
|
||||
Get-ChildItem -LiteralPath (Join-Path $qemuRepo 'subprojects') -Directory |
|
||||
Where-Object { $_.Name -ne 'packagecache' -and -not (Test-Path -LiteralPath (Join-Path $srcDir "reims-vgpu-$commit\vendor\qemu\subprojects\$($_.Name)")) } |
|
||||
ForEach-Object { Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $srcDir "reims-vgpu-$commit\vendor\qemu\subprojects\") -Recurse -Force }
|
||||
|
||||
Export-GitTree $utilTree $utilCommit (Join-Path $srcDir "reims-util-$($utilCommit.Substring(0, 7))")
|
||||
Export-GitTree $m2vTree $m2vCommit (Join-Path $srcDir "metal2vulkan-$($m2vCommit.Substring(0, 7))")
|
||||
foreach ($extra in @(
|
||||
@{ Name = 'reims-util'; Tree = $utilTree },
|
||||
@{ Name = 'metal2vulkan'; Tree = $m2vTree }
|
||||
)) {
|
||||
foreach ($lf in @('LICENSE', 'LICENSE.txt', 'LICENSE.md', 'COPYING', 'COPYING.LIB')) {
|
||||
$srcLic = Join-Path $extra.Tree $lf
|
||||
if (Test-Path -LiteralPath $srcLic -PathType Leaf) {
|
||||
Copy-Item -LiteralPath $srcLic -Destination (Join-Path "$bundleDir\licenses" "$($extra.Name)-$lf") -Force
|
||||
}
|
||||
}
|
||||
if (Test-Path -LiteralPath (Join-Path $extra.Tree 'LICENSES') -PathType Container) {
|
||||
Copy-Item -Path (Join-Path $extra.Tree 'LICENSES\*') -Destination "$bundleDir\licenses\" -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path "$srcDir\patches" | Out-Null
|
||||
foreach ($ps in $patchSpecs) {
|
||||
Copy-Item -LiteralPath (Join-Path "$bundleDir\patches" $ps.Name) -Destination "$srcDir\patches\"
|
||||
}
|
||||
Copy-Item -LiteralPath "$bundleDir\MSYS2-PACKAGES.txt" -Destination "$srcDir\MSYS2-PACKAGES.txt"
|
||||
Copy-Item -LiteralPath "$bundleDir\NOTICE.md" -Destination "$srcDir\NOTICE.md"
|
||||
$m2vBuildSteps = if ($byTarget.Contains('metal2vulkan')) {
|
||||
$m2vDir = "metal2vulkan-$($m2vCommit.Substring(0, 7))"
|
||||
$m2vApply = ($byTarget['metal2vulkan'] | ForEach-Object { " git -C $m2vDir apply `"`$(pwd)/patches/$($_.Name)`"" }) -join "`n"
|
||||
@"
|
||||
|
||||
Before running ``scripts/install-ctl.sh``, apply the ``metal2vulkan`` patches
|
||||
and point Cargo at the patched checkout via ```$CARGO_HOME/config.toml``:
|
||||
|
||||
$m2vApply
|
||||
cat >> "`${CARGO_HOME:-`$HOME/.cargo}/config.toml" <<EOF
|
||||
[patch."$($pins.Metal.Url)"]
|
||||
metal2vulkan = { path = "`$(cygpath -m "`$(pwd)/$m2vDir")/crates/metal2vulkan" }
|
||||
metal2vulkan-runtime = { path = "`$(cygpath -m "`$(pwd)/$m2vDir")/crates/metal2vulkan-runtime" }
|
||||
EOF
|
||||
|
||||
"@
|
||||
}
|
||||
$utilBuildSteps = if ($byTarget.Contains('reims-util')) {
|
||||
$utilDir = "reims-util-$($utilCommit.Substring(0, 7))"
|
||||
$utilApply = ($byTarget['reims-util'] | ForEach-Object { " git -C $utilDir apply `"`$(pwd)/patches/$($_.Name)`"" }) -join "`n"
|
||||
@"
|
||||
|
||||
After the upstream build, run these commands from the extracted source
|
||||
archive's root in the same MSYS2 CLANG64 shell. They apply the reims-util
|
||||
patches and replace the stock reims-util executable with this build:
|
||||
|
||||
$utilApply
|
||||
cd reims-vgpu-$commit
|
||||
toolchain=`$(sed -n 's/^channel *= *"\([^"]*\)".*/\1/p' rust-toolchain.toml)
|
||||
CC=clang CXX=clang++ AR=llvm-ar cargo +"`$toolchain-x86_64-pc-windows-gnullvm" install --locked --force --path ../$utilDir
|
||||
|
||||
"@
|
||||
}
|
||||
$applyRuntimePatches = @(
|
||||
foreach ($ps in $patchSpecs) {
|
||||
switch ($ps.Target) {
|
||||
'reims-vgpu' { " git -C reims-vgpu-$commit apply ../patches/$($ps.Name)" }
|
||||
'vendor/qemu' { " git -C reims-vgpu-$commit/vendor/qemu apply ../../../patches/$($ps.Name)" }
|
||||
}
|
||||
}
|
||||
)
|
||||
Write-Utf8 "$srcDir\README.md" @"
|
||||
# Source for $bundleName
|
||||
|
||||
Corresponding source for the binaries in ``$bundleName.tar.zst``.
|
||||
|
||||
| Directory | Source repository | Commit |
|
||||
| :-- | :-- | :-- |
|
||||
| ``reims-vgpu-$commit/`` | $reimsSource | ``$fullCommit`` |
|
||||
| ``reims-vgpu-$commit/vendor/qemu/`` | $qemuSource | ``$qemuCommit`` |
|
||||
| ``reims-util-$($utilCommit.Substring(0, 7))/`` | $($pins.Util.Url) | ``$utilCommit`` |
|
||||
| ``metal2vulkan-$($m2vCommit.Substring(0, 7))/`` | $($pins.Metal.Url) | ``$m2vCommit`` |
|
||||
|
||||
$(
|
||||
if ($applyRuntimePatches) {
|
||||
"Apply the runtime patches from the archive root.`n`n" + ($applyRuntimePatches -join "`n")
|
||||
}
|
||||
)
|
||||
|
||||
$m2vBuildSteps
|
||||
From ``reims-vgpu-$commit/``, run ``scripts/install-ctl.sh``
|
||||
in an MSYS2 CLANG64 shell. The DLLs in ``qemu/bin`` come from the MSYS2
|
||||
packages listed in ``MSYS2-PACKAGES.txt``, with links to their sources.
|
||||
$utilBuildSteps
|
||||
"@
|
||||
|
||||
# ── 5. Manifest (schema 2) ───────────────────────────────────
|
||||
$hashes = [ordered]@{}
|
||||
foreach ($rel in $keyFiles) {
|
||||
$fp = Join-Path $bundleDir ($rel -replace '/', '\')
|
||||
$hashes[$rel] = Get-Sha256 $fp
|
||||
}
|
||||
$manifest = [ordered]@{
|
||||
schema_version = 2
|
||||
name = $bundleName
|
||||
platform = 'windows-x86_64'
|
||||
upstream_repo = $reimsSource
|
||||
commit = $id
|
||||
full_commit = $fullCommit
|
||||
vendor_qemu_repo = $qemuSource
|
||||
vendor_qemu_commit = $qemuCommit
|
||||
util_repo = $pins.Util.Url
|
||||
util_commit = $utilCommit
|
||||
metal2vulkan_repo = $pins.Metal.Url
|
||||
metal2vulkan_commit = $m2vCommit
|
||||
patches = $patchEntries
|
||||
capabilities = $capabilities
|
||||
channel = $Channel
|
||||
source_package = "$srcName.tar.zst"
|
||||
qemu_version = $qemuVersionLine
|
||||
util_version = $utilVersionLine
|
||||
built_at = (Get-Date).ToString('o')
|
||||
file_count = (Get-ChildItem -LiteralPath $bundleDir -Recurse -File).Count + 1
|
||||
dll_count = $dlls.Count
|
||||
raw_bytes = [int64]((Get-ChildItem -LiteralPath $bundleDir -Recurse -File | Measure-Object Length -Sum).Sum) # Add the manifest's own size after writing it below.
|
||||
sha256 = $hashes
|
||||
}
|
||||
if (-not $SkipSymbols) { $manifest['symbols_package'] = "$symbolsName.tar.zst" }
|
||||
if ($SuspendCompatID) { $manifest['suspend_compat_id'] = $SuspendCompatID }
|
||||
if ($PackagingCommit) { $manifest['packaging_commit'] = $PackagingCommit }
|
||||
Write-Utf8 "$bundleDir\manifest.json" ($manifest | ConvertTo-Json -Depth 5)
|
||||
$manifest.raw_bytes += (Get-Item -LiteralPath "$bundleDir\manifest.json").Length
|
||||
Write-Utf8 "$bundleDir\manifest.json" ($manifest | ConvertTo-Json -Depth 5)
|
||||
|
||||
# ── 6. Archives and sums ─────────────────────────────────────
|
||||
$zstd = Resolve-Zstd -Msys2 $Msys2
|
||||
Write-Host '==> Compressing runtime'
|
||||
$runtimeArchive = Join-Path $OutDir "$bundleName.tar.zst"
|
||||
New-TarZst $stageRoot $bundleName $runtimeArchive
|
||||
Write-Host '==> Compressing sources'
|
||||
$srcArchive = Join-Path $OutDir "$srcName.tar.zst"
|
||||
New-TarZst $stageRoot $srcName $srcArchive
|
||||
|
||||
$rtHash = Get-Sha256 $runtimeArchive
|
||||
$srcHash = Get-Sha256 $srcArchive
|
||||
Write-Utf8 "$runtimeArchive.sha256" "$rtHash $bundleName.tar.zst`n"
|
||||
$sumsLines = @(
|
||||
"$rtHash $bundleName.tar.zst"
|
||||
"$srcHash $srcName.tar.zst"
|
||||
)
|
||||
if (-not $SkipSymbols) {
|
||||
$symbolsArchive = Join-Path $OutDir "$symbolsName.tar.zst"
|
||||
New-TarZst $stageRoot $symbolsName $symbolsArchive
|
||||
$sumsLines += "$(Get-Sha256 $symbolsArchive) $symbolsName.tar.zst"
|
||||
}
|
||||
Write-Utf8 (Join-Path $OutDir 'SHA256SUMS.txt') (($sumsLines -join "`n") + "`n")
|
||||
|
||||
# Sources of the copyleft MSYS2 packages, as their own asset (adds a line to SHA256SUMS.txt).
|
||||
if (-not $SkipMsys2Sources) {
|
||||
& (Join-Path $PSScriptRoot 'pack-msys2-sources.ps1') -PackagesFile (Join-Path $bundleDir 'MSYS2-PACKAGES.txt') -Commit $id -OutDir $OutDir -Msys2 $Msys2 -TempRoot $TempRoot
|
||||
}
|
||||
|
||||
Remove-Item -Recurse -Force -LiteralPath $stageRoot
|
||||
|
||||
Write-Host ''
|
||||
Write-Host '==> Done' -ForegroundColor Green
|
||||
'{0,-10} {1} {2:N1} MB' -f 'runtime', $runtimeArchive, ((Get-Item $runtimeArchive).Length / 1MB)
|
||||
'{0,-10} {1} {2:N1} MB' -f 'source', $srcArchive, ((Get-Item $srcArchive).Length / 1MB)
|
||||
"channel $Channel; patches: $(($patchEntries | ForEach-Object { $_.name }) -join ', '); DLLs: $($dlls.Count)"
|
||||
@@ -1,141 +0,0 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$RuntimeRepo,
|
||||
[Parameter(Mandatory)][ValidatePattern('^[0-9a-f]{40}$')][string]$RuntimeCommit,
|
||||
[Parameter(Mandatory)][string]$PackagingRepo,
|
||||
[Parameter(Mandatory)][ValidatePattern('^[0-9a-f]{40}$')][string]$PackagingCommit,
|
||||
[Parameter(Mandatory)][string]$Repository,
|
||||
[switch]$Rebuild,
|
||||
[switch]$PackagingPush
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tagPattern = '^runtime-(?<base>[0-9a-f]{7,40})(?:-p(?<revision>[1-9][0-9]*))?$'
|
||||
|
||||
function Invoke-VersionCommand([string]$command, [string[]]$argv) {
|
||||
$result = & $command @argv
|
||||
if ($LASTEXITCODE -ne 0) { throw "$command $($argv -join ' ') failed ($LASTEXITCODE)" }
|
||||
return $result
|
||||
}
|
||||
|
||||
function Test-InputsChanged([string]$Repo, [string]$From, [string]$To, [string[]]$Paths) {
|
||||
& git -C $Repo diff --quiet $From $To -- @Paths
|
||||
if ($LASTEXITCODE -gt 1) { throw "Could not compare suspend inputs from $From to $To" }
|
||||
return $LASTEXITCODE -eq 1
|
||||
}
|
||||
|
||||
function New-VersionPlan([string]$ReleaseId, [string]$Family, [string]$Evidence = '', [string]$Predecessor = '') {
|
||||
return [pscustomobject]@{
|
||||
Skip = $false
|
||||
ReleaseId = $ReleaseId
|
||||
SuspendCompatID = $Family
|
||||
Evidence = $Evidence
|
||||
Predecessor = $Predecessor
|
||||
}
|
||||
}
|
||||
|
||||
$remoteTags = @{}
|
||||
foreach ($line in (Invoke-VersionCommand git @('-C', $RuntimeRepo, 'ls-remote', '--tags', 'origin', 'refs/tags/runtime-*'))) {
|
||||
if ($line -match '^(?<sha>[0-9a-f]{40})\s+refs/tags/(?<tag>runtime-[^\s^]+)(?<peeled>\^\{\})?$') {
|
||||
if ($Matches.peeled -or !$remoteTags.ContainsKey($Matches.tag)) {
|
||||
$remoteTags[$Matches.tag] = $Matches.sha
|
||||
}
|
||||
}
|
||||
}
|
||||
$pages = (Invoke-VersionCommand gh @('api', '--paginate', '--slurp', "repos/$Repository/releases?per_page=100")) -join "`n"
|
||||
$releasePages = $pages | ConvertFrom-Json -NoEnumerate
|
||||
$published = @(foreach ($page in $releasePages) {
|
||||
foreach ($release in $page) {
|
||||
if ($release.draft -or $release.tag_name -notmatch $tagPattern) { continue }
|
||||
$family = $Matches.base
|
||||
$revision = if ($Matches.revision) { [int]$Matches.revision } else { 0 }
|
||||
$tag = $release.tag_name
|
||||
if (!$remoteTags.ContainsKey($tag)) { throw "Published runtime tag $tag was not found in Git" }
|
||||
$packaging = if ($release.body -match '(?m)^Packaging commit: `([0-9a-f]{40})`\s*$') { $Matches[1] } else { '' }
|
||||
$verifiedFamily = if ($release.body -match '(?m)^Suspend compatibility ID: `([0-9a-f]{7,40})`\s*$') { $Matches[1] } else { '' }
|
||||
[pscustomobject]@{
|
||||
Tag = $tag
|
||||
RuntimeCommit = $remoteTags[$tag]
|
||||
Packaging = $packaging
|
||||
Family = $family
|
||||
Revision = $revision
|
||||
VerifiedFamily = $verifiedFamily
|
||||
PublishedAt = [DateTimeOffset]$release.published_at
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$sameRuntime = @($published | Where-Object RuntimeCommit -eq $RuntimeCommit)
|
||||
if ($sameRuntime.Count -and (!$Rebuild -or ($PackagingPush -and ($sameRuntime | Where-Object Packaging -eq $PackagingCommit)))) {
|
||||
Write-Host "Skipping the already published runtime $RuntimeCommit."
|
||||
return [pscustomobject]@{ Skip = $true }
|
||||
}
|
||||
|
||||
# The verification belongs to the changed commit and names its exact other input.
|
||||
$approvalRepo = if ($PackagingPush -or $Rebuild) { $PackagingRepo } else { $RuntimeRepo }
|
||||
$approvalCommit = if ($PackagingPush -or $Rebuild) { $PackagingCommit } else { $RuntimeCommit }
|
||||
$otherInput = if ($PackagingPush -or $Rebuild) { $RuntimeCommit } else { $PackagingCommit }
|
||||
$message = (Invoke-VersionCommand git @('-C', $approvalRepo, 'show', '-s', '--format=%B', $approvalCommit)) -join "`n"
|
||||
$trailers = $message | git interpret-trailers --parse
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not read suspend compatibility trailers' }
|
||||
$approval = @{}
|
||||
foreach ($line in $trailers) {
|
||||
if ($line -match '^(Suspend-Compatible-With|Suspend-Verified-Inputs|Suspend-Verification):\s+(.+)$') {
|
||||
if ($approval.ContainsKey($Matches[1])) { throw "Repeated compatibility trailer: $($Matches[1])" }
|
||||
$approval[$Matches[1]] = $Matches[2].Trim()
|
||||
}
|
||||
}
|
||||
|
||||
if ($approval.Count) {
|
||||
$previous = $published | Where-Object Tag -eq $approval['Suspend-Compatible-With']
|
||||
$evidence = $approval['Suspend-Verification']
|
||||
if (!$previous -or !$previous.Packaging -or $previous.VerifiedFamily -ne $previous.Family -or
|
||||
$approval['Suspend-Verified-Inputs'] -ne $otherInput -or $evidence -notmatch '^https://[^\s<>]+$') {
|
||||
Write-Warning 'Compatibility evidence does not match these inputs and a published compatibility baseline.'
|
||||
} else {
|
||||
$latest = $published | Sort-Object PublishedAt, Revision -Descending | Select-Object -First 1
|
||||
$familyTip = $published | Where-Object Family -eq $previous.Family | Sort-Object Revision -Descending | Select-Object -First 1
|
||||
& git -C $RuntimeRepo merge-base --is-ancestor $previous.RuntimeCommit $RuntimeCommit
|
||||
if ($LASTEXITCODE -gt 1) { throw 'Could not verify the runtime baseline ancestry' }
|
||||
$ancestor = $LASTEXITCODE -eq 0
|
||||
|
||||
# Direct changes to these inputs require a fresh family even with a trailer.
|
||||
$runtimePaths = @(
|
||||
'vendor/qemu', 'guest', 'firmware', ':(glob)crates/reims-vgpu*/**',
|
||||
'.cargo', 'Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml', 'reims-go-runtime.json',
|
||||
'scripts/install-ctl.sh', 'scripts/install.ps1',
|
||||
'crates/reims-ctl/Cargo.toml', 'crates/reims-ctl/Cargo.lock',
|
||||
'crates/reims-ctl/src/qemu.rs', 'crates/reims-ctl/src/runtime.rs',
|
||||
'crates/reims-ctl/src/main.rs', 'crates/reims-ctl/src/cli.rs', 'crates/reims-ctl/src/vm.rs',
|
||||
'crates/reims-ctl/src/opencore.rs', 'crates/reims-ctl/src/reims_util.rs',
|
||||
'crates/reims-ctl/src/host.rs', 'crates/reims-ctl/src/os'
|
||||
)
|
||||
$packagingPaths = @(
|
||||
':(glob)packaging/windows-runtime/patches/*.patch',
|
||||
'packaging/windows-runtime/patches/series.txt',
|
||||
'packaging/windows-runtime/scripts/apply-patch-series.ps1'
|
||||
)
|
||||
if ($ancestor -and $previous.Tag -eq $latest.Tag -and $previous.Tag -eq $familyTip.Tag) {
|
||||
& git -C $PackagingRepo cat-file -e "$($previous.Packaging)^{commit}" 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Invoke-VersionCommand git @('-C', $PackagingRepo, 'fetch', '-q', '--no-tags', 'origin', $previous.Packaging)
|
||||
}
|
||||
$runtimeChange = Test-InputsChanged $RuntimeRepo $previous.RuntimeCommit $RuntimeCommit $runtimePaths
|
||||
$packagingChange = Test-InputsChanged $PackagingRepo $previous.Packaging $PackagingCommit $packagingPaths
|
||||
if (!$runtimeChange -and !$packagingChange) {
|
||||
$id = "$($previous.Family)-p$($familyTip.Revision + 1)"
|
||||
if ($remoteTags.ContainsKey("runtime-$id")) { throw "Runtime tag runtime-$id is already reserved" }
|
||||
return New-VersionPlan $id $previous.Family $evidence $previous.Tag
|
||||
}
|
||||
Write-Warning 'Suspend inputs changed. A new runtime family is required.'
|
||||
} else {
|
||||
Write-Warning 'The verification must cover the latest published runtime and its highest family revision.'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$base = (Invoke-VersionCommand git @('-C', $RuntimeRepo, 'rev-parse', '--short=7', $RuntimeCommit)).Trim()
|
||||
if ($sameRuntime.Count -or $remoteTags.ContainsKey("runtime-$base")) {
|
||||
throw 'A new runtime baseline commit is required, or record verified compatibility for these exact build inputs.'
|
||||
}
|
||||
return New-VersionPlan $base $base
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pacman's ownership query returns the owner and installed version together.
|
||||
set -euo pipefail
|
||||
export LC_ALL=C
|
||||
if (($# == 0)); then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
status=0
|
||||
ownership=$(pacman -Qo -- "$@" 2>&1) || status=$?
|
||||
owned='^(/clang64/bin/.+) is owned by ([^[:space:]]+) ([^[:space:]]+)$'
|
||||
unowned='^error: No package owns (/clang64/bin/.+)$'
|
||||
declare -A seen=()
|
||||
packages=()
|
||||
missing=0
|
||||
while IFS= read -r line; do
|
||||
if [[ $line =~ $owned ]]; then
|
||||
path=${BASH_REMATCH[1]}
|
||||
package=${BASH_REMATCH[2]}
|
||||
version=${BASH_REMATCH[3]}
|
||||
printf 'owned\t%s\t%s\t%s\n' "$path" "$package" "$version"
|
||||
if [[ -z ${seen[$package]+yes} ]]; then
|
||||
seen[$package]=1
|
||||
packages+=("$package")
|
||||
fi
|
||||
elif [[ $line =~ $unowned ]]; then
|
||||
printf 'unowned\t%s\n' "${BASH_REMATCH[1]}"
|
||||
((missing += 1))
|
||||
else
|
||||
printf 'Unexpected pacman ownership response: %s\n' "$line" >&2
|
||||
exit 1
|
||||
fi
|
||||
done <<< "$ownership"
|
||||
if ((status != missing % 256)); then
|
||||
printf 'pacman ownership query exited with %d for %d unowned files\n' "$status" "$missing" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ((${#packages[@]})); then
|
||||
pacman -Ql -- "${packages[@]}" | awk '
|
||||
{
|
||||
package = $1
|
||||
sub(/^[^[:space:]]+[[:space:]]+/, "")
|
||||
if ($0 ~ /^\/clang64\/share\/licenses\/.+/ && $0 !~ /\/$/)
|
||||
printf "license\t%s\t%s\n", package, $0
|
||||
}
|
||||
'
|
||||
fi
|
||||
@@ -1,31 +0,0 @@
|
||||
param([Parameter(Mandatory)][string]$RuntimeRepo)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$githubUrl = 'https://github\.com/[\w.-]+/[\w.-]+'
|
||||
$util = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'crates/reims-ctl/src/reims_util.rs')
|
||||
$utilUrl = [regex]::Match($util, "pub const REPO: &str = ""($githubUrl)"";").Groups[1].Value
|
||||
$utilRev = [regex]::Match($util, 'pub const REV: &str = "([0-9a-f]{40})";').Groups[1].Value
|
||||
if (-not $utilUrl -or -not $utilRev) { throw 'reims-util REPO or REV is missing from reims_util.rs' }
|
||||
|
||||
$cargo = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'Cargo.toml')
|
||||
$metal = foreach ($name in 'metal2vulkan', 'metal2vulkan-runtime') {
|
||||
$entry = [regex]::Match($cargo, "(?m)^$name\s*=\s*\{([^}]+)\}").Groups[1].Value
|
||||
$url = [regex]::Match($entry, "git\s*=\s*""($githubUrl)""").Groups[1].Value
|
||||
if (-not $url) { throw "$name git URL is missing from Cargo.toml" }
|
||||
$rev = [regex]::Match($entry, 'rev\s*=\s*"([0-9a-f]{40})"').Groups[1].Value
|
||||
if (-not $rev) {
|
||||
$lock = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'Cargo.lock')
|
||||
$pin = '(?m)^source = "git\+' + [regex]::Escape($url) + '\?rev=([0-9a-f]{40})#[0-9a-f]{40}"'
|
||||
$rev = [regex]::Match($lock, $pin).Groups[1].Value
|
||||
}
|
||||
if (-not $rev) { throw "$name revision is missing from Cargo.toml and Cargo.lock" }
|
||||
[pscustomobject]@{ Url = $url; Rev = $rev }
|
||||
}
|
||||
if ($metal[0].Url -cne $metal[1].Url -or $metal[0].Rev -cne $metal[1].Rev) {
|
||||
throw 'metal2vulkan and metal2vulkan-runtime must use the same repository and commit'
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
Util = [pscustomobject]@{ Url = $utilUrl; Rev = $utilRev }
|
||||
Metal = $metal[0]
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
function Resolve-Zstd([string]$Msys2) {
|
||||
$candidates = @(
|
||||
Get-Command zstd.exe -CommandType Application -All -ErrorAction SilentlyContinue |
|
||||
Select-Object -ExpandProperty Source
|
||||
Join-Path $Msys2 'usr\bin\zstd.exe'
|
||||
Join-Path $Msys2 'clang64\bin\zstd.exe'
|
||||
)
|
||||
$failures = @()
|
||||
|
||||
foreach ($candidate in ($candidates | Select-Object -Unique)) {
|
||||
if (-not (Test-Path -LiteralPath $candidate -PathType Leaf)) { continue }
|
||||
|
||||
# A binary can exist but fail to load its DLLs outside the MSYS2 shell.
|
||||
try {
|
||||
& $candidate --version *> $null
|
||||
if ($LASTEXITCODE -eq 0) { return $candidate }
|
||||
$failures += "$candidate (exit $LASTEXITCODE)"
|
||||
} catch {
|
||||
$failures += "$candidate ($($_.Exception.Message))"
|
||||
}
|
||||
}
|
||||
|
||||
if ($failures.Count) { throw "Could not run zstd.exe: $($failures -join '; ')" }
|
||||
throw "zstd.exe not found on PATH or in MSYS2 at $Msys2"
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Real-host smoke test for an alpha portable reims-vgpu runtime archive.
|
||||
|
||||
.DESCRIPTION
|
||||
Implements docs/portable-runtime-spec.md section 6 (alpha -> stable gate):
|
||||
1. Verifies SHA256 against SHA256SUMS.txt (when provided).
|
||||
2. Extracts the runtime into an isolated directory under -TempRoot (never C:).
|
||||
3. Verifies manifest.json provenance, NOTICE.md, licenses/, and core binaries.
|
||||
4. Runs `reims-ctl doctor` and `reims-ctl list --json` in a clean environment
|
||||
stripped of MSYS2 / Cargo paths to prove true portability.
|
||||
5. Writes a Markdown report for human review before promoting to `stable`.
|
||||
|
||||
.EXAMPLE
|
||||
powershell -ExecutionPolicy Bypass -File scripts/smoke-runtime.ps1 `
|
||||
-ArchivePath D:\Data\reims-go\releases\reims-runtime-win-x64-3731afd.tar.zst `
|
||||
-Sha256File D:\Data\reims-go\releases\SHA256SUMS.txt
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ArchivePath,
|
||||
[string]$Sha256File = '',
|
||||
[string]$TempRoot = 'D:\Build\Temp',
|
||||
[string]$ReportOut = ''
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $ArchivePath)) {
|
||||
throw "Archive not found: $ArchivePath"
|
||||
}
|
||||
|
||||
$archiveFile = Get-Item -LiteralPath $ArchivePath
|
||||
$actualHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $ArchivePath).Hash.ToLowerInvariant()
|
||||
$hashStatus = 'skipped (no -Sha256File provided)'
|
||||
if ($Sha256File -ne '') {
|
||||
if (-not (Test-Path -LiteralPath $Sha256File)) {
|
||||
throw "SHA256SUMS file not found: $Sha256File"
|
||||
}
|
||||
$matched = $false
|
||||
foreach ($line in (Get-Content -LiteralPath $Sha256File)) {
|
||||
if ($line -match '^([0-9a-fA-F]{64})\s+\*?(.+)$') {
|
||||
$h = $Matches[1].ToLowerInvariant()
|
||||
$n = $Matches[2].Trim()
|
||||
if ($n -eq $archiveFile.Name) {
|
||||
if ($h -ne $actualHash) {
|
||||
throw "SHA256 mismatch for $($archiveFile.Name): expected $h, got $actualHash"
|
||||
}
|
||||
$matched = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (-not $matched) {
|
||||
throw "Entry for $($archiveFile.Name) not found in $Sha256File"
|
||||
}
|
||||
$hashStatus = "PASS ($actualHash)"
|
||||
}
|
||||
|
||||
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||
$smokeDir = Join-Path $TempRoot "smoke-$stamp"
|
||||
$extractDir = Join-Path $smokeDir 'runtime'
|
||||
$dataDir = Join-Path $smokeDir 'data'
|
||||
New-Item -ItemType Directory -Force -Path $extractDir, $dataDir | Out-Null
|
||||
|
||||
function Resolve-Zstd {
|
||||
@(
|
||||
(Get-Command zstd.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source),
|
||||
'D:\DevTools\msys64\usr\bin\zstd.exe',
|
||||
'C:\msys64\usr\bin\zstd.exe'
|
||||
) | Where-Object { $_ -and (Test-Path -LiteralPath $_) } | Select-Object -First 1
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host "[1/5] Extracting $($archiveFile.Name) into $extractDir..."
|
||||
if ($archiveFile.Name.EndsWith('.tar.zst')) {
|
||||
$zstd = Resolve-Zstd
|
||||
if (-not $zstd) { throw 'zstd.exe not found to extract .tar.zst' }
|
||||
$tarPath = Join-Path $smokeDir 'runtime.tar'
|
||||
& $zstd -d -f -q $ArchivePath -o $tarPath
|
||||
if ($LASTEXITCODE -ne 0) { throw "zstd decompress failed ($LASTEXITCODE)" }
|
||||
& tar.exe -xf $tarPath -C $extractDir
|
||||
if ($LASTEXITCODE -ne 0) { throw "tar extract failed ($LASTEXITCODE)" }
|
||||
Remove-Item -LiteralPath $tarPath -Force
|
||||
} elseif ($archiveFile.Name.EndsWith('.zip')) {
|
||||
Expand-Archive -LiteralPath $ArchivePath -DestinationPath $extractDir -Force
|
||||
} else {
|
||||
throw "Unsupported archive format: $($archiveFile.Name)"
|
||||
}
|
||||
|
||||
# Handle single top-level folder inside archive.
|
||||
$rootDir = $extractDir
|
||||
$children = @(Get-ChildItem -LiteralPath $extractDir)
|
||||
if ($children.Count -eq 1 -and $children[0].PSIsContainer) {
|
||||
$rootDir = $children[0].FullName
|
||||
}
|
||||
|
||||
Write-Host "[2/5] Checking manifest.json, compliance files, and core binaries..."
|
||||
$required = @(
|
||||
'manifest.json',
|
||||
'NOTICE.md',
|
||||
'licenses',
|
||||
'bin\reims-ctl.exe',
|
||||
'bin\reims-util.exe',
|
||||
'qemu\bin\qemu-system-x86_64.exe',
|
||||
'qemu\bin\qemu-img.exe'
|
||||
)
|
||||
foreach ($rel in $required) {
|
||||
$p = Join-Path $rootDir $rel
|
||||
if (-not (Test-Path -LiteralPath $p)) {
|
||||
throw "Missing required runtime asset: $rel"
|
||||
}
|
||||
}
|
||||
$manifest = Get-Content -Raw -LiteralPath (Join-Path $rootDir 'manifest.json') | ConvertFrom-Json
|
||||
$patchList = @()
|
||||
if ($manifest.patches) {
|
||||
$patchList = @($manifest.patches | ForEach-Object { $_.name })
|
||||
}
|
||||
|
||||
Write-Host "[3/5] Running reims-ctl doctor in a clean MSYS2-free environment..."
|
||||
$cleanEnv = @{
|
||||
'XDG_CONFIG_HOME' = (Join-Path $dataDir 'config')
|
||||
'XDG_DATA_HOME' = (Join-Path $dataDir 'data')
|
||||
'XDG_CACHE_HOME' = (Join-Path $dataDir 'cache')
|
||||
'TEMP' = (Join-Path $dataDir 'tmp')
|
||||
'TMP' = (Join-Path $dataDir 'tmp')
|
||||
'REIMS_CTL_QEMU' = (Join-Path $rootDir 'qemu')
|
||||
'PATH' = "$($env:SystemRoot)\System32;$($env:SystemRoot)"
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $cleanEnv['XDG_CONFIG_HOME'], $cleanEnv['XDG_DATA_HOME'], $cleanEnv['XDG_CACHE_HOME'], $cleanEnv['TEMP'] | Out-Null
|
||||
|
||||
function Invoke-CleanCtl([string[]]$ctlArgs) {
|
||||
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = (Join-Path $rootDir 'bin\reims-ctl.exe')
|
||||
$psi.Arguments = ($ctlArgs -join ' ')
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.CreateNoWindow = $true
|
||||
foreach ($k in $cleanEnv.Keys) {
|
||||
$psi.EnvironmentVariables[$k] = $cleanEnv[$k]
|
||||
}
|
||||
$proc = [System.Diagnostics.Process]::Start($psi)
|
||||
$stdout = $proc.StandardOutput.ReadToEnd()
|
||||
$stderr = $proc.StandardError.ReadToEnd()
|
||||
$proc.WaitForExit()
|
||||
return @{ Code = $proc.ExitCode; Stdout = $stdout; Stderr = $stderr }
|
||||
}
|
||||
|
||||
$doctorRes = Invoke-CleanCtl @('doctor')
|
||||
Write-Host "[4/5] Running reims-ctl list --json..."
|
||||
$listRes = Invoke-CleanCtl @('list', '--json')
|
||||
if ($listRes.Code -ne 0) {
|
||||
throw "reims-ctl list --json failed ($($listRes.Code)): $($listRes.Stderr)"
|
||||
}
|
||||
|
||||
Write-Host "[5/5] Generating smoke report..."
|
||||
$reportLines = @(
|
||||
"# Runtime Smoke Test Report",
|
||||
"",
|
||||
"- **Tested at**: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss zzz')",
|
||||
"- **Host**: $([Environment]::MachineName) ($([Environment]::OSVersion.VersionString))",
|
||||
"- **Archive**: $($archiveFile.Name) ($([math]::Round($archiveFile.Length / 1MB, 1)) MB)",
|
||||
"- **SHA256 check**: $hashStatus",
|
||||
"- **Upstream commit**: $($manifest.commit) (channel: $($manifest.channel))",
|
||||
"- **vendor/qemu commit**: $($manifest.vendor_qemu_commit)",
|
||||
"- **Patches**: $(if ($patchList.Count -gt 0) { $patchList -join ', ' } else { 'none (pure upstream)' })",
|
||||
"- **Source package declared**: $($manifest.source_package)",
|
||||
"- **reims-ctl list --json**: PASS (exit $($listRes.Code))",
|
||||
"- **reims-ctl doctor exit code**: $($doctorRes.Code)",
|
||||
"",
|
||||
"## reims-ctl doctor output",
|
||||
'```text',
|
||||
$doctorRes.Stdout.TrimEnd(),
|
||||
'```'
|
||||
)
|
||||
$report = $reportLines -join "`n"
|
||||
if ($ReportOut -ne '') {
|
||||
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $ReportOut) | Out-Null
|
||||
[IO.File]::WriteAllText($ReportOut, $report + "`n", [Text.UTF8Encoding]::new($false))
|
||||
Write-Host "Smoke report written to: $ReportOut"
|
||||
} else {
|
||||
Write-Host "`n$report"
|
||||
}
|
||||
Write-Host "`nSmoke test finished. Human review required before promoting alpha -> stable."
|
||||
} finally {
|
||||
if (Test-Path -LiteralPath $smokeDir) {
|
||||
Remove-Item -LiteralPath $smokeDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
# Stage the Windows x64 payload and matching GNU debug files. Inputs are read-only.
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)] [string]$CargoBin,
|
||||
[Parameter(Mandatory)] [string]$QemuDir,
|
||||
[Parameter(Mandatory)] [string]$BundleDir,
|
||||
[Parameter(Mandatory)] [string]$SymbolsDir,
|
||||
[Parameter(Mandatory)] [string]$Objcopy
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$programs = @('bin/reims-ctl.exe', 'bin/reims-util.exe', 'qemu/bin/qemu-system-x86_64.exe',
|
||||
'qemu/bin/qemu-img.exe', 'qemu/bin/reims-vgpu-compile.exe')
|
||||
# Additional executables that may be built alongside x64 (e.g. ARM64 guest support).
|
||||
# Strip their debug info into the detached symbols archive whenever present.
|
||||
$optionalPrograms = @('qemu/bin/qemu-system-aarch64.exe', 'qemu/bin/reims-restore.exe')
|
||||
$allStripped = $programs + $optionalPrograms
|
||||
|
||||
# Omit only the paths tested with the x64 launcher. Keep new upstream files,
|
||||
# in particular dynamically loaded video drivers, ROMs, and license notices.
|
||||
$tools = @('bin/qemu-system-x86_64w.exe', 'bin/qemu-system-aarch64w.exe', 'bin/elf2dmp.exe',
|
||||
'bin/qemu-edid.exe', 'bin/qemu-io.exe', 'bin/qemu-nbd.exe', 'bin/qemu-storage-daemon.exe')
|
||||
foreach ($file in Get-ChildItem -LiteralPath $QemuDir -Recurse -Force -File) {
|
||||
$rel = [IO.Path]::GetRelativePath($QemuDir, $file.FullName).Replace('\', '/')
|
||||
if ($rel -in $tools) { continue }
|
||||
if ($rel -match '^share/edk2-(aarch64|riscv64|loongarch64)-(code|vars)\.fd$' -or
|
||||
$rel -match '^share/firmware/\d+-edk2-(aarch64|riscv64|loongarch64)\.json$') { continue }
|
||||
if ("qemu/$rel" -in $allStripped) { continue }
|
||||
$dest = Join-Path $BundleDir "qemu/$rel"
|
||||
[void][IO.Directory]::CreateDirectory((Split-Path -Parent $dest))
|
||||
Copy-Item -LiteralPath $file.FullName -Destination $dest
|
||||
}
|
||||
|
||||
function Copy-StrippedBinary([string]$rel) {
|
||||
$src = if ($rel.StartsWith('qemu/')) { Join-Path $QemuDir $rel.Substring(5) }
|
||||
else { Join-Path $CargoBin (Split-Path -Leaf $rel) }
|
||||
$dest = Join-Path $BundleDir $rel
|
||||
$debug = Join-Path $SymbolsDir "$rel.debug"
|
||||
[void][IO.Directory]::CreateDirectory((Split-Path -Parent $dest))
|
||||
[void][IO.Directory]::CreateDirectory((Split-Path -Parent $debug))
|
||||
& $Objcopy --only-keep-debug $src $debug | Out-Null
|
||||
if ($LASTEXITCODE) { throw "Extracting symbols from $src failed ($LASTEXITCODE)" }
|
||||
& $Objcopy --strip-debug "--add-gnu-debuglink=$debug" $src $dest | Out-Null
|
||||
if ($LASTEXITCODE) { throw "Stripping $src failed ($LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
foreach ($rel in $programs) {
|
||||
Copy-StrippedBinary $rel
|
||||
}
|
||||
foreach ($rel in $optionalPrograms) {
|
||||
$src = Join-Path $QemuDir $rel.Substring(5)
|
||||
if (Test-Path -LiteralPath $src -PathType Leaf) {
|
||||
Copy-StrippedBinary $rel
|
||||
}
|
||||
}
|
||||
# The packer hashes these final, stripped bytes for manifest.json.
|
||||
$programs
|
||||
@@ -1,117 +0,0 @@
|
||||
[CmdletBinding()]
|
||||
param([Parameter(Mandatory)][string]$TempRoot)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$root = (Resolve-Path -LiteralPath $TempRoot).Path
|
||||
$fixture = Join-Path $root ("alpha-version-test-" + [guid]::NewGuid())
|
||||
$planner = Join-Path $PSScriptRoot 'plan-runtime-release.ps1'
|
||||
$source = Join-Path $fixture 'runtime'
|
||||
$packaging = Join-Path $fixture 'packaging'
|
||||
$fixtureReleases = [System.Collections.Generic.List[hashtable]]::new()
|
||||
$testRepo = 'test/runtime'
|
||||
|
||||
function gh {
|
||||
$global:LASTEXITCODE = 0
|
||||
'[' + (ConvertTo-Json -InputObject $fixtureReleases.ToArray() -Depth 5 -Compress) + ']'
|
||||
}
|
||||
|
||||
function Test-Git([string]$repo, [string[]]$argv) {
|
||||
$result = & git -C $repo @argv
|
||||
if ($LASTEXITCODE) { throw "git $($argv -join ' ') failed in fixture" }
|
||||
return $result
|
||||
}
|
||||
|
||||
function Write-Commit([string]$repo, [string]$path, [string]$content, [string]$message = 'Fixture update') {
|
||||
$file = Join-Path $repo $path
|
||||
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $file) | Out-Null
|
||||
Set-Content -LiteralPath $file -Encoding utf8NoBOM -Value $content
|
||||
Test-Git $repo @('add', '--', $path) | Out-Null
|
||||
Test-Git $repo @('commit', '-q', '-m', $message) | Out-Null
|
||||
return Test-Git $repo @('rev-parse', 'HEAD')
|
||||
}
|
||||
|
||||
function Add-Published([string]$id, [string]$commit, [string]$pack, [string]$family) {
|
||||
$tag = "runtime-$id"
|
||||
Test-Git $source @('tag', $tag, $commit) | Out-Null
|
||||
$fixtureReleases.Add(@{
|
||||
tag_name = $tag
|
||||
draft = $false
|
||||
published_at = [DateTimeOffset]::UnixEpoch.AddMinutes($fixtureReleases.Count).ToString('o')
|
||||
body = "Packaging commit: ``$pack```nSuspend compatibility ID: ``$family``"
|
||||
})
|
||||
}
|
||||
|
||||
function Approval([string]$predecessor, [string]$other) {
|
||||
return "Fixture verified`n`nSuspend-Compatible-With: $predecessor`nSuspend-Verified-Inputs: $other`nSuspend-Verification: https://example.invalid/runtime-test"
|
||||
}
|
||||
|
||||
function Plan([string]$commit, [string]$pack, [switch]$PackagingPush) {
|
||||
& $planner -RuntimeRepo $source -RuntimeCommit $commit -PackagingRepo $packaging -PackagingCommit $pack `
|
||||
-Repository $testRepo -Rebuild:$PackagingPush -PackagingPush:$PackagingPush
|
||||
}
|
||||
|
||||
function Assert-Version($plan, [string]$id, [string]$family) {
|
||||
if ($plan.Skip -or $plan.ReleaseId -ne $id -or $plan.SuspendCompatID -ne $family) {
|
||||
throw "Expected $id in family $family, got $($plan | ConvertTo-Json -Compress)"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
foreach ($repo in $source, $packaging) {
|
||||
New-Item -ItemType Directory -Path $repo -Force | Out-Null
|
||||
Test-Git $repo @('init', '-q') | Out-Null
|
||||
Test-Git $repo @('config', 'user.name', 'Version Fixture') | Out-Null
|
||||
Test-Git $repo @('config', 'user.email', 'fixture@example.invalid') | Out-Null
|
||||
}
|
||||
Test-Git $source @('remote', 'add', 'origin', $source) | Out-Null
|
||||
$old = Write-Commit $source 'crates/reims-ctl/src/qemu.rs' 'original state path'
|
||||
$pack = Write-Commit $packaging 'packaging/windows-runtime/patches/series.txt' 'original patch queue'
|
||||
$base = Test-Git $source @('rev-parse', '--short=7', $old)
|
||||
Assert-Version (Plan $old $pack) $base $base
|
||||
Add-Published $base $old $pack $base
|
||||
if (!(Plan $old $pack).Skip -or !(Plan $old $pack -PackagingPush).Skip) {
|
||||
throw 'Already published build was not skipped'
|
||||
}
|
||||
|
||||
$compatiblePack = Write-Commit $packaging 'packaging/windows-runtime/notice.txt' 'packaging adjustment' (Approval "runtime-$base" $old)
|
||||
Assert-Version (Plan $old $compatiblePack -PackagingPush) "$base-p1" $base
|
||||
$breakingPack = Write-Commit $packaging 'packaging/windows-runtime/patches/series.txt' 'changed snapshot patch queue' (Approval "runtime-$base" $old)
|
||||
try {
|
||||
$null = Plan $old $breakingPack -PackagingPush
|
||||
throw 'Incompatible packaging change reused the old runtime commit'
|
||||
} catch {
|
||||
if ($_ -notmatch 'A new runtime baseline commit is required') { throw }
|
||||
}
|
||||
|
||||
$compatible = Write-Commit $source 'docs/build.md' 'safe runtime change' (Approval "runtime-$base" $pack)
|
||||
Assert-Version (Plan $compatible $pack) "$base-p1" $base
|
||||
Add-Published "$base-p1" $compatible $pack $base
|
||||
if (!(Plan $compatible $pack).Skip) {
|
||||
throw 'A published revision with a different source prefix rebuilt'
|
||||
}
|
||||
|
||||
$next = Write-Commit $source 'docs/build.md' 'another verified change' (Approval "runtime-$base-p1" $pack)
|
||||
Assert-Version (Plan $next $pack) "$base-p2" $base
|
||||
|
||||
$breaking = Write-Commit $source 'crates/reims-ctl/src/qemu.rs' 'different state path' (Approval "runtime-$base-p1" $pack)
|
||||
$breakingBase = Test-Git $source @('rev-parse', '--short=7', $breaking)
|
||||
Assert-Version (Plan $breaking $pack) $breakingBase $breakingBase
|
||||
Add-Published $breakingBase $breaking $pack $breakingBase
|
||||
|
||||
$reverted = Write-Commit $source 'crates/reims-ctl/src/qemu.rs' 'original state path' (Approval "runtime-$base-p1" $pack)
|
||||
$revertedBase = Test-Git $source @('rev-parse', '--short=7', $reverted)
|
||||
Assert-Version (Plan $reverted $pack) $revertedBase $revertedBase
|
||||
|
||||
$unverified = Write-Commit $source 'docs/build.md' 'unverified change'
|
||||
$unverifiedBase = Test-Git $source @('rev-parse', '--short=7', $unverified)
|
||||
Assert-Version (Plan $unverified $pack) $unverifiedBase $unverifiedBase
|
||||
Write-Host 'PASS Alpha family selection, exact-source deduplication, and suspend input guards'
|
||||
} finally {
|
||||
if (Test-Path -LiteralPath $fixture) {
|
||||
$resolved = (Resolve-Path -LiteralPath $fixture).Path
|
||||
if ($resolved -ne $fixture -or (Split-Path -Parent $resolved) -ne $root) {
|
||||
throw "Unexpected test fixture path: $resolved"
|
||||
}
|
||||
Remove-Item -LiteralPath $resolved -Recurse -Force
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Exercise the batched queries and their failure handling without a package database.
|
||||
set -euo pipefail
|
||||
helper="$(dirname "$0")/read-msys2-package-metadata.sh"
|
||||
mode=ok
|
||||
|
||||
pacman() {
|
||||
case "$*" in
|
||||
'-Qo -- /clang64/bin/a.dll /clang64/bin/local.dll /clang64/bin/b.dll')
|
||||
echo '/clang64/bin/a.dll is owned by same-package 2:1.0-3'
|
||||
echo 'error: No package owns /clang64/bin/local.dll' >&2
|
||||
echo '/clang64/bin/b.dll is owned by same-package 2:1.0-3'
|
||||
case $mode in
|
||||
query-failure) echo 'error: invalid local database' >&2; return 2 ;;
|
||||
wrong-status) return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
;;
|
||||
'-Ql -- same-package')
|
||||
echo 'same-package /clang64/bin/a.dll'
|
||||
echo 'same-package /clang64/share/licenses/example/'
|
||||
echo 'same-package /clang64/share/licenses/example/<LICENSE> text'
|
||||
if [[ $mode == list-failure ]]; then
|
||||
echo 'error: failed to read package file list' >&2
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf 'Unexpected pacman invocation: %s\n' "$*" >&2
|
||||
return 255
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
read_metadata() (
|
||||
source "$helper" "$@"
|
||||
)
|
||||
|
||||
paths=(/clang64/bin/a.dll /clang64/bin/local.dll /clang64/bin/b.dll)
|
||||
expected=$'owned\t/clang64/bin/a.dll\tsame-package\t2:1.0-3\nunowned\t/clang64/bin/local.dll\nowned\t/clang64/bin/b.dll\tsame-package\t2:1.0-3\nlicense\tsame-package\t/clang64/share/licenses/example/<LICENSE> text'
|
||||
actual=$(read_metadata "${paths[@]}")
|
||||
if [[ $actual != "$expected" ]]; then
|
||||
printf 'Metadata did not match:\n%s\n' "$actual" >&2
|
||||
exit 1
|
||||
fi
|
||||
[[ -z $(read_metadata) ]]
|
||||
for mode in query-failure wrong-status list-failure; do
|
||||
if read_metadata "${paths[@]}" >/dev/null 2>&1; then
|
||||
printf 'Accepted an unexpected pacman failure: %s\n' "$mode" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
printf 'MSYS2 package metadata checks passed\n'
|
||||
@@ -1,54 +0,0 @@
|
||||
# Alpha 运行时编号与挂起兼容性规范
|
||||
|
||||
本规范用于 Windows 便携运行时的 Alpha 发布。主编号表示挂起兼容边界,`-pN` 表示同一主编号下的发布修订。
|
||||
|
||||
## 编号规则
|
||||
|
||||
| 变更判定 | 发布编号 | 旧挂起文件 |
|
||||
| :--- | :--- | :--- |
|
||||
| 同一主编号下首次发布 | `runtime-a1b2c3d` | 作为该主编号的兼容基线 |
|
||||
| 交付内容有变更,旧挂起文件仍可用新版恢复 | `runtime-a1b2c3d-p1`、`runtime-a1b2c3d-p2`,按顺序递增 | 支持从该主编号下已验证的早期版本升级恢复 |
|
||||
| 直接修改挂起或恢复逻辑、影响挂起功能,或暂时无法确认兼容 | `runtime-d4e5f6a`,使用新的主编号 | 新版拒绝加载上一主编号的挂起文件 |
|
||||
|
||||
同一版本的发布标识、归档名称和 `manifest.json` 的 `commit` 使用同一份编号。`full_commit` 和 `vendor_qemu_commit` 分别记录实际构建所用的运行时与 QEMU 完整提交。`-pN` 递增时,源码记录随实际构建更新。发布过的主编号和修订号不得换包或重新分配。
|
||||
|
||||
新主编号采用新兼容基线对应的运行时提交短 SHA。若不兼容变更来自打包仓库或依赖补丁,先在运行时维护分支提交新的兼容基线记录,再以该提交生成新主编号。
|
||||
|
||||
## 兼容性判定
|
||||
|
||||
发布前比较上一版实际交付的运行时、QEMU、依赖补丁、固件和启动参数。仅在确认新版能读取旧挂起状态,并验证恢复后虚拟机可继续运行时,才能沿用主编号。
|
||||
|
||||
- **可以沿用主编号的场景** 包括下载、日志或打包调整。前提是这些调整没有改变挂起所用的文件、启动配置或恢复行为,并通过跨版本恢复验证。
|
||||
- **必须更换主编号的场景** 包括挂起保存、状态写入、恢复加载和相关校验逻辑的变更。迁移流或设备状态的格式、版本有变,以及 QEMU、WHPX、vGPU 或依赖调整会影响挂起功能时,也必须更换主编号。默认机型、CPU 特性、设备布局、固件、RAM 映射、磁盘控制器、QMP 恢复顺序和介质校验规则的变更也要纳入判定。
|
||||
- **影响不明确时使用新主编号。** 目录名和提交标题可用于定位审查范围。变更实际触达的状态和跨版本恢复结果决定能否沿用主编号。
|
||||
|
||||
例如,网络修复需要核对它是否改动可迁移网卡、网络设备状态或恢复顺序。只修改网络相关文件仍需完成这项检查。
|
||||
|
||||
## 客户端恢复契约
|
||||
|
||||
客户端将发布标识用于下载、安装和定位归档。跨修订恢复使用清单中明确声明的挂起兼容标识,并在保存挂起时将该标识写入记录。获得同一兼容标识的发布必须符合本规范的同主编号规则。客户端仍要验证挂起记录的格式、虚拟硬件配置、附加介质和状态文件完整性。
|
||||
|
||||
清单和挂起记录使用 `suspend_compat_id` 保存挂起兼容标识,其值为发布编号中 `-pN` 前的主编号。打包提交记录在清单的 `packaging_commit` 中。
|
||||
|
||||
不兼容的挂起文件应在启动 QEMU 加载前被拦截。客户端保留原挂起状态,并提示用户选择原运行时重新恢复,或在用户明确放弃挂起后冷启动。
|
||||
|
||||
现有 Reims-Go 校验会比较 `vendor_qemu_commit` 和完整的运行时编号。即使 QEMU 提交相同,`a1b2c3d` 与 `a1b2c3d-p1` 的完整编号也会触发拒绝。客户端支持明确的兼容标识后,Alpha 才可向使用该客户端的用户承诺跨 `-pN` 恢复。缺少兼容标识的旧记录继续使用原有校验。若要承诺旧记录可以升级恢复,必须另行验证并明确列出可接受的旧运行时和 QEMU 提交组合。 [现有运行时校验](https://github.com/Nwflower/Reims-Go/blob/08b3089569b2f3a705e06fbe6d37846c7faf7d47/internal/macos/reims/suspend.go#L159-L189) · [挂起文件及介质校验](https://github.com/Nwflower/Reims-Go/blob/08b3089569b2f3a705e06fbe6d37846c7faf7d47/internal/macos/reims/suspend_transaction.go#L139-L184)
|
||||
|
||||
## 发布验证
|
||||
|
||||
1. **确认比较基线。** 记录旧包和新包的发布标识、运行时与 QEMU 完整提交、依赖和补丁变更,以及本次编号判定。
|
||||
2. **沿用主编号。** 在虚拟机副本上,用旧包正常运行并挂起,再切到新版恢复。核对桌面和原应用状态、磁盘可写性及受影响的设备。验证上一修订和本系列最早承诺可升级的版本,并覆盖这次受影响的宿主或后端。
|
||||
3. **更换主编号。** 用上一主编号的挂起记录确认新版在加载前拦截,并验证新版能冷启动及完成自己的挂起与恢复。保留测试证据和可用于恢复旧状态的原运行时。
|
||||
4. **确认发布。** 核对编号与运行时清单、校验和、源码附件和 Release 说明。Alpha 经 CI 构建和检查后以预发布交付,正式版由人工确认和发布。 [Alpha 构建流程](../../.github/workflows/runtime-preview.yml)
|
||||
|
||||
## 自动编号的验证记录
|
||||
|
||||
沿用主编号前,在触发构建的提交末尾记录已验证的上一修订、另一侧的完整提交和验收记录链接。运行时分支提交记录打包提交,打包变更和手动重建由打包提交记录运行时提交。
|
||||
|
||||
```text
|
||||
Suspend-Compatible-With: runtime-a1b2c3d-p2
|
||||
Suspend-Verified-Inputs: 0123456789abcdef0123456789abcdef01234567
|
||||
Suspend-Verification: https://example.com/runtime-resume-check
|
||||
```
|
||||
|
||||
CI 使用最新已发布且声明兼容标识的运行时作为验证基线,该版本还必须是所属主编号下的最高修订。运行时和打包输入必须与该次验证对应。QEMU 指针、挂起相关源码或依赖补丁变化会要求新主编号。没有满足这些条件的验证记录时,CI 按新主编号处理。若运行时提交已发布且本次只是更换打包输入,先提交新的运行时基线,再发布。
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"capabilities": [
|
||||
"window-release-shortcut"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user