aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/ci/appveyor/generator.py
blob: 454bd4a95ac100aa69c9a24561608a89a6018c02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
# This file is part of the "cmake-common" project.
# For details, see https://github.com/egor-tensin/cmake-common.
# Distributed under the MIT License.

from enum import Enum

from project.utils import env


class Image(Enum):
    VS_2013 = 'Visual Studio 2013'
    VS_2015 = 'Visual Studio 2015'
    VS_2017 = 'Visual Studio 2017'
    VS_2019 = 'Visual Studio 2019'

    def __str__(self):
        return str(self.value)

    @staticmethod
    def parse(s):
        try:
            return Image(s)
        except ValueError as e:
            raise ValueError(f'unsupported AppVeyor image: {s}') from e

    @staticmethod
    def get():
        return Image.parse(env('APPVEYOR_BUILD_WORKER_IMAGE'))

    def get_prebuilt_boost_dir(self):
        # As of 2021-01-25, these are the latest pre-built Boost distributions:
        # https://www.appveyor.com/docs/windows-images-software/#boost
        if self is Image.VS_2013:
            return 'C:\\Libraries\\boost_1_58_0'
        if self is Image.VS_2015:
            return 'C:\\Libraries\\boost_1_69_0'
        if self is Image.VS_2017:
            return 'C:\\Libraries\\boost_1_69_0'
        if self is Image.VS_2019:
            return 'C:\\Libraries\\boost_1_73_0'
        raise NotImplementedError(f'unsupported AppVeyor image: {self}')


class Generator(Enum):
    VS_2013 = 'Visual Studio 12 2013'
    VS_2015 = 'Visual Studio 14 2015'
    VS_2017 = 'Visual Studio 15 2017'
    VS_2019 = 'Visual Studio 16 2019'

    def __str__(self):
        return str(self.value)

    @staticmethod
    def from_image(image):
        if image is Image.VS_2013:
            return Generator.VS_2013
        if image is Image.VS_2015:
            return Generator.VS_2015
        if image is Image.VS_2017:
            return Generator.VS_2017
        if image is Image.VS_2019:
            return Generator.VS_2019
        raise RuntimeError(f"don't know which generator to use for image: {image}")