feat: add msglib readonly sidecar

This commit is contained in:
zhaoyilun
2026-07-10 02:45:55 +08:00
parent b442138e5c
commit 5b05228ba8
8 changed files with 849 additions and 23 deletions

View 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