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
66 - cd src/%CONFIGURATION%
67 - stockfish bench 2> out.txt >NUL
70 $s = (gc "./out.txt" | out-string)
71 $r = ($s -match 'Nodes searched \D+(\d+)' | % { $matches[1] })
72 Write-Host "Engine bench:" $r
73 Write-Host "Reference bench:" $bench
74 If ($r -ne $bench) { exit 1 }