feat: add msglib readonly sidecar
This commit is contained in:
53
scripts/build-msglib-sidecar.ps1
Normal file
53
scripts/build-msglib-sidecar.ps1
Normal file
@@ -0,0 +1,53 @@
|
||||
param(
|
||||
[string]$OutputDir = "runs/msglib-sidecar",
|
||||
[string]$Configuration = "Release"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
||||
$sourceDir = Join-Path $repo "native/MsgLibReadSidecar"
|
||||
$outDirPath = Join-Path $repo $OutputDir
|
||||
$outExe = Join-Path $outDirPath "MsgLibReadSidecar.exe"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sourceDir)) {
|
||||
throw "source directory not found: $sourceDir"
|
||||
}
|
||||
|
||||
$csc = "$env:WINDIR\Microsoft.NET\Framework\v4.0.30319\csc.exe"
|
||||
if (-not (Test-Path -LiteralPath $csc)) {
|
||||
throw "32-bit .NET Framework csc.exe v4.0.30319 not found"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $outDirPath | Out-Null
|
||||
|
||||
$sources = Get-ChildItem -LiteralPath $sourceDir -Filter '*.cs' | Sort-Object Name | ForEach-Object { $_.FullName }
|
||||
if (-not $sources) {
|
||||
throw "no C# sources found in $sourceDir"
|
||||
}
|
||||
|
||||
& $csc `
|
||||
/nologo `
|
||||
/target:exe `
|
||||
/platform:x86 `
|
||||
/optimize+ `
|
||||
/warn:0 `
|
||||
/out:$outExe `
|
||||
/reference:System.dll `
|
||||
/reference:System.Core.dll `
|
||||
/reference:System.Data.dll `
|
||||
/reference:System.Web.Extensions.dll `
|
||||
$sources
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "MsgLib sidecar compilation failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
[ordered]@{
|
||||
ok = $true
|
||||
configuration = $Configuration
|
||||
platform = "x86"
|
||||
csc = $csc
|
||||
source_dir = $sourceDir
|
||||
output = $outExe
|
||||
} | ConvertTo-Json -Depth 4 -Compress
|
||||
81
scripts/verify-msglib-sidecar.ps1
Normal file
81
scripts/verify-msglib-sidecar.ps1
Normal file
@@ -0,0 +1,81 @@
|
||||
param(
|
||||
[string]$SidecarExe = "runs/msglib-sidecar/MsgLibReadSidecar.exe",
|
||||
[string]$SQLiteDllPath = $env:ISPHERE_MSGLIB_SQLITE_DLL,
|
||||
[string]$DbPath = $env:ISPHERE_MSGLIB_DB,
|
||||
[switch]$SkipBuild
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
||||
$sidecarPath = Join-Path $repo $SidecarExe
|
||||
|
||||
function Invoke-SidecarJson([hashtable]$Request) {
|
||||
$json = $Request | ConvertTo-Json -Depth 10 -Compress
|
||||
$output = $json | & $sidecarPath
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "sidecar exited with code $LASTEXITCODE"
|
||||
}
|
||||
try {
|
||||
return $output | ConvertFrom-Json
|
||||
}
|
||||
catch {
|
||||
throw "sidecar output was not JSON: $output"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $SkipBuild) {
|
||||
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo "scripts\build-msglib-sidecar.ps1") | Out-Host
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "build-msglib-sidecar.ps1 failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sidecarPath)) {
|
||||
throw "sidecar not found: $sidecarPath"
|
||||
}
|
||||
|
||||
$self = Invoke-SidecarJson @{
|
||||
protocol = "isphere.msglib.v1"
|
||||
request_id = "verify-self-check"
|
||||
op = "self_check"
|
||||
args = @{}
|
||||
}
|
||||
if (-not $self.ok -or $self.data.sidecar_name -ne "MsgLibReadSidecar" -or $self.data.process_bits -ne 32) {
|
||||
throw "self_check failed: $($self | ConvertTo-Json -Depth 8 -Compress)"
|
||||
}
|
||||
|
||||
$providerChecked = $false
|
||||
$displaySources = $null
|
||||
if ($SQLiteDllPath -and $DbPath) {
|
||||
if (-not (Test-Path -LiteralPath $SQLiteDllPath)) {
|
||||
throw "SQLite DLL not found: $SQLiteDllPath"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $DbPath)) {
|
||||
throw "MsgLib DB not found: $DbPath"
|
||||
}
|
||||
$displaySources = Invoke-SidecarJson @{
|
||||
protocol = "isphere.msglib.v1"
|
||||
request_id = "verify-display-sources"
|
||||
op = "display_sources"
|
||||
args = @{
|
||||
sqlite_dll_path = $SQLiteDllPath
|
||||
db_path = $DbPath
|
||||
password = "123"
|
||||
include_counts = $true
|
||||
max_tables = 64
|
||||
}
|
||||
}
|
||||
if (-not $displaySources.ok -or -not $displaySources.data.metadata_only -or $displaySources.data.message_body_values_returned) {
|
||||
throw "display_sources failed: $($displaySources | ConvertTo-Json -Depth 12 -Compress)"
|
||||
}
|
||||
$providerChecked = $true
|
||||
}
|
||||
|
||||
[ordered]@{
|
||||
ok = $true
|
||||
sidecar = (Resolve-Path -LiteralPath $sidecarPath).Path
|
||||
version = $self.data.sidecar_version
|
||||
process_bits = $self.data.process_bits
|
||||
provider_checked = $providerChecked
|
||||
display_source_count = if ($displaySources) { $displaySources.data.display_sources.Count } else { 0 }
|
||||
} | ConvertTo-Json -Depth 6 -Compress
|
||||
Reference in New Issue
Block a user