XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
[CmdletBinding()]
param(
    [ValidateSet('Debug','Release')][string]$Configuration='Release',
    [Parameter(Mandatory)][string]$OutputDirectory
)
$ErrorActionPreference='Stop'
$taskVsWhere='C:/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe'
$taskVs=& $taskVsWhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if(-not $taskVs){throw 'NativeAOT requires the Visual Studio x64 native linker and Windows SDK.'}
$taskOutput=[IO.Path]::GetFullPath($OutputDirectory)
New-Item -ItemType Directory -Force -Path $taskOutput | Out-Null
$taskMinHook=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../../third_party/minhook/src'))
$taskOptimize=if($Configuration -eq 'Debug'){'/Od'}else{'/O2'}
$taskCommands=@('@call "'+$taskVs+'\VC\Auxiliary\Build\vcvars64.bat" >nul')
$taskCommands+='@if errorlevel 1 exit /b %ERRORLEVEL%'
$taskObjects=@()
foreach($taskFile in @('buffer.c','hook.c','trampoline.c','hde/hde64.c')){
    $taskObject=Join-Path $taskOutput ([IO.Path]::GetFileNameWithoutExtension($taskFile)+'.obj')
    $taskObjects+='"'+$taskObject+'"'
    $taskCommands+=('@cl /nologo '+$taskOptimize+' /MT /W4 /c "'+(Join-Path $taskMinHook $taskFile)+'" /Fo"'+$taskObject+'"')
    $taskCommands+='@if errorlevel 1 exit /b %ERRORLEVEL%'
}
$taskCommands+=('@cl /nologo /std:c++20 '+$taskOptimize+' /MT /EHsc /W4 /c "'+$PSScriptRoot+'\Boundary.cpp" /Fo"'+$taskOutput+'\boundary.obj"')
$taskCommands+='@if errorlevel 1 exit /b %ERRORLEVEL%'
$taskCommands+=('@ml64 /nologo /c /Fo"'+$taskOutput+'\invoke.obj" "'+$PSScriptRoot+'\Invoke.asm"')
$taskCommands+='@if errorlevel 1 exit /b %ERRORLEVEL%'
$taskCommands+=('@lib /nologo /OUT:"'+$taskOutput+'\XfePlatform.lib" "'+$taskOutput+'\boundary.obj" "'+$taskOutput+'\invoke.obj" '+($taskObjects -join ' '))
$taskCommands+='@exit /b %ERRORLEVEL%'
$taskBatch=Join-Path $taskOutput 'build.cmd'
[IO.File]::WriteAllLines($taskBatch,$taskCommands,[Text.Encoding]::ASCII)
& $env:ComSpec /d /c $taskBatch
if($LASTEXITCODE -ne 0){throw 'Native ABI boundary build failed.'}