am-freescan/integrations/freescan-service/build.ps1
Codex a16f16e19a feat(scanner): show native calibration window and SDK progress
Use the existing successful calibration-enter workflow to display the same SDK manufacturer's window and actual callback progress in the task UI. Bind metadata, JPEG and MJPEG to the execution, SDK session, calibration ID and trusted process/window identity; closing the monitor only stops viewing.

Include source-only FreeScanCpp integration, WGC capture lifecycle fixes and immediate ENTER acknowledgement cache synchronization. Preserve original scanner project guards, regression sources and third-party licensing; exclude private runtime configuration and generated artifacts.

Validated platform Java compilation/regressions, frontend type checks and standalone build, native compilation/offline and HTTP regressions, immediate calibration identity checks and ten synthetic window close/reopen cycles. Production installation/restart and real scanner calibration remain pending.
2026-11-21 19:52:07 +08:00

39 lines
3.1 KiB
PowerShell

param(
[string]$ToolchainRoot='C:\Users\Administrator\Desktop\扫描仪\FreeScanViewer\native\toolchain',
[string]$SdkInclude='C:\Program Files\Shining3d\FreeTrak_TRAK\sdk\include',
[string]$OutputName='FreeScanCpp.exe',
[switch]$CompileOnly,
[string[]]$SourceFiles,
[string]$OutputDirectory,
[string]$BuildDirectory
)
$ErrorActionPreference='Stop'
$taskProject=$PSScriptRoot
$taskWorkspace=Split-Path -Parent $taskProject
if([IO.Path]::GetFileName($OutputName) -ne $OutputName -or -not $OutputName.EndsWith('.exe')){throw 'OutputName must be an exe filename.'}
$taskToolchain=[IO.Path]::GetFullPath($ToolchainRoot)
$taskMsvc=Join-Path $taskToolchain 'msvc\VC\Tools\MSVC\14.44.35207'
$taskHeaders=Join-Path $taskToolchain 'winsdk\microsoft.windows.sdk.cpp\c\Include\10.0.26100.0'
$taskLibraries=Join-Path $taskToolchain 'winsdk\microsoft.windows.sdk.cpp.x64\c'
$taskCompiler=Join-Path $taskMsvc 'bin\Hostx64\x64\cl.exe'
if(-not(Test-Path -LiteralPath $taskCompiler)){throw 'The project-local verified MSVC toolchain is missing. See FreeScanViewer/native/README.md.'}
$taskSignature=Get-AuthenticodeSignature -LiteralPath $taskCompiler
if($taskSignature.Status-ne 'Valid' -or $taskSignature.SignerCertificate.Subject-notmatch 'Microsoft Corporation'){throw 'Microsoft compiler signature verification failed.'}
$taskBuild=if($BuildDirectory){[IO.Path]::GetFullPath($BuildDirectory)}else{Join-Path $taskProject 'build'}
$taskOutputDirectory=if($OutputDirectory){[IO.Path]::GetFullPath($OutputDirectory)}else{Join-Path $taskProject 'build\bin'}
New-Item -ItemType Directory -Path $taskBuild -Force|Out-Null
New-Item -ItemType Directory -Path $taskOutputDirectory -Force|Out-Null
$taskPreviousPath=$env:PATH;$taskPreviousInclude=$env:INCLUDE;$taskPreviousLib=$env:LIB
try{
$env:PATH=(Join-Path $taskMsvc 'bin\Hostx64\x64')+';'+$env:PATH
$env:INCLUDE=(Join-Path $taskMsvc 'include')+';'+(Join-Path $taskHeaders 'ucrt')+';'+(Join-Path $taskHeaders 'shared')+';'+(Join-Path $taskHeaders 'um')+';'+(Join-Path $taskHeaders 'cppwinrt')+';'+(Join-Path $taskHeaders 'winrt')+';'+$SdkInclude
$env:LIB=(Join-Path $taskMsvc 'lib\x64')+';'+(Join-Path $taskLibraries 'um\x64')+';'+(Join-Path $taskLibraries 'ucrt\x64')
[string[]]$taskSources=@(if($SourceFiles){$SourceFiles|ForEach-Object{if([IO.Path]::IsPathRooted($_)){$_}else{Join-Path $taskProject $_}}}else{Get-ChildItem (Join-Path $taskProject 'src') -Filter '*.cpp'|Select-Object -ExpandProperty FullName})
$taskOutput=Join-Path $taskOutputDirectory $OutputName
$taskArgs=@('/nologo','/MD','/O2','/EHsc','/std:c++17','/D_ITERATOR_DEBUG_LEVEL=0','/D_WIN32_WINNT=0x0602','/utf-8','/W4',('/Fo'+$taskBuild+'\'))
if($CompileOnly){$taskArgs+='/c'}else{$taskArgs+=('/Fe'+$taskOutput)}
& $taskCompiler @taskArgs @taskSources /link /INCREMENTAL:NO httpapi.lib advapi32.lib ole32.lib shell32.lib user32.lib gdiplus.lib shlwapi.lib crypt32.lib bcrypt.lib ws2_32.lib version.lib
if($LASTEXITCODE-ne 0){throw 'Native C++ build failed.'}
if(-not $CompileOnly){Write-Output ('Built native C++ executable: '+$taskOutput)}
}finally{$env:PATH=$taskPreviousPath;$env:INCLUDE=$taskPreviousInclude;$env:LIB=$taskPreviousLib}