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/boost/directory.py | |
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/boost/directory.py')
-rw-r--r-- | project/boost/directory.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/project/boost/directory.py b/project/boost/directory.py new file mode 100644 index 0000000..e50041f --- /dev/null +++ b/project/boost/directory.py @@ -0,0 +1,60 @@ +# 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 logging +import os.path + +from project.utils import cd, run, on_windows + + +class BoostDir: + def __init__(self, path): + if not os.path.isdir(path): + raise RuntimeError(f"Boost directory doesn't exist: {path}") + self.path = path + + def _go(self): + return cd(self.path) + + def build(self, params): + with self._go(): + self._bootstrap_if_required() + self._b2(params) + + def _bootstrap_if_required(self): + if os.path.isfile(self._b2_path()): + logging.info('Not going to bootstrap, b2 is already there') + return + self.bootstrap() + + def bootstrap(self): + with self._go(): + run(self._bootstrap_path()) + + def _b2(self, params): + for b2_params in params.enum_b2_args(): + run([self._b2_path()] + b2_params) + + @staticmethod + def _bootstrap_path(): + return os.path.join('.', BoostDir._bootstrap_name()) + + @staticmethod + def _bootstrap_name(): + ext = '.sh' + if on_windows(): + ext = '.bat' + return f'bootstrap{ext}' + + @staticmethod + def _b2_path(): + return os.path.join('.', BoostDir._b2_name()) + + @staticmethod + def _b2_name(): + ext = '' + if on_windows(): + ext = '.exe' + return f'b2{ext}' |