25 lines
1.3 KiB
PowerShell
25 lines
1.3 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[string]$BuildDirectory = (Join-Path $PSScriptRoot '../native/build'),
|
|
[string]$Generator = '',
|
|
[ValidateRange(1, 64)][int]$Jobs = 2,
|
|
[switch]$Test
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$SourceDirectory = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../native'))
|
|
$BuildDirectory = [System.IO.Path]::GetFullPath($BuildDirectory)
|
|
if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) { throw 'CMake 3.24+ is required.' }
|
|
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { throw 'Git is required to fetch pinned RandomX.' }
|
|
$NativeTests = if ($Test) { 'ON' } else { 'OFF' }
|
|
$ConfigureArguments = @('-S', $SourceDirectory, '-B', $BuildDirectory,
|
|
'-DCMAKE_BUILD_TYPE=Release', "-DWIKIDECK_RANDOMX_TESTS=$NativeTests")
|
|
if ($Generator) { $ConfigureArguments += @('-G', $Generator) }
|
|
& cmake @ConfigureArguments
|
|
if ($LASTEXITCODE -ne 0) { throw 'RandomX CMake configuration failed.' }
|
|
& cmake --build $BuildDirectory --config Release --target wikideck-randomx --parallel $Jobs
|
|
if ($LASTEXITCODE -ne 0) { throw 'RandomX native build failed.' }
|
|
if ($Test) {
|
|
& ctest --test-dir $BuildDirectory -C Release --output-on-failure
|
|
if ($LASTEXITCODE -ne 0) { throw 'RandomX known-vector test failed.' }
|
|
}
|
|
Write-Host "Built native RandomX engine in $BuildDirectory" |