Merge remote-tracking branch 'upstream/master' into HEAD
[stockfish] / appveyor.yml
1 version: 1.0.{build}
2 clone_depth: 50
3
4 branches:
5   only:
6     - master
7
8 # Operating system (build VM template)
9 os: Visual Studio 2019
10
11 # Build platform, i.e. x86, x64, AnyCPU. This setting is optional.
12 platform:
13   - x86
14   - x64
15
16 # build Configuration, i.e. Debug, Release, etc.
17 configuration:
18   - Debug
19   - Release
20
21 matrix:
22   # The build fail immediately once one of the job fails
23   fast_finish: true
24
25 # Scripts that are called at very beginning, before repo cloning
26 init:
27   - cmake --version
28   - msbuild /version
29
30 before_build:
31   - ps: |
32       # Get sources
33       $src = get-childitem -Path *.cpp -Recurse | select -ExpandProperty FullName
34       $src = $src -join ' '
35       $src = $src.Replace("\", "/")
36
37       # Build CMakeLists.txt
38       $t = 'cmake_minimum_required(VERSION 3.17)',
39            'project(Stockfish)',
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})'
46
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)
51
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
61
62 build_script:
63   - cmake --build . --config %CONFIGURATION% -- /verbosity:minimal
64
65 before_test:
66   - cd src/%CONFIGURATION%
67   - stockfish bench 2> out.txt >NUL
68   - ps: |
69       # Verify bench number
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 }