standalone: VoxelForgeCore library -- the fast generator behind a clean C++20 API, output unchanged
- Standalone/Core: public header VoxelForgeCore.h (no Unreal types), static library target, ResolvedWorldSnapshot (from the schema-v1 JSON), World (compile, generateTile, density/sign, point/segment solid, classifyBox), host-supplied JobScheduler (the core starts no threads), sequenced, idempotent EditTransaction returning affected tiles per LOD. - The viewer, benchmarks, edits and audits run on Core; StreamingWorld stays host code. - Same as round 11: 11 hash rows at W1 and W8, routes 5642/5642, look/passage/far audits pass, bad-shell control fails, six fixed captures byte-identical; cold W8 1.025 s vs 1.041 s reference. - SHARED_CPP_LIBRARY_PLAN.md rewritten for a UBT module compiling the same sources via shims. Open issue before Unreal: Core's implementation still compiles the Compat stand-ins named like Unreal types (TArray, FVector...); inside a UE binary that is an ODR clash. Must be namespaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
This commit is contained in:
1 parent
631dd57eb4
commit
557f6aac30
22 files changed
+6185
-5063
No files matched your search
+55
-45
@@ -1,72 +1,82 @@
|
||||
[CmdletBinding()]
|
||||
param([string]$OutputName = 'VoxelForgeStandalone.exe')
|
||||
param(
|
||||
[string]$OutputName = 'VoxelForgeCoreStandalone.exe',
|
||||
[ValidateSet('All','Core')][string]$Target = 'All'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$BuildHostProcess = Get-Process -Id $PID
|
||||
$BuildHostProcess.PriorityClass = 'BelowNormal'
|
||||
$BuildHostProcess.ProcessorAffinity = [IntPtr]0xFF00
|
||||
$Root = [IO.Path]::GetFullPath($PSScriptRoot)
|
||||
$BuildDir = Join-Path $Root 'Build'
|
||||
$BuildDir = Join-Path $Root 'Build\VoxelForgeCore'
|
||||
$BinDir = Join-Path $Root 'bin'
|
||||
if ([IO.Path]::GetFileName($OutputName) -ne $OutputName -or [IO.Path]::GetExtension($OutputName) -ne '.exe') {
|
||||
[IO.Directory]::CreateDirectory($BuildDir) | Out-Null
|
||||
[IO.Directory]::CreateDirectory($BinDir) | Out-Null
|
||||
|
||||
if ($Target -eq 'All' -and ([IO.Path]::GetFileName($OutputName) -ne $OutputName -or [IO.Path]::GetExtension($OutputName) -ne '.exe')) {
|
||||
throw "OutputName must be an executable filename, not a path: $OutputName"
|
||||
}
|
||||
$OutputPath = Join-Path $BinDir $OutputName
|
||||
[IO.Directory]::CreateDirectory($BuildDir) | Out-Null
|
||||
[IO.Directory]::CreateDirectory($BinDir) | Out-Null
|
||||
$CoreLibrary = Join-Path $BuildDir 'VoxelForgeCore.lib'
|
||||
$VcVars = 'E:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat'
|
||||
if (-not (Test-Path -LiteralPath $VcVars -PathType Leaf)) { throw "MSVC environment script not found: $VcVars" }
|
||||
|
||||
$Sources = @(
|
||||
(Join-Path $Root 'Source\StandaloneViewer.cpp'),
|
||||
(Join-Path $Root 'Compat\UnrealPerlin.cpp'),
|
||||
(Join-Path $Root 'Compat\StandaloneDataAssetGlue.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelBiomeDefinition.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelCaveMorphology.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelDensityAblation.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelDensityOpStack.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelDensityProfile.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelDiffLayer.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelGenerator.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelHeightOpStack.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelMarchingCubesMesher.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelSettings.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelStrateComposer.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelStrateManager.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelStrateMeasure.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelTerrainOpDefinition.cpp'),
|
||||
(Join-Path $Root 'Source\VoxelForge\Private\VoxelWormField.cpp')
|
||||
)
|
||||
foreach ($Source in $Sources) {
|
||||
if (-not (Test-Path -LiteralPath $Source -PathType Leaf)) { throw "Required source is missing: $Source" }
|
||||
$SourceManifest = Join-Path $Root 'Core\core_sources.txt'
|
||||
if (-not (Test-Path -LiteralPath $SourceManifest -PathType Leaf)) { throw "Core source manifest not found: $SourceManifest" }
|
||||
$CoreSourceNames = @(Get-Content -LiteralPath $SourceManifest | ForEach-Object { $_.Trim() } |
|
||||
Where-Object { $_ -and -not $_.StartsWith('#') })
|
||||
if ($CoreSourceNames.Count -eq 0) { throw "Core source manifest is empty: $SourceManifest" }
|
||||
$CoreSources = @($CoreSourceNames | ForEach-Object {
|
||||
$SourcePath = [IO.Path]::GetFullPath((Join-Path $Root $_))
|
||||
if (-not $SourcePath.StartsWith($Root,[StringComparison]::OrdinalIgnoreCase)) {
|
||||
throw "Core source path escapes Standalone: $_"
|
||||
}
|
||||
$SourcePath
|
||||
})
|
||||
foreach ($Source in $CoreSources) {
|
||||
if (-not (Test-Path -LiteralPath $Source -PathType Leaf)) { throw "Required core source is missing: $Source" }
|
||||
}
|
||||
|
||||
$ResponsePath = Join-Path $BuildDir 'standalone.rsp'
|
||||
$RspLines = @(
|
||||
'/nologo', '/std:c++20', '/O2', '/arch:AVX2', '/fp:precise', '/EHsc', '/MP8',
|
||||
'/D_CRT_SECURE_NO_WARNINGS',
|
||||
$IncludeArgs = @(
|
||||
('/I"{0}"' -f (Join-Path $Root 'Core\include')),
|
||||
('/I"{0}"' -f (Join-Path $Root 'Core\src')),
|
||||
('/I"{0}"' -f (Join-Path $Root 'Compat')),
|
||||
('/I"{0}"' -f (Join-Path $Root 'Source')),
|
||||
('/I"{0}"' -f (Join-Path $Root 'Source\VoxelForge\Public')),
|
||||
('/I"{0}"' -f (Join-Path $Root 'Source\VoxelForge\Private')),
|
||||
('/Fe"{0}"' -f $OutputPath)
|
||||
('/I"{0}"' -f (Join-Path $Root 'Source\VoxelForge\Private'))
|
||||
)
|
||||
# Run at most eight compiler processes on the half-load runner.
|
||||
foreach ($Source in $Sources) { $RspLines += ('"{0}"' -f $Source) }
|
||||
$RspLines += @('/link','d3d11.lib','dxgi.lib','d3dcompiler.lib','user32.lib','gdi32.lib')
|
||||
[IO.File]::WriteAllLines($ResponsePath,$RspLines,[Text.UTF8Encoding]::new($false))
|
||||
$CommonFlags = @('/nologo','/std:c++20','/O2','/arch:AVX2','/fp:precise','/EHsc','/MP8','/D_CRT_SECURE_NO_WARNINGS') + $IncludeArgs
|
||||
$CoreRsp = Join-Path $BuildDir 'core-compile.rsp'
|
||||
$CoreRspLines = $CommonFlags + @('/c') + @($CoreSources | ForEach-Object { '"{0}"' -f $_ })
|
||||
[IO.File]::WriteAllLines($CoreRsp,$CoreRspLines,[Text.UTF8Encoding]::new($false))
|
||||
|
||||
$Objects = @($CoreSources | ForEach-Object { '"{0}.obj"' -f [IO.Path]::GetFileNameWithoutExtension($_) })
|
||||
$LibRsp = Join-Path $BuildDir 'core-library.rsp'
|
||||
[IO.File]::WriteAllLines($LibRsp,@('/nologo',('/OUT:"{0}"' -f $CoreLibrary)) + $Objects,[Text.UTF8Encoding]::new($false))
|
||||
|
||||
$ViewerRsp = Join-Path $BuildDir 'viewer-link.rsp'
|
||||
$ViewerRspLines = $CommonFlags + @(
|
||||
('/Fe"{0}"' -f $OutputPath),
|
||||
('"{0}"' -f (Join-Path $Root 'Source\StandaloneViewer.cpp')),
|
||||
('"{0}"' -f $CoreLibrary),
|
||||
'/link','d3d11.lib','dxgi.lib','d3dcompiler.lib','user32.lib','gdi32.lib'
|
||||
)
|
||||
[IO.File]::WriteAllLines($ViewerRsp,$ViewerRspLines,[Text.UTF8Encoding]::new($false))
|
||||
|
||||
Push-Location $BuildDir
|
||||
try {
|
||||
# This PowerShell process already runs BelowNormal with affinity 0xFF00;
|
||||
# compile directly so cmd returns cl.exe's real exit code.
|
||||
$CommandLine = 'call "{0}" >nul && cl.exe @"{1}"' -f $VcVars,$ResponsePath
|
||||
# One cl process with /MP8 bounds compiler work to eight processes; MSVC, lib.exe, and the
|
||||
# viewer link inherit BelowNormal priority and the 0xFF00 process affinity from this host.
|
||||
$CommandLine = 'call "{0}" >nul && cl.exe @"{1}" && lib.exe @"{2}"' -f $VcVars,$CoreRsp,$LibRsp
|
||||
if ($Target -eq 'All') { $CommandLine += ' && cl.exe @"{0}"' -f $ViewerRsp }
|
||||
& $env:ComSpec /d /s /c $CommandLine
|
||||
if ($LASTEXITCODE -ne 0) { throw "Standalone MSVC build failed with exit code $LASTEXITCODE" }
|
||||
if (-not (Test-Path -LiteralPath $OutputPath -PathType Leaf)) {
|
||||
throw "Standalone MSVC build reported success but did not produce: $OutputPath"
|
||||
}
|
||||
if ($LASTEXITCODE -eq -1073741502) { throw 'A build process exited with 0xC0000142; stopping as required.' }
|
||||
if ($LASTEXITCODE -ne 0) { throw "VoxelForgeCore build failed with exit code $LASTEXITCODE" }
|
||||
if (-not (Test-Path -LiteralPath $CoreLibrary -PathType Leaf)) { throw "Core library was not produced: $CoreLibrary" }
|
||||
if ($Target -eq 'All' -and -not (Test-Path -LiteralPath $OutputPath -PathType Leaf)) { throw "Viewer was not produced: $OutputPath" }
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
Write-Host "Built $OutputPath"
|
||||
Write-Host "Built $CoreLibrary"
|
||||
if ($Target -eq 'All') { Write-Host "Built $OutputPath" }
|
||||
Reference in new issue
Block a user