59 lines
3.2 KiB
PowerShell
59 lines
3.2 KiB
PowerShell
<#
|
|
Build the ground AI simulator's runtime: the open-source daScript interpreter (daslang.exe) at a
|
|
pinned commit, with this project's native module `wto_sim` (native\wto-ai-sim\module).
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File native\wto-ai-sim\build.ps1
|
|
|
|
The daScript checkout goes to build\daslang (cloned when missing, about 420 MB), the build to
|
|
build\daslang-build. Neither is part of the repository. The module folder is linked into the
|
|
checkout as modules\wtoSim, so the daScript build compiles it with its own module rules and
|
|
daslang loads it at start. Needs Visual Studio with the x64 C++ tools; CMake and Ninja are the
|
|
ones Visual Studio bundles.
|
|
#>
|
|
param(
|
|
[string]$DasRoot = (Join-Path $PSScriptRoot '..\..\build\daslang'),
|
|
[string]$BuildDir = (Join-Path $PSScriptRoot '..\..\build\daslang-build')
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
# daScript 0.6.6, the version the simulator was verified with (docs: tank-ai-revision-plan 3.3.1).
|
|
$pin = '7a51c4ef9927dbc92ecf4cab67ae41b41d239f4a'
|
|
$repo = 'https://github.com/GaijinEntertainment/daScript.git'
|
|
|
|
if (-not (Test-Path (Join-Path $DasRoot '.git'))) {
|
|
git clone --no-checkout $repo $DasRoot
|
|
if ($LASTEXITCODE -ne 0) { throw 'git clone of daScript failed' }
|
|
}
|
|
$head = (git -C $DasRoot rev-parse HEAD 2>$null)
|
|
if ($head -ne $pin) {
|
|
git -C $DasRoot fetch origin $pin
|
|
git -C $DasRoot checkout --detach $pin
|
|
if ($LASTEXITCODE -ne 0) { throw "checkout of daScript $pin failed" }
|
|
}
|
|
|
|
$moduleLink = Join-Path $DasRoot 'modules\wtoSim'
|
|
if (-not (Test-Path $moduleLink)) {
|
|
New-Item -ItemType Junction -Path $moduleLink -Target (Join-Path $PSScriptRoot 'module') | Out-Null
|
|
}
|
|
|
|
$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'
|
|
$cmakeDir = Join-Path $vs 'Common7\IDE\CommonExtensions\Microsoft\CMake'
|
|
$cmake = Join-Path $cmakeDir 'CMake\bin\cmake.exe'
|
|
$ninja = Join-Path $cmakeDir 'Ninja\ninja.exe'
|
|
|
|
# Only the interpreter and the core runtime; every optional module of daScript stays off.
|
|
$off = @('ACCELERATE', 'AOT_EXAMPLES', 'AUDIO', 'CLANG_BIND', 'CLIPBOARD', 'CRYPTO', 'CUDA', 'FLEX_BISON', 'GLFW', 'HV',
|
|
'IMGUI', 'LLVM', 'MESHOPTIMIZER', 'METAL', 'PUGIXML', 'SMT', 'SQLITE', 'STBIMAGE', 'STDDLG', 'TERMINAL', 'TESTS',
|
|
'TREE_SITTER', 'TUTORIAL', 'VULKAN') | ForEach-Object { "-DDAS_$($_)_DISABLED=ON" }
|
|
$native = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path -replace '\\', '/'
|
|
$configure = "`"$cmake`" -S `"$DasRoot`" -B `"$BuildDir`" -G Ninja -DCMAKE_MAKE_PROGRAM=`"$ninja`" " +
|
|
"-DCMAKE_BUILD_TYPE=Release -DDAS_TOOLS_DISABLED=OFF -DWTO_SIM_NATIVE_ROOT=`"$native`" $($off -join ' ')"
|
|
cmd /c "`"$vcvars`" >nul && $configure"
|
|
if ($LASTEXITCODE -ne 0) { throw "cmake configure failed with $LASTEXITCODE" }
|
|
cmd /c "`"$vcvars`" >nul && `"$cmake`" --build `"$BuildDir`" --target daslang dasModuleWtoSim"
|
|
if ($LASTEXITCODE -ne 0) { throw "cmake build failed with $LASTEXITCODE" }
|
|
Write-Output (Join-Path $DasRoot 'bin\daslang.exe')
|