The patch number is the commit count
A hand-maintained version says what somebody remembered to type. Pinning it to the repository means a binary always names the commit it came from, so a log from a test machine settles which changes are in it. stamp-version.ps1 runs as RP_L4's pre-build step and writes the generated RP_L4\rpl4build.h: #define RP412_VERSION "4.12.96" #define RP412_VERSION_LONG "4.12.96 (a1b2c3d)" The hash beside the number names the commit exactly; a trailing '+' means the tree had uncommitted changes to TRACKED files when it was built, which is the state a puzzling bug report usually comes from. Untracked files do not count - one scratch document in the tree would otherwise mark every build dirty and the marker would stop meaning anything. Generated rather than committed, and gitignored, because a hardcoded number cannot work: the commit that records "4.12.96" is itself commit 96, so the file is stale the moment it lands. The header is rewritten only when the stamp changes, so ordinary rebuilds do not drag RPL4.CPP through a recompile. pack-dist.ps1 reads that header instead of asking git again - a commit between building and packing would otherwise have the zip claiming a version the binary inside it does not report - and warns when the build it is packing came from a modified tree. The README banner, the zip name and the shipped CONTROLS.html all take the same number. Numbering stays ordered: 95 commits so far, so 4.12.95 follows 4.12.7 and every future build sorts after it. Only the "4.12" line is set by hand, at the top of the script. Two things the wiring turned up: Windows PowerShell turns a native command's stderr into ErrorRecords, so with $ErrorActionPreference = 'Stop' git's routine "LF will be replaced by CRLF" warning threw straight past the dirty check and stamped a modified tree as clean. Every git call now goes through cmd, which keeps stderr out of PowerShell's error stream entirely. The script ended on "git diff --quiet", which exits 1 to mean "there are changes" - as a pre-build step that failed the build on exactly the tree a developer builds in. It exits 0 explicitly now. Verified: deleting the header and building recreates it; a second build reports "(unchanged)" and leaves the timestamp alone; a build on a modified tree succeeds and stamps 4.12.95 (c1729e4+); and the packed game logs "Red Planet 4.12.95 (c1729e4+)" on its first line while README.txt and CONTROLS.html in the same package both read 4.12.95. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+23
-2
@@ -27,6 +27,23 @@ if (-not (Test-Path $exe)) {
|
||||
throw "Release\rpl4opt.exe not found - build first (see BUILD.md 2)."
|
||||
}
|
||||
|
||||
# --- version ---------------------------------------------------------------
|
||||
# Read the stamp the exe was BUILT with rather than asking git again: a
|
||||
# commit between the build and the pack would otherwise have the package
|
||||
# claiming a version the binary inside it does not report.
|
||||
$buildHeader = Join-Path $root 'RP_L4\rpl4build.h'
|
||||
if (-not (Test-Path $buildHeader)) {
|
||||
throw "RP_L4\rpl4build.h not found - build first, or run stamp-version.ps1."
|
||||
}
|
||||
$stamp = Get-Content $buildHeader -Raw
|
||||
$version = ([regex]::Match($stamp, '#define\s+RP412_VERSION\s+"([^"]+)"')).Groups[1].Value
|
||||
$versionLong = ([regex]::Match($stamp, '#define\s+RP412_VERSION_LONG\s+"([^"]+)"')).Groups[1].Value
|
||||
if (-not $version) { throw "could not read RP412_VERSION from $buildHeader" }
|
||||
if ($stamp -match '#define\s+RP412_BUILD_DIRTY\s+1') {
|
||||
Write-Warning "packing a build made from a modified tree ($versionLong)"
|
||||
}
|
||||
Write-Host "Version $versionLong"
|
||||
|
||||
# Refuse to touch a dist the game is currently running from.
|
||||
$running = Get-Process rpl4opt -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Path -like "$dist\*" }
|
||||
@@ -83,6 +100,10 @@ Set-Content -Path "$dist\CONTROLS.txt" -Encoding ascii -Value $controls
|
||||
# without a charset the typography arrives as mojibake. Written without a
|
||||
# BOM so the charset declaration is the only thing speaking.
|
||||
$controlsPage = Get-Content (Join-Path $root 'docs\rp412-controls.html') -Raw -Encoding UTF8
|
||||
# Stamp the shipped copy with the build's own version. The source keeps a
|
||||
# readable one for publishing; only "4.12.<n>" is touched, which on this
|
||||
# page is always the version and never anything else.
|
||||
$controlsPage = [regex]::Replace($controlsPage, '4\.12\.\d+', $version)
|
||||
$page = @"
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
@@ -401,7 +422,7 @@ set RP412JOYCONFIG=
|
||||
"@
|
||||
|
||||
Set-Content -Path "$dist\README.txt" -Encoding ascii -Value @"
|
||||
Red Planet 4.12.7
|
||||
Red Planet $version
|
||||
=================
|
||||
|
||||
Run start-fullscreen.bat for borderless over the whole monitor, or
|
||||
@@ -471,7 +492,7 @@ $size = (Get-ChildItem $dist -Recurse | Measure-Object Length -Sum).Sum
|
||||
Write-Host ("dist ready: {0:N1} MB" -f ($size / 1MB))
|
||||
|
||||
if ($Zip) {
|
||||
$zipPath = Join-Path $root 'RedPlanet-4.12.7.zip'
|
||||
$zipPath = Join-Path $root "RedPlanet-$version.zip"
|
||||
Write-Host "zipping to $zipPath..."
|
||||
|
||||
# Everything lives under a single RP412\ folder inside the zip, so
|
||||
|
||||
Reference in New Issue
Block a user