From 86f069fe70a8ece2829953264ef372d0a661b454 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 14 Dec 2019 03:46:03 +0300 Subject: build: clean up silly cmd line params They were just plain synonyms for CMake flags, barely had any value. --- ci/boost/build_travis.py | 2 ++ ci/build.py | 26 +++----------------------- ci/build_appveyor.py | 34 ++++++++++++++++++++++++++++++---- ci/build_travis.py | 12 ++++++++++++ 4 files changed, 47 insertions(+), 27 deletions(-) (limited to 'ci') diff --git a/ci/boost/build_travis.py b/ci/boost/build_travis.py index bfdccc0..de8c957 100755 --- a/ci/boost/build_travis.py +++ b/ci/boost/build_travis.py @@ -54,6 +54,7 @@ def build_travis(argv=None): argv = sys.argv[1:] logging.info('Command line arguments: %s', argv) _check_travis() + version = BoostVersion.from_string(_get_boost_version()) travis_argv = [ 'download', @@ -61,6 +62,7 @@ def build_travis(argv=None): '--', str(version) ] build_main(travis_argv) + travis_argv = [ 'build', '--configuration', _get_configuration(), diff --git a/ci/build.py b/ci/build.py index 0fb4478..c77216a 100755 --- a/ci/build.py +++ b/ci/build.py @@ -91,20 +91,10 @@ class GenerationPhase: @staticmethod def _to_cmake_args(build_dir, args): result = [] - if args.generator is not None: - result += ['-G', args.generator] - if args.platform is not None: - result += ['-A', args.platform] if args.install_dir is not None: result.append(f'-DCMAKE_INSTALL_PREFIX={args.install_dir}') if args.configuration is not None: result.append(f'-DCMAKE_BUILD_TYPE={args.configuration}') - if args.toolchain_path is not None: - result.append(f'-DCMAKE_TOOLCHAIN_FILE={args.toolchain_path}') - if args.boost_root is not None: - result.append(f'-DBOOST_ROOT={args.boost_root}') - if args.boost_librarydir is not None: - result.append(f'-DBOOST_LIBRARYDIR={args.boost_librarydir}') if args.cmake_args is not None: result += args.cmake_args result += [f'-B{build_dir.path}'] @@ -126,8 +116,6 @@ class BuildPhase: @staticmethod def _to_cmake_args(build_dir, args): result = ['--build', build_dir.path] - if args.clean_build_dir: - result.append('--clean-first') if args.configuration is not None: result += ['--config', str(args.configuration)] if args.install_dir is not None: @@ -163,9 +151,9 @@ def _parse_args(argv=None): if argv is None: argv = sys.argv[1:] logging.info('Command line arguments: %s', argv) + parser = argparse.ArgumentParser(description='Build a CMake project') - parser.add_argument('--src', required=True, dest='src_dir', - type=os.path.abspath, metavar='DIR', + parser.add_argument('--src', required=True, metavar='DIR', dest='src_dir', help='source directory') parser.add_argument('--build', metavar='DIR', dest='build_dir', help='build directory (temporary directory if not specified)') @@ -173,17 +161,9 @@ def _parse_args(argv=None): help='install directory') parser.add_argument('--clean', action='store_true', dest='clean_build_dir', help='clean the build directory (temporary directory will be removed)') - parser.add_argument('--generator', help='build system to use') - parser.add_argument('--platform', help='target platform (i.e. Win32/x64)') parser.add_argument('--configuration', metavar='CONFIG', - type=_parse_configuration, + type=_parse_configuration, default=Configuration.DEBUG, help='build configuration (i.e. Debug/Release)') - parser.add_argument('--toolchain', metavar='PATH', dest='toolchain_path', - help='CMake toolchain file path') - parser.add_argument('--boost', metavar='DIR', dest='boost_root', - help='set Boost directory') - parser.add_argument('--boost-librarydir', metavar='DIR', - help='set Boost library directory (stage/lib by default)') parser.add_argument('cmake_args', nargs='*', metavar='CMAKE_ARG', help='additional CMake arguments, to be passed verbatim') args = parser.parse_args(argv) diff --git a/ci/build_appveyor.py b/ci/build_appveyor.py index 2d2ee65..56b4d4b 100755 --- a/ci/build_appveyor.py +++ b/ci/build_appveyor.py @@ -9,6 +9,7 @@ # the AppVeyor-defined environment variables. # The project is built in C:\Projects\build. +import argparse from enum import Enum import logging import os @@ -77,6 +78,11 @@ def _env(name): return os.environ[name] +def _check_appveyor(): + if 'APPVEYOR' not in os.environ: + raise RuntimeError('not running on AppVeyor') + + def _get_src_dir(): return _env('APPVEYOR_BUILD_FOLDER') @@ -104,18 +110,38 @@ def _setup_logging(): level=logging.INFO) -def build_appveyor(argv=None): +def _parse_args(argv=None): if argv is None: argv = sys.argv[1:] logging.info('Command line arguments: %s', argv) + + parser = argparse.ArgumentParser(description='Build a CMake project on AppVeyor') + parser.add_argument('--install', metavar='DIR', dest='install_dir', + help='install directory') + parser.add_argument('cmake_args', nargs='*', metavar='CMAKE_ARG', + help='additional CMake arguments, to be passed verbatim') + return parser.parse_args(argv) + + +def build_appveyor(argv=None): + args = _parse_args(argv) + _check_appveyor() + appveyor_argv = [ '--src', _get_src_dir(), '--build', _get_build_dir(), - '--generator', _get_generator(), - '--platform', _get_platform(), '--configuration', _get_configuration(), ] - build(appveyor_argv + argv) + if args.install_dir is not None: + appveyor_argv += [ + '--install', args.install_dir, + ] + appveyor_argv += [ + '--', + '-G', _get_generator(), + '-A', _get_platform(), + ] + build(appveyor_argv + args.cmake_args) def main(argv=None): diff --git a/ci/build_travis.py b/ci/build_travis.py index dce7fd7..564f964 100755 --- a/ci/build_travis.py +++ b/ci/build_travis.py @@ -23,6 +23,11 @@ def _env(name): return os.environ[name] +def _check_travis(): + if 'TRAVIS' not in os.environ: + raise RuntimeError('not running on Travis') + + def _get_src_dir(): return _env('TRAVIS_BUILD_DIR') @@ -31,6 +36,10 @@ def _get_build_dir(): return os.path.join(_env('HOME'), 'build') +def _get_configuration(): + return _env('configuration') + + def _setup_logging(): logging.basicConfig( format='%(asctime)s | %(levelname)s | %(message)s', @@ -41,9 +50,12 @@ def build_travis(argv=None): if argv is None: argv = sys.argv[1:] logging.info('Command line arguments: %s', argv) + _check_travis() + travis_argv = [ '--src', _get_src_dir(), '--build', _get_build_dir(), + '--configuration', _get_configuration(), ] build(travis_argv + argv) -- cgit v1.2.3