From b0110256e5d0f77830f5d8419dc4939402462e00 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 7 Jan 2020 02:02:19 +0300 Subject: boost/build: add the --link parameter --- boost/build/build.py | 34 ++++++++++++++++++++++++++++++++++ boost/build/ci/appveyor.py | 15 +++++++++++---- boost/build/ci/travis.py | 7 +++++++ 3 files changed, 52 insertions(+), 4 deletions(-) (limited to 'boost/build') diff --git a/boost/build/build.py b/boost/build/build.py index 02ab9b0..e04aa30 100755 --- a/boost/build/build.py +++ b/boost/build/build.py @@ -100,6 +100,25 @@ def _parse_configuration(s): raise argparse.ArgumentTypeError(f'invalid configuration: {s}') +class Link(Enum): + STATIC = 'static' + SHARED = 'shared' + + @staticmethod + def all(): + return tuple(Link) + + def __str__(self): + return self.value + + +def _parse_link(s): + try: + return Link(s) + except ValueError: + raise argparse.ArgumentTypeError(f'invalid linkage: {s}') + + Version = namedtuple('Version', ['major', 'minor', 'patch']) @@ -303,6 +322,7 @@ class BoostBuild: def __init__(self, args): self.platforms = args.platforms or Platform.all() self.configurations = args.configurations or Configuration.all() + self.link = args.link or Link.all() self.stage_dir = 'stage' @@ -316,6 +336,7 @@ class BoostBuild: for platform in self.platforms: platform_params = [f'--build-dir={build_dir}'] platform_params.append(self._address_model(platform)) + platform_params.append(self._linkage()) platform_params += self.b2_args if _on_windows(): platform_params.append(self._windows_stagedir(platform)) @@ -343,6 +364,10 @@ class BoostBuild: logging.info('Removing build directory: %s', build_dir) return + def _linkage(self): + link = ','.join(map(str, self.link)) + return f'link={link}' + @staticmethod def _address_model(platform): return f'address-model={platform.get_address_model()}' @@ -389,6 +414,8 @@ def _parse_args(argv=None): build = subparsers.add_parser('build', help='build Boost libraries') + # These are used to put the built libraries into proper stage/ + # subdirectories (to avoid name clashes). build.add_argument('--platform', metavar='PLATFORM', nargs='*', dest='platforms', default=[], type=_parse_platform, @@ -397,6 +424,13 @@ def _parse_args(argv=None): nargs='*', dest='configurations', default=[], type=_parse_configuration, help='target configuration (e.g. Debug/Release)') + # This is needed because the default behaviour on Linux and Windows is + # different: static & dynamic libs are built on Linux, but only static libs + # are built on Windows by default. + build.add_argument('--link', metavar='LINKAGE', + nargs='*', default=[], + type=_parse_link, + help='how the libraries are linked (i.e. static/shared)') build.add_argument('--build', metavar='DIR', dest='build_dir', type=_parse_dir, diff --git a/boost/build/ci/appveyor.py b/boost/build/ci/appveyor.py index 3f8d0cd..e6a330d 100644 --- a/boost/build/ci/appveyor.py +++ b/boost/build/ci/appveyor.py @@ -56,6 +56,8 @@ def _parse_args(argv=None): logging.info('Command line arguments: %s', argv) parser = argparse.ArgumentParser() + parser.add_argument('--link', metavar='LINKAGE', nargs='*', + help='how the libraries are linked (i.e. static/shared)') parser.add_argument('b2_args', nargs='*', metavar='B2_ARG', default=[], help='additional b2 arguments, to be passed verbatim') return parser.parse_args(argv) @@ -71,20 +73,25 @@ def build_appveyor(argv=None): from build import BoostVersion, main as build_main version = BoostVersion.from_string(_get_boost_version()) - travis_argv = [ + appveyor_argv = [ 'download', '--unpack', _get_build_dir(), '--', str(version) ] - build_main(travis_argv) + build_main(appveyor_argv) - travis_argv = [ + appveyor_argv = [ 'build', '--configuration', _get_configuration(), '--platform', _get_platform(), + ] + if args.link is not None: + appveyor_argv.append('--link') + appveyor_argv += args.link + appveyor_argv += [ '--', version.dir_path(_get_build_dir()), ] - build_main(travis_argv + args.b2_args) + build_main(appveyor_argv + args.b2_args) def main(argv=None): diff --git a/boost/build/ci/travis.py b/boost/build/ci/travis.py index d5d00eb..74ba29f 100755 --- a/boost/build/ci/travis.py +++ b/boost/build/ci/travis.py @@ -54,6 +54,8 @@ def _parse_args(argv=None): logging.info('Command line arguments: %s', argv) parser = argparse.ArgumentParser() + parser.add_argument('--link', metavar='LINKAGE', nargs='*', + help='how the libraries are linked (i.e. static/shared)') parser.add_argument('b2_args', nargs='*', metavar='B2_ARG', default=[], help='additional b2 arguments, to be passed verbatim') return parser.parse_args(argv) @@ -80,6 +82,11 @@ def build_travis(argv=None): 'build', '--configuration', _get_configuration(), '--platform', _get_platform(), + ] + if args.link is not None: + travis_argv.append('--link') + travis_argv += args.link + travis_argv += [ '--', version.dir_path(_get_build_dir()), ] build_main(travis_argv + args.b2_args) -- cgit v1.2.3