Files
aiturk-hermes-ide/scripts/build-chrome.ps1

24 lines
1.7 KiB
PowerShell

param([string]$OutputDirectory = (Join-Path $PSScriptRoot '../artifacts/chrome'))
$ErrorActionPreference = 'Stop'
$taskRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$chromeSource = Join-Path $taskRoot 'apps/chrome'
$compiler = Join-Path $env:WINDIR 'Microsoft.NET/Framework64/v4.0.30319/csc.exe'
if (!(Test-Path -LiteralPath $compiler)) { throw '.NET Framework 4 C# compiler is required.' }
$staging = Join-Path ([IO.Path]::GetTempPath()) ('aiturk-chrome-' + [guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Path $staging | Out-Null
Copy-Item -LiteralPath (Join-Path $chromeSource 'extension') -Destination $staging -Recurse
Copy-Item -LiteralPath (Join-Path $chromeSource 'KURULUM.txt') -Destination $staging
$executable = Join-Path $staging 'AITURK Chrome Kur.exe'
& $compiler /nologo /optimize+ /target:winexe /platform:anycpu /r:System.Web.Extensions.dll /r:System.Windows.Forms.dll "/out:$executable" (Join-Path $chromeSource 'native/Bridge.cs')
if ($LASTEXITCODE -ne 0) { throw 'Native bridge compilation failed.' }
New-Item -ItemType Directory -Force -Path $OutputDirectory | Out-Null
$version = (Get-Content -LiteralPath (Join-Path $chromeSource 'extension/manifest.json') -Raw | ConvertFrom-Json).version
$archive = Join-Path $OutputDirectory "AITURK-Chrome-$version-windows.zip"
if (Test-Path -LiteralPath $archive) { throw "Artifact already exists; use a new output directory: $archive" }
Compress-Archive -Path (Join-Path $staging '*') -DestinationPath $archive -CompressionLevel Optimal
$hash = (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant()
Write-Output "Archive: $archive"
Write-Output "SHA256: $hash"
Write-Output "Native host test path: $executable"
Write-Output "Staging retained for verification: $staging"