40 行
1.8 KiB
PowerShell
40 行
1.8 KiB
PowerShell
param(
|
|
[string]$Firmware = "$PSScriptRoot/../out/firmware-fan-r2",
|
|
[string]$Msvc = 'C:/Program Files (x86)/Microsoft Visual Studio/18/BuildTools/VC/Tools/MSVC/14.50.35717',
|
|
[string]$Sdk = 'C:/Program Files (x86)/Windows Kits/10',
|
|
[string]$SdkVersion = '10.0.26100.0'
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$fw = (Resolve-Path -LiteralPath $Firmware).Path
|
|
$build = [IO.Path]::GetFullPath("$PSScriptRoot/../out/fan-pin-tests")
|
|
New-Item -ItemType Directory -Path $build -Force | Out-Null
|
|
$oldInclude = $env:INCLUDE
|
|
$oldLib = $env:LIB
|
|
$oldPath = $env:PATH
|
|
try {
|
|
$env:INCLUDE = "$Msvc/include;$Sdk/Include/$SdkVersion/ucrt;$Sdk/Include/$SdkVersion/shared;$Sdk/Include/$SdkVersion/um"
|
|
$env:LIB = "$Msvc/lib/x64;$Sdk/Lib/$SdkVersion/ucrt/x64;$Sdk/Lib/$SdkVersion/um/x64"
|
|
$env:PATH = "$Msvc/bin/Hostx64/x64;$env:PATH"
|
|
$hal = "$fw/components/phonerail_hal"
|
|
$drv = "$fw/components/drv"
|
|
$sources = @("$fw/main/rail_cfg.c", "$fw/test/test_rail_cfg.c", "$fw/third_party/unity/unity.c")
|
|
$sources += (Get-ChildItem "$hal/*.c", "$hal/sim/*.c", "$drv/*.c").FullName
|
|
$includes = @("$fw/main", "$fw/third_party/unity", "$hal/include", "$hal/sim", "$drv/include")
|
|
$flags = @('/nologo', '/std:c11', '/utf-8', '/W3', '/WX')
|
|
$flags += $includes | ForEach-Object { "/I$_" }
|
|
Push-Location $build
|
|
try {
|
|
& "$Msvc/bin/Hostx64/x64/cl.exe" @flags @sources /Fe:test_rail_cfg.exe 2>&1 |
|
|
Tee-Object -FilePath compile.log
|
|
if ($LASTEXITCODE -ne 0) { throw "Pin test compilation failed: $LASTEXITCODE" }
|
|
& ./test_rail_cfg.exe 2>&1 | Tee-Object -FilePath tests.log
|
|
if ($LASTEXITCODE -ne 0) { throw "Pin tests failed: $LASTEXITCODE" }
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
} finally {
|
|
$env:INCLUDE = $oldInclude
|
|
$env:LIB = $oldLib
|
|
$env:PATH = $oldPath
|
|
}
|