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/dirs.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 '')
-rw-r--r-- | project/ci/dirs.py | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/project/ci/dirs.py b/project/ci/dirs.py new file mode 100644 index 0000000..9234df2 --- /dev/null +++ b/project/ci/dirs.py @@ -0,0 +1,99 @@ +# 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. + +import abc +import os.path + +from project.boost.version import Version +from project.ci.appveyor.generator import Generator, Image +from project.configuration import Configuration +from project.platform import Platform +from project.utils import env + + +class Dirs(abc.ABC): + def __init__(self): + pass + + @abc.abstractmethod + def get_platform(self): + pass + + @abc.abstractmethod + def get_configuration(self): + pass + + @abc.abstractmethod + def get_src_dir(self): + pass + + @abc.abstractmethod + def get_build_dir(self): + pass + + def get_boost_version(self): + return Version.from_string(env('boost_version')) + + def get_boost_dir(self): + return os.path.join(self.get_build_dir(), 'boost') + + def get_cmake_dir(self): + return os.path.join(self.get_build_dir(), 'build') + + @abc.abstractmethod + def get_cmake_args(self): + pass + + def get_boost_help(self): + return f'''Download & build Boost on Travis/AppVeyor. + +This is similar to running both project.boost.download & project.boost.build, +but auto-fills some parameters from environment variables. + +Boost is built in {self.get_boost_dir()}. +''' + + def get_cmake_help(self): + return f'''Build a CMake project on AppVeyor. + +This is similar to running project.cmake.build, but auto-fills some parameters +from environment variables. + +The project is built in {self.get_cmake_dir()}. +''' + + +class Travis(Dirs): + def get_platform(self): + return Platform.parse(env('platform')) + + def get_configuration(self): + return Configuration.parse(env('configuration')) + + def get_src_dir(self): + return env('TRAVIS_BUILD_DIR') + + def get_build_dir(self): + return env('HOME') + + def get_cmake_args(self): + return [] + + +class AppVeyor(Dirs): + def get_platform(self): + return Platform.parse(env('PLATFORM')) + + def get_configuration(self): + return Configuration.parse(env('CONFIGURATION')) + + def get_src_dir(self): + return env('APPVEYOR_BUILD_FOLDER') + + def get_build_dir(self): + return R'C:\projects' + + def get_cmake_args(self): + return ['-G', str(Generator.from_image(Image.get()))] |