53 lines
3.3 KiB
PowerShell
53 lines
3.3 KiB
PowerShell
<#
|
|
Build wto_ws.dll with the Visual Studio C compiler (x64).
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File native\wto-net\build.ps1 [-Out <folder>]
|
|
|
|
Output: <Out>\wto_ws.dll (default build\native). Static C runtime (/MT), so the DLL needs
|
|
nothing but the system's ws2_32.dll. MinHook comes from native\third_party\minhook (BSD-2).
|
|
The ground AI navigation engine (native\wto-nav) links upstream Detour from
|
|
native\third_party\recastnavigation (zlib), compiled separately at its own warning level.
|
|
#>
|
|
param([string]$Out = (Join-Path $PSScriptRoot '..\..\build\native'))
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
|
|
$vs = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
|
if (-not $vs) { throw 'Visual Studio with the x64 C++ tools was not found' }
|
|
$vcvars = Join-Path $vs 'VC\Auxiliary\Build\vcvars64.bat'
|
|
|
|
$src = Join-Path $PSScriptRoot 'src'
|
|
$mh = Join-Path $PSScriptRoot '..\third_party\minhook'
|
|
$nav = Join-Path $PSScriptRoot '..\wto-nav'
|
|
$dt = Join-Path $PSScriptRoot '..\third_party\recastnavigation\Detour'
|
|
New-Item -ItemType Directory -Force $Out | Out-Null
|
|
$obj = Join-Path $Out 'obj'
|
|
New-Item -ItemType Directory -Force $obj | Out-Null
|
|
$dtObj = Join-Path $obj 'detour'
|
|
New-Item -ItemType Directory -Force $dtObj | Out-Null
|
|
|
|
function Quote($paths) { $paths | ForEach-Object { '"' + (Resolve-Path $_) + '"' } }
|
|
|
|
$sources = Quote @(
|
|
"$src\dll_main.c", "$src\hook_config.c", "$src\redirect_rules.c", "$src\resolver_hooks.c", "$src\connection_hooks.c",
|
|
"$src\local_mp_core.c", "$src\local_mp_values.c", "$src\local_mp_players.c", "$src\local_mp_loadout.c", "$src\local_mp_actions.c", "$src\local_mp_awards.c", "$src\local_mp_kills.c", "$src\local_mp_events.c", "$src\local_mp_scores.c", "$src\local_mp_nuke.c", "$src\local_mp_support.c",
|
|
"$src\local_mp_damage_notifications.c", "$src\local_mp_hit_feedback.c", "$src\local_mp_air_events.c", "$src\local_mp_ground_ai.c", "$src\local_mp_nav.c", "$src\local_mp_zones.c", "$src\local_mp_captures.c", "$src\local_mp_air_ai_sync.c",
|
|
"$nav\wto_nav_runtime.cpp", "$nav\wto_nav_paths.cpp", "$nav\wto_nav_queries.cpp", "$nav\wto_nav_protocol.c",
|
|
"$mh\src\hook.c", "$mh\src\buffer.c", "$mh\src\trampoline.c", "$mh\src\hde\hde64.c"
|
|
)
|
|
$detourSources = Quote (Get-ChildItem "$dt\Source\*.cpp").FullName
|
|
$detourObjects = (Get-ChildItem "$dt\Source\*.cpp") | ForEach-Object { '"' + (Join-Path $dtObj ($_.BaseName + '.obj')) + '"' }
|
|
# Every translation unit that sees dtQueryFilter must agree on its layout (wto_nav_runtime.cpp).
|
|
$detourFlags = "/DDT_VIRTUAL_QUERYFILTER /I`"$dt\Include`""
|
|
|
|
$detour = "`"$vcvars`" >nul && cl /nologo /c /O2 /MT /EHsc /W3 $detourFlags /Fo`"$dtObj\\`" $($detourSources -join ' ')"
|
|
cmd /c $detour
|
|
if ($LASTEXITCODE -ne 0) { throw "cl (Detour) failed with $LASTEXITCODE" }
|
|
|
|
$command = "`"$vcvars`" >nul && cl /nologo /LD /O2 /MT /EHsc /W4 /wd4100 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN $detourFlags " +
|
|
"/I`"$mh\include`" /I`"$nav`" /Fo`"$obj\\`" $($sources -join ' ') $($detourObjects -join ' ') /Fe`"$Out\wto_ws.dll`" " +
|
|
"/link /DEF:`"$src\wto_ws.def`" ws2_32.lib"
|
|
cmd /c $command
|
|
if ($LASTEXITCODE -ne 0) { throw "cl failed with $LASTEXITCODE" }
|
|
Write-Output (Join-Path $Out 'wto_ws.dll')
|