aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/ci/boost.py
blob: c17c9db9482d31582c25df31d0fffce86533249b (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
# 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 argparse
import logging
import sys

from project.boost.download import DownloadParameters, download
from project.boost.build import BuildParameters, build
from project.linkage import Linkage


def _parse_args(dirs, argv=None):
    if argv is None:
        argv = sys.argv[1:]
    logging.info('Command line arguments: %s', argv)

    parser = argparse.ArgumentParser(
        description=dirs.get_boost_help(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument('--link', metavar='LINKAGE',
                        nargs='*', type=Linkage.parse,
                        help='how the libraries are linked')
    parser.add_argument('--runtime-link', metavar='LINKAGE',
                        type=Linkage.parse,
                        help='how the libraries link to the runtime')
    parser.add_argument('--mingw', action='store_true',
                        help='build using MinGW-w64')
    parser.add_argument('b2_args', metavar='B2_ARG',
                        nargs='*', default=[],
                        help='additional b2 arguments, to be passed verbatim')

    return parser.parse_args(argv)


def build_ci(dirs, argv=None):
    args = _parse_args(dirs, argv)

    version = dirs.get_boost_version()
    build_dir = dirs.get_build_dir()
    boost_dir = dirs.get_boost_dir()
    params = DownloadParameters(version, unpack_dir=build_dir, dest_path=boost_dir)
    download(params)

    params = BuildParameters(boost_dir,
                             platforms=(dirs.get_platform(),),
                             configurations=(dirs.get_configuration(),),
                             link=args.link,
                             runtime_link=args.runtime_link,
                             mingw=args.mingw,
                             b2_args=args.b2_args)
    build(params)