33 lines
2.0 KiB
PowerShell
33 lines
2.0 KiB
PowerShell
<#
|
|
Optional interop: build this library's fixture and an external lib60870-C master, then check both masters' parsing.
|
|
The caller supplies Lib60870Root and Python with c104 installed; no dependencies are downloaded.
|
|
External libraries are test-client dependencies only, not requirements of IEC60870-Slave or its example.
|
|
#>
|
|
param(
|
|
[Parameter(Mandatory=$true)][string]$Lib60870Root,
|
|
[Parameter(Mandatory=$true)][string]$Python,
|
|
[string]$Compiler = 'gcc'
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$project = Split-Path -Parent $PSScriptRoot
|
|
$out = Join-Path $project '.build/periodic-scan-interop'
|
|
$external = (Resolve-Path -LiteralPath $Lib60870Root).Path
|
|
New-Item -ItemType Directory -Path $out -Force | Out-Null
|
|
# Caller supplies test-only dependencies. Nothing is downloaded or installed here.
|
|
& cmake -S $external -B (Join-Path $out 'lib60870-build') -G 'MinGW Makefiles' -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
|
|
if ($LASTEXITCODE -ne 0) { throw 'External client library configuration failed' }
|
|
& cmake --build (Join-Path $out 'lib60870-build') -j 4
|
|
if ($LASTEXITCODE -ne 0) { throw 'External client library build failed' }
|
|
Push-Location $project
|
|
try {
|
|
$sources = @(rg --files 104 common -g '*.c' | Where-Object { $_ -notmatch 'IEC104\.c$|IEC104_Log\.c$|IEC104_Link_Master_StartStop\.c$' })
|
|
$server = Join-Path $out 'server.exe'
|
|
$client = Join-Path $out 'lib60870-client.exe'
|
|
& $Compiler -std=c11 -O2 -Wall -Wextra -Werror -I104 -I104/business -Icommon test/periodic_scan_interop_server.c @sources -lws2_32 -o $server
|
|
if ($LASTEXITCODE -ne 0) { throw 'Scan fixture server build failed' }
|
|
& $Compiler -std=c11 -O2 -Wall -Wextra -Werror "-I$external/src/inc/api" "-I$external/src/hal/inc" test/periodic_scan_lib60870_client.c (Join-Path $out 'lib60870-build/src/liblib60870.a') -lws2_32 -o $client
|
|
if ($LASTEXITCODE -ne 0) { throw 'External client build failed' }
|
|
& $Python test/periodic_scan_interop_test.py $server $client
|
|
if ($LASTEXITCODE -ne 0) { throw 'External interoperability failed' }
|
|
} finally { Pop-Location }
|