Improve appeyor build
[stockfish] / appveyor.yml
1 version: 1.0.{build}
2 clone_depth: 50
3
4 branches:
5   only:
6     - master
7     - appveyor
8
9 # Operating system (build VM template)
10 os: Visual Studio 2015
11
12 # Build platform, i.e. x86, x64, AnyCPU. This setting is optional.
13 platform:
14   - x86
15   - x64
16   - Any CPU
17
18 # build Configuration, i.e. Debug, Release, etc.
19 configuration: Debug
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.8)',
39            'project(Stockfish)',
40            'set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src)',
41            'set(source_files', $src, ')',
42            'add_executable(stockfish ${source_files})'
43
44       # Write CMakeLists.txt withouth BOM
45       $MyPath = (Get-Item -Path "." -Verbose).FullName + '\CMakeLists.txt'
46       $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
47       [System.IO.File]::WriteAllLines($MyPath, $t, $Utf8NoBomEncoding)
48
49       # Obtain bench reference from git log
50       $b = git log HEAD | sls "\b[Bb]ench[ :]+[0-9]{7}" | select -first 1
51       $bench = $b -match '\D+(\d+)' | % { $matches[1] }
52       Write-Host "Reference bench:" $bench
53
54 build_script:
55   - cmake -G "Visual Studio 14 2015 Win64" .
56   - cmake --build .
57
58 before_test:
59   - cd src/Debug
60   - ps: |
61       # Verify bench number
62       ./stockfish bench 2> out.txt 1> null
63       $s = (gc "./out.txt" | out-string)
64       $r = ($s -match 'Nodes searched \D+(\d+)' | % { $matches[1] })
65       Write-Host "Engine bench:" $r
66       Write-Host "Reference bench:" $bench
67       If ($r -ne $bench) { exit 1 }