Repository navigation
Expand file tree
/
Copy pathdev.ps1
More file actions
165 lines (165 loc) · 10.2 KB
/
Copy pathdev.ps1
File metadata and controls
165 lines (165 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#requires -Version 5.1
[CmdletBinding()]
param(
[Parameter(Position=0)][ValidateSet('status','sync','build','test','bundle','publish','verify','dependencies')][string]$Command='status',
[ValidateSet('x64','x86','both')][string]$Architecture='x64',
[ValidateSet('auto','release','local','test')][string]$Flavor='local',
[string]$Output,
[string]$Component,
[switch]$Offline
)
$ErrorActionPreference='Stop'
$repoRoot=$PSScriptRoot
Set-Location -LiteralPath $repoRoot
function Run-Git([string[]]$Arguments) {
& git -C $repoRoot @Arguments
if ($LASTEXITCODE -ne 0) { throw "git failed: $Arguments" }
}
function Run-Python([string[]]$Arguments) {
$launcher=Get-Command py -ErrorAction SilentlyContinue
if ($launcher) { & $launcher.Source -3 @Arguments } else { & python @Arguments }
if ($LASTEXITCODE -ne 0) { throw "Python command failed: $Arguments" }
}
function Fetch-State {
foreach ($remote in @('origin','upstream')) {
$expected=if ($remote -eq 'origin') {'marcmy/VideoRenderer'} else {'Aleksoid1978/VideoRenderer'}
$url=(& git remote get-url $remote).Trim()
if ($LASTEXITCODE -ne 0 -or $url -notmatch ('^(https://github\.com/|git@github\.com:)'+[regex]::Escape($expected)+'(\.git)?/?$')) { throw "Unexpected $remote repository: $url" }
}
Run-Git @('fetch','origin')
Run-Git @('fetch','upstream','--no-tags','master')
}
function Set-BuildSearchPath([string]$NasmExecutable) {
# Developer shells can replace PATH from an older __VSCMD_PREINIT_PATH.
# Keep Windows batch utilities and the pinned assembler available locally.
$systemDirectory=Join-Path $env:SystemRoot 'System32'
$required=@((Split-Path -Parent $NasmExecutable),$systemDirectory,$env:SystemRoot,(Join-Path $systemDirectory 'WindowsPowerShell\v1.0'))
$seen=New-Object 'System.Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase)
$entries=@(foreach ($entry in ($required+@($env:PATH -split ';'))) {
if (-not [string]::IsNullOrWhiteSpace($entry) -and $seen.Add($entry)) { $entry }
})
$env:PATH=$entries -join ';'
}
function Prepare-Tools {
$directory=Join-Path $repoRoot '_tools\nasm'
$executable=Join-Path $directory 'nasm-3.01\nasm.exe'
if (-not (Test-Path -LiteralPath $executable)) {
New-Item -ItemType Directory -Force -Path $directory | Out-Null
$archive=Join-Path $directory 'nasm-3.01-win64.zip'
if (-not (Test-Path -LiteralPath $archive)) { Invoke-WebRequest 'https://www.nasm.us/pub/nasm/releasebuilds/3.01/win64/nasm-3.01-win64.zip' -OutFile $archive -UseBasicParsing }
if ((Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash -ine 'e0ba5157007abc7b1a65118a96657a961ddf55f7e3f632ee035366dfce039ca4') { throw 'NASM checksum mismatch' }
Expand-Archive -LiteralPath $archive -DestinationPath $directory -Force
}
Set-BuildSearchPath $executable
}
function Build-Renderer {
Prepare-Tools
$nasmExecutable=Join-Path $repoRoot '_tools\nasm\nasm-3.01\nasm.exe'
$vswhere=Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$vs=(& $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | Select-Object -First 1)
if (-not $vs) { throw 'Visual Studio C++ tools were not found.' }
Import-Module (Join-Path $vs 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
$previousPreinitPath=$env:__VSCMD_PREINIT_PATH
try {
$env:__VSCMD_PREINIT_PATH=$env:PATH
Enter-VsDevShell -VsInstallPath $vs -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
} finally { $env:__VSCMD_PREINIT_PATH=$previousPreinitPath }
Set-BuildSearchPath $nasmExecutable
Set-Location -LiteralPath $repoRoot
& (Join-Path $repoRoot 'tools\Dev\Version.ps1') -Flavor $Flavor -Generate | Out-Null
$architectures=if ($Architecture -eq 'both') {@('x86','x64')} else {@($Architecture)}
foreach ($arch in $architectures) {
$platform=$arch
& msbuild MpcVideoRenderer.sln /nologo /m /nr:false /p:Configuration=Release "/p:Platform=$platform" "/p:NasmPath=$nasmExecutable" /v:minimal
if ($LASTEXITCODE -ne 0) { throw "$arch renderer build failed." }
}
$metadata=Get-Content '_bin\source-version.json' -Raw | ConvertFrom-Json
foreach ($arch in $architectures) {
$name=if ($arch -eq 'x64') {'MpcVideoRenderer64.ax'} else {'MpcVideoRenderer.ax'}
$path=Join-Path $repoRoot "_bin\Filter_$arch\$name"
$version=[Diagnostics.FileVersionInfo]::GetVersionInfo($path)
if ($version.FileVersion -ne $metadata.version -or $version.ProductVersion -ne $metadata.productVersion) { throw "Compiled version disagrees with source metadata: $path" }
if (-not $version.Comments.Contains($metadata.commit) -or -not $version.Comments.Contains($metadata.upstreamCommit)) { throw "Compiled source provenance is missing: $path" }
Write-Host "$name : $($version.ProductVersion)"
}
}
function Test-Renderer {
Prepare-Tools
Run-Python @('tools/Dev/test_release.py')
Run-Python @('tools/Dev/test_upstream_merge.py')
foreach ($hostName in @('powershell.exe','pwsh.exe')) {
& $hostName -NoLogo -NoProfile -ExecutionPolicy Bypass -File tools/Dev/Test-Version.ps1
if ($LASTEXITCODE -ne 0) { throw "$hostName version tests failed." }
& $hostName -NoLogo -NoProfile -ExecutionPolicy Bypass -File tools/Dev/Test-Dependencies.ps1
if ($LASTEXITCODE -ne 0) { throw "$hostName dependency tests failed." }
}
$pythonTests=@('rife-receive-pacing-test/test_receive_pacing.py','rife-lifecycle-test/test_rife_lifecycle.py','rife-spatial-contract-test/test_rife_vsr_routing.py','rife-presentation-preparation-test/test_preparation_contract.py','rife-spatial-contract-test/test_rife_spatial_contract.py')
foreach ($path in $pythonTests) { Run-Python @("tools/$path") }
$nativeTests=@('rife-scheduler-test/build-test.cmd','rife-runtime-abi-test/build-test.cmd','rife-cache-test/build-test.cmd','rife-image-scene-test/build-test.cmd','rife-nvof-input-test/build-test.cmd','rife-spatial-policy-test/build-test.cmd','rife-svp-scene-test/build-test.cmd','rife-precision-test/build-warp.cmd')
foreach ($path in $nativeTests) {
& cmd.exe /d /c "tools\$($path.Replace('/','\'))"
if ($LASTEXITCODE -ne 0) { throw "Regression test failed: $path" }
}
if (Test-Path '_bin\Filter_x64\MpcVideoRenderer64.ax') {
& cmd.exe /d /c tools\rife-working-resolution-test\build-test.cmd
if ($LASTEXITCODE -ne 0) { throw 'Compiled dialog test failed.' }
}
Run-Python @('tools/Dev/dependencies.py','check','--lock','dependencies.lock.json')
}
$previousFlavor=$env:MPCVR_BUILD_FLAVOR
try {
$env:MPCVR_BUILD_FLAVOR=$Flavor
switch ($Command) {
'status' {
if (-not $Offline) { Fetch-State }
Run-Git @('status','--short','--branch')
Run-Git @('rev-list','--left-right','--count','HEAD...origin/master')
Run-Git @('rev-list','--count','HEAD..upstream/master')
& tools/Dev/Version.ps1 -Flavor $Flavor
}
'sync' {
Fetch-State
if ((& git status --porcelain).Count) { throw 'Preserve and commit intentional work before integrating; use a temporary integration worktree for a dirty checkout.' }
if ((& git branch --show-current).Trim() -ne 'master') { throw 'Routine sync runs from canonical master; review feature-branch divergence separately.' }
Run-Git @('merge','--ff-only','origin/master')
$pending=[int](& git rev-list --count HEAD..upstream/master)
if ($pending) {
Run-Git @('merge','--no-ff','--no-commit','upstream/master')
& tools/Dev/Version.ps1 -RecordUpstream upstream/master
Run-Git @('add','upstream.version.json')
Run-Git @('commit','-m','Merge upstream VideoRenderer and record its source revision')
Write-Host 'Upstream integrated. Run build -Architecture both, test, then publish. Conflicts remain reviewable; no automatic resolver rewrites source.'
}
}
'build' { Build-Renderer }
'test' { Test-Renderer }
'bundle' {
Build-Renderer
$metadata=Get-Content '_bin/source-version.json' -Raw | ConvertFrom-Json
if (-not $Output) { $Output=Join-Path $repoRoot ('_artifacts/'+$metadata.sourceId+'/'+$Architecture) }
Run-Python @('tools/Dev/release.py','package','--version','_bin/source-version.json','--architecture',$Architecture,'--output',$Output)
}
'publish' {
Fetch-State
if ((& git status --porcelain).Count -or (& git branch --show-current).Trim() -ne 'master') { throw 'Publish requires committed canonical master; finish reviewing your changes first.' }
$env:MPCVR_BUILD_FLAVOR='release'; $Flavor='release'; $Architecture='both'
Build-Renderer; Test-Renderer
$alreadyPushed=(& git rev-parse HEAD).Trim() -eq (& git rev-parse origin/master).Trim()
Run-Git @('push','origin','HEAD:master')
if ($alreadyPushed) {
& gh workflow run main.yml --repo marcmy/VideoRenderer --ref master
if ($LASTEXITCODE -ne 0) { throw 'Source is already pushed, but release retry dispatch failed.' }
}
Write-Host 'Source pushed normally. main.yml publishes the verified source revision automatically.'
}
'verify' { Run-Python @('tools/Dev/release.py','verify-published') }
'dependencies' {
if ($Component -notin @('rife-runtime','rife-models','maxine')) { throw 'Specify -Component rife-runtime, rife-models, or maxine.' }
if ((& git status --porcelain).Count) { throw 'Dependency publishing requires a committed source revision.' }
Fetch-State
$sha=(& git rev-parse HEAD).Trim()
Run-Python @('tools/Dev/dependencies.py','approve-workflow','--source-ref',$sha,'--component',$Component)
Write-Host 'Dependency publishing dispatched separately. After validation, refresh the lock with dependencies.py plan and lock, review and publish the source update.'
}
}
} finally { $env:MPCVR_BUILD_FLAVOR=$previousFlavor }