diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-28 23:01:09 +0000 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-28 23:54:46 +0000 |
commit | c58a3787eca9c0c4a7f376ba841cd7e39ab95ece (patch) | |
tree | 709b5ab8385bbb952912206ae561fbe5e1e752d8 /project/ci/travis | |
parent | project.boost: factor out BoostVersion (diff) | |
download | cmake-common-c58a3787eca9c0c4a7f376ba841cd7e39ab95ece.tar.gz cmake-common-c58a3787eca9c0c4a7f376ba841cd7e39ab95ece.zip |
project.boost: factor out everything else
I finally snapped. This starts to resemble sensible structure though.
Diffstat (limited to 'project/ci/travis')
-rw-r--r-- | project/ci/travis/boost.py | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/project/ci/travis/boost.py b/project/ci/travis/boost.py index 6d3e911..b8e843f 100644 --- a/project/ci/travis/boost.py +++ b/project/ci/travis/boost.py @@ -1,11 +1,9 @@ -#!/usr/bin/env python3 - # Copyright (c) 2019 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. -'''Download & build Boost on Travis. +R'''Download & build Boost on Travis. This is similar to build.py, but auto-fills some parameters for build.py from the Travis-defined environment variables. @@ -20,7 +18,12 @@ import os.path import sys from project.boost.version import Version -from project.boost.build import main as build_main +from project.boost.download import DownloadParameters, download +from project.boost.build import BuildParameters, build +from project.configuration import Configuration +from project.linkage import Linkage +from project.platform import Platform +import project.utils def _env(name): @@ -43,21 +46,15 @@ def _get_boost_dir(): def _get_boost_version(): - return _env('travis_boost_version') + return Version.from_string(_env('travis_boost_version')) def _get_configuration(): - return _env('configuration') + return Configuration.parse(_env('configuration')) def _get_platform(): - return _env('platform') - - -def _setup_logging(): - logging.basicConfig( - format='%(asctime)s | %(levelname)s | %(message)s', - level=logging.INFO) + return Platform.parse(_env('platform')) def _parse_args(argv=None): @@ -68,9 +65,9 @@ def _parse_args(argv=None): parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument('--link', metavar='LINKAGE', nargs='*', + parser.add_argument('--link', metavar='LINKAGE', nargs='*', type=Linkage.parse, help='how the libraries are linked') - parser.add_argument('--runtime-link', metavar='LINKAGE', + parser.add_argument('--runtime-link', metavar='LINKAGE', type=Linkage.parse, help='how the libraries link to the runtime') parser.add_argument('b2_args', nargs='*', metavar='B2_ARG', default=[], help='additional b2 arguments, to be passed verbatim') @@ -81,39 +78,26 @@ def build_travis(argv=None): args = _parse_args(argv) _check_travis() - version = Version.from_string(_get_boost_version()) - travis_argv = [ - 'download', - '--unpack', _get_build_dir(), - '--', str(version) - ] - build_main(travis_argv) + version = _get_boost_version() + build_dir = _get_build_dir() + download(DownloadParameters(version, unpack_dir=build_dir)) unpacked_boost_dir = version.dir_path(_get_build_dir()) boost_dir = _get_boost_dir() os.rename(unpacked_boost_dir, boost_dir) - travis_argv = [ - 'build', - '--configuration', _get_configuration(), - '--platform', _get_platform(), - ] - if args.link is not None: - travis_argv.append('--link') - travis_argv += args.link - if args.runtime_link is not None: - travis_argv += ['--runtime-link', args.runtime_link] - travis_argv += ['--', boost_dir] - build_main(travis_argv + args.b2_args) + params = BuildParameters(boost_dir, + platforms=(_get_platform(),), + configurations=(_get_configuration(),), + link=args.link, + runtime_link=args.runtime_link, + b2_args=args.b2_args) + build(params) def main(argv=None): - _setup_logging() - try: + with project.utils.setup_logging(): build_travis(argv) - except Exception as e: - logging.exception(e) - raise if __name__ == '__main__': |