diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-30 11:56:05 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-30 12:03:37 +0300 |
commit | 98e3a56296cb9955e49adb09a111f26e07328338 (patch) | |
tree | bbbd6a464a809c00398bc12ef4cb472f92b30eab /project/ci/appveyor/generator.py | |
parent | project.cmake: make it --boost aware (diff) | |
download | cmake-common-98e3a56296cb9955e49adb09a111f26e07328338.tar.gz cmake-common-98e3a56296cb9955e49adb09a111f26e07328338.zip |
project.ci: dedupe code
Diffstat (limited to 'project/ci/appveyor/generator.py')
-rw-r--r-- | project/ci/appveyor/generator.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/project/ci/appveyor/generator.py b/project/ci/appveyor/generator.py new file mode 100644 index 0000000..dc1fa13 --- /dev/null +++ b/project/ci/appveyor/generator.py @@ -0,0 +1,51 @@ +# 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 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')) + + +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 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}") |