8 # Operating system (build VM template)
11 # Build platform, i.e. x86, x64, AnyCPU. This setting is optional.
16 # build Configuration, i.e. Debug, Release, etc.
22 # The build fail immediately once one of the job fails
25 # Scripts that are called at very beginning, before repo cloning
33 $src = get-childitem -Path *.cpp -Recurse | select -ExpandProperty FullName
35 $src = $src.Replace("\", "/")
37 # Build CMakeLists.txt
38 $t = 'cmake_minimum_required(VERSION 3.17)',
40 'set(CMAKE_CXX_STANDARD 17)',
41 'set(CMAKE_CXX_STANDARD_REQUIRED ON)',
42 'set (CMAKE_CXX_EXTENSIONS OFF)',
43 'set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src)',
44 'set(source_files', $src, ')',
45 'add_executable(stockfish ${source_files})'
47 # Write CMakeLists.txt withouth BOM
48 $MyPath = (Get-Item -Path "." -Verbose).FullName + '\CMakeLists.txt'
49 $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
50 [System.IO.File]::WriteAllLines($MyPath, $t, $Utf8NoBomEncoding)
52 # Obtain bench reference from git log
53 $b = git log HEAD | sls "\b[Bb]ench[ :]+[0-9]{7}" | select -first 1
54 $bench = $b -match '\D+(\d+)' | % { $matches[1] }
55 Write-Host "Reference bench:" $bench
56 $g = "Visual Studio 16 2019"
57 If (${env:PLATFORM} -eq 'x64') { $a = "x64" }
58 If (${env:PLATFORM} -eq 'x86') { $a = "Win32" }
59 cmake -G "${g}" -A ${a} .
60 Write-Host "Generated files for: " $g $a
63 - cmake --build . --config %CONFIGURATION% -- /verbosity:minimal
65 # Download default NNUE net from fishtest
66 $nnuenet = Get-Content -Path src\evaluate.h | Select-String -CaseSensitive -Pattern "EvalFileDefaultName" | Select-String -CaseSensitive -Pattern "nn-[a-z0-9]{12}.nnue"
67 $dummy = $nnuenet -match "(?<nnuenet>nn-[a-z0-9]{12}.nnue)"
68 $nnuenet = $Matches.nnuenet
69 Write-Host "Default net:" $nnuenet
70 $nnuedownloadurl = "https://tests.stockfishchess.org/api/nn/$nnuenet"
71 $nnuefilepath = "src\${env:CONFIGURATION}\$nnuenet"
72 if (Test-Path -Path $nnuefilepath) {
73 Write-Host "Already available."
75 Write-Host "Downloading $nnuedownloadurl to $nnuefilepath"
76 Invoke-WebRequest -Uri $nnuedownloadurl -OutFile $nnuefilepath
80 - cd src/%CONFIGURATION%
81 - stockfish bench 2> out.txt >NUL
84 $s = (gc "./out.txt" | out-string)
85 $r = ($s -match 'Nodes searched \D+(\d+)' | % { $matches[1] })
86 Write-Host "Engine bench:" $r
87 Write-Host "Reference bench:" $bench
88 If ($r -ne $bench) { exit 1 }