aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/ci
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-03-28 23:01:09 +0000
committerEgor Tensin <Egor.Tensin@gmail.com>2020-03-28 23:54:46 +0000
commitc58a3787eca9c0c4a7f376ba841cd7e39ab95ece (patch)
tree709b5ab8385bbb952912206ae561fbe5e1e752d8 /project/ci
parentproject.boost: factor out BoostVersion (diff)
downloadcmake-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')
-rw-r--r--project/ci/appveyor/boost.py66
-rw-r--r--project/ci/travis/boost.py62
2 files changed, 48 insertions, 80 deletions
diff --git a/project/ci/appveyor/boost.py b/project/ci/appveyor/boost.py
index aa2d77a..0a15b7b 100644
--- a/project/ci/appveyor/boost.py
+++ b/project/ci/appveyor/boost.py
@@ -1,11 +1,9 @@
-#!/usr/bin/env python3
-
# 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.
-'''Download & build Boost on AppVeyor.
+R'''Download & build Boost on AppVeyor.
This is similar to build.py, but auto-fills some parameters for build.py from
the AppVeyor-defined environment variables. This script is rarely usefull,
@@ -22,7 +20,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):
@@ -37,7 +40,7 @@ def _check_appveyor():
def _get_build_dir():
- return 'C:\\projects'
+ return R'C:\projects'
def _get_boost_dir():
@@ -45,21 +48,15 @@ def _get_boost_dir():
def _get_boost_version():
- return _env('appveyor_boost_version')
+ return Version.from_string(_env('appveyor_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):
@@ -70,9 +67,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 (i.e. static/shared)')
- 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')
@@ -83,39 +80,26 @@ def build_appveyor(argv=None):
args = _parse_args(argv)
_check_appveyor()
- version = Version.from_string(_get_boost_version())
- appveyor_argv = [
- 'download',
- '--unpack', _get_build_dir(),
- '--', str(version)
- ]
- build_main(appveyor_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())
+ unpacked_boost_dir = version.dir_path(build_dir)
boost_dir = _get_boost_dir()
os.rename(unpacked_boost_dir, boost_dir)
- appveyor_argv = [
- 'build',
- '--configuration', _get_configuration(),
- '--platform', _get_platform(),
- ]
- if args.link is not None:
- appveyor_argv.append('--link')
- appveyor_argv += args.link
- if args.runtime_link is not None:
- appveyor_argv += ['--runtime-link', args.runtime_link]
- appveyor_argv += ['--', boost_dir]
- build_main(appveyor_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_appveyor(argv)
- except Exception as e:
- logging.exception(e)
- raise
if __name__ == '__main__':
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__':