9 # Operating system (build VM template)
10 os: Visual Studio 2017
12 # Build platform, i.e. x86, x64, AnyCPU. This setting is optional.
17 # build Configuration, i.e. Debug, Release, etc.
23 # The build fail immediately once one of the job fails
26 # Scripts that are called at very beginning, before repo cloning
34 $src = get-childitem -Path *.cpp -Recurse | select -ExpandProperty FullName
36 $src = $src.Replace("\", "/")
38 # Build CMakeLists.txt
39 $t = 'cmake_minimum_required(VERSION 3.8)',
41 'set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src)',
42 'set(source_files', $src, ')',
43 'add_executable(stockfish ${source_files})'
45 # Write CMakeLists.txt withouth BOM
46 $MyPath = (Get-Item -Path "." -Verbose).FullName + '\CMakeLists.txt'
47 $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
48 [System.IO.File]::WriteAllLines($MyPath, $t, $Utf8NoBomEncoding)
50 # Obtain bench reference from git log
51 $b = git log HEAD | sls "\b[Bb]ench[ :]+[0-9]{7}" | select -first 1
52 $bench = $b -match '\D+(\d+)' | % { $matches[1] }
53 Write-Host "Reference bench:" $bench
54 $g = "Visual Studio 15 2017"
55 If (${env:PLATFORM} -eq 'x64') { $g = $g + ' Win64' }
57 Write-Host "Generated files for: " $g
60 - cmake --build . --config %CONFIGURATION% -- /verbosity:minimal
63 - cd src/%CONFIGURATION%
64 - stockfish bench 2> out.txt >NUL
67 $s = (gc "./out.txt" | out-string)
68 $r = ($s -match 'Nodes searched \D+(\d+)' | % { $matches[1] })
69 Write-Host "Engine bench:" $r
70 Write-Host "Reference bench:" $bench
71 If ($r -ne $bench) { exit 1 }