1#!/usr/bin/env python
2# Build the project on AppVeyor.
3
4import os
5from subprocess import check_call
6
7build = os.environ['BUILD']
8config = os.environ['CONFIGURATION']
9platform = os.environ.get('PLATFORM')
10path = os.environ['PATH']
11cmake_command = ['cmake', '-DFMT_PEDANTIC=ON', '-DCMAKE_BUILD_TYPE=' + config]
12if build == 'mingw':
13    cmake_command.append('-GMinGW Makefiles')
14    build_command = ['mingw32-make', '-j4']
15    test_command = ['mingw32-make', 'test']
16    # Remove the path to Git bin directory from $PATH because it breaks
17    # MinGW config.
18    path = path.replace(r'C:\Program Files (x86)\Git\bin', '')
19    os.environ['PATH'] = r'C:\MinGW\bin;' + path
20else:
21    # Add MSBuild 14.0 to PATH as described in
22    # http://help.appveyor.com/discussions/problems/2229-v140-not-found-on-vs2105rc.
23    os.environ['PATH'] = r'C:\Program Files (x86)\MSBuild\14.0\Bin;' + path
24    generator = 'Visual Studio 14 2015'
25    if platform == 'x64':
26        generator += ' Win64'
27    cmake_command.append('-G' + generator)
28    build_command = ['cmake', '--build', '.', '--config', config, '--', '/m:4']
29    test_command = ['ctest', '-C', config]
30
31check_call(cmake_command)
32check_call(build_command)
33check_call(test_command)
34