23 lines
862 B
PowerShell
23 lines
862 B
PowerShell
$env:VCVARS = "D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
|
|
# 加载 VS 环境
|
|
$vcvarsOutput = & cmd /c "`"$env:VCVARS`" >nul 2>&1 && set" 2>$null
|
|
foreach ($line in $vcvarsOutput) {
|
|
if ($line -match '^([^=]+)=(.*)$') {
|
|
Set-Item -Path "env:$($matches[1])" -Value $matches[2]
|
|
}
|
|
}
|
|
|
|
Set-Location "g:\project\dllTest\TS660_DLL\TS660_DLL_SDK"
|
|
|
|
# 编译示例
|
|
& cl /nologo /EHsc /W3 /utf-8 /I. example\example.c /link /OUT:example.exe TS660_DLL.lib 2>&1 | Select-Object -Last 3
|
|
Remove-Item example.obj -ErrorAction SilentlyContinue
|
|
|
|
if (Test-Path example.exe) {
|
|
Write-Host "示例编译成功"
|
|
(Get-Item example.exe) | Select-Object Name, @{N='Size(KB)';E={[math]::Round($_.Length/1KB,1)}}
|
|
Remove-Item example.exe -ErrorAction SilentlyContinue
|
|
} else {
|
|
Write-Host "示例编译失败"
|
|
}
|