build: windows.ps1 builds ygol-engine.dll with a 333-export gate
premake vs2022 in server/ (SERVER_PRO3_SUPPORT, LOG_IN_CHAT, USE_SIMD=best), MSBuild on build\YGOPro.sln target ygoserver, Release x64, always from a wiped obj/bin/build; refuses a repo path with a space (libevent's unquoted xcopy); copies the result to out/win64/ and FAILS unless dumpbin counts exactly 333 exports: start_server, stop_server and the core's C API with ygol_sb_* and ygol_preview_attack. The old ygoserver.dll had 327 because its own core copy never carried patch 0008; one core means one export list. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
ff665ea99f
commit
58d97a36b3
1 file changed
+89
@@ -0,0 +1,89 @@
|
||||
<#
|
||||
Build ygol-engine.dll (x64, Release) for Windows.
|
||||
|
||||
One library: the duel server (server/) with the rules core (core/) linked
|
||||
inside, exporting the core C API, start_server and stop_server. The build
|
||||
is upstream's exec_windows_pro3 job: premake vs2022 in server/, then
|
||||
MSBuild on build\YGOPro.sln, target ygoserver.
|
||||
|
||||
Needs: premake5 5.0.0-beta8 (-Premake), VS 2022 Build Tools with the C++
|
||||
workload and a Windows 10 SDK, and a repo path WITHOUT spaces: libevent's
|
||||
premake emits an unquoted xcopy prebuild step that splits on a space.
|
||||
|
||||
Output: out\win64\ygol-engine.dll (+ .pdb). The export gate is the truth:
|
||||
the script FAILS unless the DLL exports exactly 333 symbols (start_server,
|
||||
stop_server, and the core C API re-exported, ygol_sb_* and
|
||||
ygol_preview_attack included). The Unity repo's old ygoserver.dll had 327:
|
||||
its own core copy never carried patch 0008's six ygol_sb_* exports.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Premake = "C:\premake\premake5.exe",
|
||||
[int]$ExpectedExports = 333
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repo = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$server = Join-Path $repo "server"
|
||||
$outDir = Join-Path $repo "out\win64"
|
||||
|
||||
if ($repo -match "\s") {
|
||||
throw "The repo path '$repo' contains a space. libevent's unquoted xcopy prebuild step cannot run from it. Clone the repo to a space-free path (for example C:\ygol-engine)."
|
||||
}
|
||||
foreach ($p in @(@($Premake, "premake5"), @((Join-Path $server "premake5.lua"), "server premake"), @((Join-Path $repo "core\ocgapi.h"), "core"))) {
|
||||
if (-not (Test-Path $p[0])) { throw "$($p[1]) not found at $($p[0])" }
|
||||
}
|
||||
$ver = & $Premake --version
|
||||
if ($ver -notmatch "5\.0\.0-beta8") { Write-Warning "premake is '$ver'; the build is verified with 5.0.0-beta8." }
|
||||
|
||||
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if (-not (Test-Path $vswhere)) { throw "vswhere not found at $vswhere (install VS 2022 Build Tools)" }
|
||||
$vs = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
|
||||
$msbuild = Join-Path $vs "MSBuild\Current\Bin\MSBuild.exe"
|
||||
if (-not (Test-Path $msbuild)) { throw "MSBuild not found at $msbuild" }
|
||||
$dumpbin = Get-ChildItem "$vs\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if (-not $dumpbin) { throw "dumpbin not found under $vs (install the C++ workload)" }
|
||||
|
||||
$buildStart = Get-Date
|
||||
Push-Location $server
|
||||
try {
|
||||
# Always from scratch: MSBuild's incremental check once reused an object
|
||||
# older than the source change that mattered, and the DLL still built.
|
||||
foreach ($d in @("obj", "bin", "build")) {
|
||||
if (Test-Path $d) { Remove-Item $d -Recurse -Force }
|
||||
}
|
||||
|
||||
# Upstream's server branch configures through the environment.
|
||||
$env:SERVER_PRO3_SUPPORT = "1"
|
||||
$env:LOG_IN_CHAT = "1"
|
||||
$env:USE_SIMD = "best"
|
||||
|
||||
Write-Host "==> premake vs2022"
|
||||
& $Premake vs2022
|
||||
if ($LASTEXITCODE -ne 0) { throw "premake failed" }
|
||||
|
||||
Write-Host "==> msbuild ygoserver (Release x64)"
|
||||
& $msbuild "build\YGOPro.sln" /t:ygoserver /p:Configuration=Release /p:Platform=x64 /m /v:minimal /nologo
|
||||
if ($LASTEXITCODE -ne 0) { throw "build failed" }
|
||||
|
||||
foreach ($o in @("obj\x64\Release\ygoserver\netserver.obj", "obj\x64\Release\ocgcore\ocgapi.obj")) {
|
||||
if (-not (Test-Path $o)) { throw "$o was never produced; the build did not compile it" }
|
||||
if ((Get-Item $o).LastWriteTime -lt $buildStart) { throw "$o is older than this run; the tree was not rebuilt" }
|
||||
}
|
||||
}
|
||||
finally { Pop-Location }
|
||||
|
||||
$dll = Join-Path $server "bin\release\x64\ygol-engine.dll"
|
||||
if (-not (Test-Path $dll)) { throw "built library not found at $dll" }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||
Copy-Item $dll $outDir -Force
|
||||
$pdb = [IO.Path]::ChangeExtension($dll, ".pdb")
|
||||
if (Test-Path $pdb) { Copy-Item $pdb $outDir -Force }
|
||||
$out = Join-Path $outDir "ygol-engine.dll"
|
||||
|
||||
$n = ((& $dumpbin.FullName /exports $out) | Select-String -Pattern '^\s+\d+\s+[0-9A-F]+\s+[0-9A-F]{8}\s+(\w+)').Count
|
||||
Write-Host ""
|
||||
Write-Host "Built: $out"
|
||||
Write-Host "exports: $n (expected $ExpectedExports)"
|
||||
if ($n -ne $ExpectedExports) { throw "export count $n != $ExpectedExports; do NOT ship this build" }
|
||||
Reference in new issue
Block a user