Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
param(
[Parameter(Mandatory=$true)][string]$CopelandRoot,
[switch]$VerifyOnly
)
$ErrorActionPreference = 'Stop'
$repo = Split-Path $PSScriptRoot -Parent
$backend = Join-Path $CopelandRoot 'src/Copeland/Copeland.TS.Backend.Wgsl/Copeland.TS.Backend.Wgsl.csproj'
$projects = [Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
function Visit([string]$path) {
$path = [IO.Path]::GetFullPath($path)
if (-not $projects.Add($path)) { return }
[xml]$project = Get-Content -LiteralPath $path -Raw
foreach ($reference in $project.Project.ItemGroup.ProjectReference) {
if ($reference.Include) { Visit (Join-Path (Split-Path $path -Parent) $reference.Include) }
}
}
Visit $backend
$files = @($projects | ForEach-Object {
Get-ChildItem -LiteralPath (Split-Path $_ -Parent) -Recurse -File |
Where-Object { $_.Extension -in '.cs','.csproj' -and $_.FullName -notmatch '[\\/](bin|obj)[\\/]' }
}) + @(Get-ChildItem -LiteralPath $CopelandRoot -Filter 'Directory.*.props')
$sourceHashes = [Collections.Generic.SortedDictionary[string,string]]::new([StringComparer]::Ordinal)
foreach ($file in $files) {
$relative = [IO.Path]::GetRelativePath($CopelandRoot,$file.FullName).Replace('\','/')
# Source identity must survive LF/CRLF and UTF-8 BOM differences between checkouts.
$text = [IO.File]::ReadAllText($file.FullName).Replace("`r`n", "`n")
$sourceHashes[$relative] = [Convert]::ToHexString([Security.Cryptography.SHA256]::HashData([Text.Encoding]::UTF8.GetBytes($text)))
}
$manifest = ($sourceHashes.GetEnumerator() | ForEach-Object { $_.Key + ':' + $_.Value }) -join "`n"
$hash = [Convert]::ToHexString([Security.Cryptography.SHA256]::HashData([Text.Encoding]::UTF8.GetBytes($manifest))).ToLowerInvariant()
[xml]$properties = Get-Content (Join-Path $repo 'Directory.Build.props') -Raw
$version = [string]$properties.Project.PropertyGroup.ManagedWgslVersion
$pin = Join-Path $repo 'scripts/managed-wgsl-source-pin.txt'
if (-not (Test-Path $pin)) { throw 'Managed WGSL producer source pin is missing.' }
if ((Get-Content $pin -Raw).Trim() -ne $hash) { throw "Managed WGSL producer source differs from the reviewed source pin: actual $hash." }
Write-Output "Source pin: $hash"
Write-Output "Package version: $version"
if ($VerifyOnly) { return }
$output = Join-Path $repo 'artifacts/local/cir-artifact-binding/packages'
New-Item -ItemType Directory -Force $output | Out-Null
foreach ($project in $projects | Sort-Object) {
dotnet pack $project -c Release -m:1 -nr:false -p:UseSharedCompilation=false -o $output "-p:PackageVersion=$version" "-p:Version=$version" --nologo
if ($LASTEXITCODE -ne 0) { throw "Managed WGSL dependency pack failed: $project" }
}