60 lines
3.5 KiB
PowerShell
60 lines
3.5 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$milestoneRoot = $PSScriptRoot
|
|
$repositoryRoot = Split-Path -Parent (Split-Path -Parent $milestoneRoot)
|
|
$source = Join-Path $milestoneRoot 'source'
|
|
$resultPath = Join-Path $milestoneRoot 'package-result.json'
|
|
$logPath = Join-Path $milestoneRoot 'package.log'
|
|
$metadataPath = Join-Path $milestoneRoot 'metadata-result.json'
|
|
foreach ($path in @($resultPath, $logPath, $metadataPath)) {
|
|
if (Test-Path -LiteralPath $path) { throw "Refusing existing execution evidence: $path" }
|
|
}
|
|
$preparation = Get-Content -LiteralPath (Join-Path $milestoneRoot 'preparation.json') -Raw | ConvertFrom-Json
|
|
if ($preparation.reconstruction_commit -ne 'd5650309a93f3d590a41f8a8f0322c6500568f69') { throw 'Unexpected reconstruction commit.' }
|
|
. (Join-Path $repositoryRoot '.local/toolchain/env.ps1')
|
|
$env:CARGO_BUILD_JOBS = '1'
|
|
$env:CARGO_NET_OFFLINE = 'true'
|
|
$script:packageCargoExecutable = (Get-Command cargo -CommandType Application).Source
|
|
$script:packageMetadataCalls = 0
|
|
# Transparent timing/admission wrapper: only the unchanged packager's one exact
|
|
# offline metadata command is allowed; stdout remains its original JSON stream.
|
|
function cargo {
|
|
$metadataArguments = @($args)
|
|
$expectedArguments = @('metadata', '--locked', '--offline', '--manifest-path', (Join-Path $source 'Cargo.toml'), '--filter-platform', 'x86_64-pc-windows-gnullvm', '--format-version', '1')
|
|
if ($script:packageMetadataCalls -ne 0 -or ($metadataArguments -join "`n") -cne ($expectedArguments -join "`n")) { throw 'Only one admitted locked offline metadata operation is authorized.' }
|
|
$script:packageMetadataCalls++
|
|
$metadataResult = [ordered]@{ executable = $script:packageCargoExecutable; arguments = $metadataArguments; started = [DateTime]::UtcNow.ToString('o') }
|
|
try {
|
|
& $script:packageCargoExecutable @metadataArguments
|
|
$metadataResult.exitCode = $LASTEXITCODE
|
|
} finally {
|
|
$metadataResult.finished = [DateTime]::UtcNow.ToString('o')
|
|
[IO.File]::WriteAllText($metadataPath, ($metadataResult | ConvertTo-Json -Depth 8) + "`n", [Text.UTF8Encoding]::new($false))
|
|
}
|
|
$global:LASTEXITCODE = $metadataResult.exitCode
|
|
}
|
|
$started = [DateTime]::UtcNow
|
|
$result = [ordered]@{ started = $started.ToString('o'); source_commit = $preparation.reconstruction_commit; version = $preparation.version }
|
|
try {
|
|
& (Join-Path $source 'scripts/package-windows.ps1') `
|
|
-Target x86_64-pc-windows-gnullvm `
|
|
-Version '0.2.0-preview.contextual.20260911' `
|
|
-BinaryDirectory (Join-Path $milestoneRoot 'bin') `
|
|
-LlvmMinGWRoot (Join-Path $repositoryRoot '.local/toolchain/llvm-mingw-20260826-ucrt-x86_64') `
|
|
-BuildEvidence (Join-Path $milestoneRoot 'build-evidence.json') `
|
|
-Python 'C:\Users\User\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' `
|
|
-OutputRoot (Join-Path $milestoneRoot 'packages') *>&1 | Tee-Object -FilePath $logPath
|
|
if ($script:packageMetadataCalls -ne 1) { throw 'Expected exactly one metadata call.' }
|
|
$result.success = $true
|
|
} catch {
|
|
$result.success = $false
|
|
$result.error = $_.ToString()
|
|
$_ | Out-String | Add-Content -LiteralPath $logPath
|
|
Write-Output $_
|
|
} finally {
|
|
$result.metadata_calls = $script:packageMetadataCalls
|
|
$result.finished = [DateTime]::UtcNow.ToString('o')
|
|
$result.elapsed_seconds = ([DateTime]::UtcNow - $started).TotalSeconds
|
|
[IO.File]::WriteAllText($resultPath, ($result | ConvertTo-Json -Depth 8) + "`n", [Text.UTF8Encoding]::new($false))
|
|
}
|
|
if (-not $result.success) { exit 1 }
|