diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-07 02:02:19 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-07 02:13:48 +0300 |
commit | b0110256e5d0f77830f5d8419dc4939402462e00 (patch) | |
tree | d19bba977ebf10ea9259409c2d36b01ac35d00a2 /boost/build/build.py | |
parent | boost/build: remove --label (diff) | |
download | cmake-common-b0110256e5d0f77830f5d8419dc4939402462e00.tar.gz cmake-common-b0110256e5d0f77830f5d8419dc4939402462e00.zip |
boost/build: add the --link parameter
Diffstat (limited to '')
-rwxr-xr-x | boost/build/build.py | 34 |
1 files changed, 34 insertions, 0 deletions
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, |