From e5ecc9bb1f2c7de1800413927cece968c79ec3f0 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 3 Jul 2023 22:04:53 +0200 Subject: project.ci.cmake -> project.ci.build Accordingly, rename ci-cmake to ci-build. --- .github/workflows/ci_appveyor.yml | 2 +- .github/workflows/ci_github.yml | 2 +- .github/workflows/ci_travis.yml | 2 +- README.md | 6 +-- docs/ci.md | 4 +- project/ci/build.py | 79 +++++++++++++++++++++++++++++++++++++++ project/ci/cmake.py | 79 --------------------------------------- pyproject.toml | 2 +- 8 files changed, 88 insertions(+), 88 deletions(-) create mode 100644 project/ci/build.py delete mode 100644 project/ci/cmake.py diff --git a/.github/workflows/ci_appveyor.yml b/.github/workflows/ci_appveyor.yml index b1f5eab..1bd0625 100644 --- a/.github/workflows/ci_appveyor.yml +++ b/.github/workflows/ci_appveyor.yml @@ -48,6 +48,6 @@ jobs: - name: Build Boost run: python -m project.ci.boost --hint AppVeyor -- --with-filesystem - name: Build example project - run: python -m project.ci.cmake --hint AppVeyor --install + run: python -m project.ci.build --hint AppVeyor --install - name: Run example project run: ./.ci/run_foo.ps1 (Join-Path $env:APPVEYOR_BUILD_FOLDER .. build install bin foo) diff --git a/.github/workflows/ci_github.yml b/.github/workflows/ci_github.yml index bcac50c..96a52a2 100644 --- a/.github/workflows/ci_github.yml +++ b/.github/workflows/ci_github.yml @@ -47,6 +47,6 @@ jobs: - name: Build Boost run: python -m project.ci.boost -- --with-filesystem - name: Build example project - run: python -m project.ci.cmake --install --subdir examples/boost + run: python -m project.ci.build --install --subdir examples/boost - name: Run example project run: ./.ci/run_foo.ps1 (Join-Path $env:GITHUB_WORKSPACE .. build install bin foo) diff --git a/.github/workflows/ci_travis.yml b/.github/workflows/ci_travis.yml index 23f0686..256e61c 100644 --- a/.github/workflows/ci_travis.yml +++ b/.github/workflows/ci_travis.yml @@ -46,6 +46,6 @@ jobs: - name: Build Boost run: python -m project.ci.boost --hint Travis -- --with-filesystem - name: Build example project - run: python -m project.ci.cmake --hint Travis --install + run: python -m project.ci.build --hint Travis --install - name: Run example project run: ./.ci/run_foo.ps1 (Join-Path $env:TRAVIS_BUILD_DIR .. build install bin foo) diff --git a/README.md b/README.md index 94f5c56..9786fd9 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Installation | boost-build | `python3 -m project.boost.build` | project-build | `python3 -m project.build` | ci-boost | `python3 -m project.ci.boost` - | ci-cmake | `python3 -m project.ci.cmake` + | ci-build | `python3 -m project.ci.build` Toolsets -------- @@ -104,7 +104,7 @@ Everything is optional (use the `CC_*` CMake options to opt out). ### CI -Utility scripts `ci-boost` and `ci-cmake` allow building Boost and CMake +Utility scripts `ci-boost` and `ci-build` allow building Boost and CMake projects on multiple CI systems. They work by calling the generic scripts from above, auto-filling some parameters from environment variables. @@ -120,7 +120,7 @@ parameters from environment variables. | Install path | `$TRAVIS_BUILD_DIR/../build/install` | `%APPVEYOR_BUILD_FOLDER%\..\build\install` | `$GITHUB_WORKSPACE/../build/install` -For an example of how to integrate `ci-boost` and `ci-cmake` into a CI +For an example of how to integrate `ci-boost` and `ci-build` into a CI workflow, see [docs/ci.md](docs/ci.md). Tools diff --git a/docs/ci.md b/docs/ci.md index 2c02d98..6f31b6f 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -1,4 +1,4 @@ -`ci-boost` and `ci-cmake` are thin wrappers around `boost-download`/`boost-build` +`ci-boost` and `ci-build` are thin wrappers around `boost-download`/`boost-build` and `project-build` accordingly. They work by reading environment variables and passing their values as command line parameters to the more generic scripts. This facilitates matrix-building the project without too much fuss. @@ -18,7 +18,7 @@ env: - CONFIGURATION=Release PLATFORM=x64 before_script: ci-boost -- --with-filesystem -script: ci-cmake --install +script: ci-build --install ``` is roughly equivalent to running diff --git a/project/ci/build.py b/project/ci/build.py new file mode 100644 index 0000000..24fe34c --- /dev/null +++ b/project/ci/build.py @@ -0,0 +1,79 @@ +# Copyright (c) 2020 Egor Tensin +# 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 os.path +import sys + +from project.ci.dirs import Dirs +from project.build import BuildParameters, build +from project.utils import setup_logging +import project.version + + +def _parse_args(argv=None): + if argv is None: + argv = sys.argv[1:] + + parser = argparse.ArgumentParser( + description=Dirs.get_cmake_help(), + formatter_class=argparse.RawDescriptionHelpFormatter) + + project.version.add_to_arg_parser(parser) + + # The hint parameter is basically a workaround for when this is run on a + # CI, _but_ testing another CI is desired. This shouldn't be used in a + # real CI workflow. + parser.add_argument('--hint', metavar='CI_NAME', + choices=Dirs.all_ci_names(), + help=argparse.SUPPRESS) + parser.add_argument('--install', action='store_true', + help='install the project') + parser.add_argument('--boost', metavar='DIR', dest='boost_dir', + help='set Boost directory path') + parser.add_argument('--subdir', metavar='DIR', + help='relative project directory path') + parser.add_argument('cmake_args', nargs='*', metavar='CMAKE_ARG', default=[], + help='additional CMake arguments, to be passed verbatim') + return parser.parse_args(argv) + + +def build_ci(dirs, argv=None): + args = _parse_args(argv) + with setup_logging(): + if dirs is None: + dirs = Dirs.detect(args.hint) + + src_dir = dirs.get_src_dir() + if args.subdir: + src_dir = os.path.join(src_dir, args.subdir) + install_dir = dirs.get_install_dir() if args.install else None + + boost_dir = args.boost_dir + if not boost_dir: + # If we've built Boost using project.ci.boost already, use that. + # Otherwise, try to use the latest pre-built Boost provided by the CI + # system. + boost_dir = dirs.get_boost_dir() + if not os.path.isdir(boost_dir): + boost_dir = dirs.get_prebuilt_boost_dir() + + params = BuildParameters(src_dir, + build_dir=dirs.get_cmake_dir(), + install_dir=install_dir, + platform=dirs.get_platform(), + configuration=dirs.get_configuration(), + boost_dir=boost_dir, + toolset_version=dirs.get_toolset(), + cmake_args=dirs.get_cmake_args() + args.cmake_args) + build(params) + + +def main(argv=None): + build_ci(None, argv) + + +if __name__ == '__main__': + main() diff --git a/project/ci/cmake.py b/project/ci/cmake.py deleted file mode 100644 index 24fe34c..0000000 --- a/project/ci/cmake.py +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2020 Egor Tensin -# 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 os.path -import sys - -from project.ci.dirs import Dirs -from project.build import BuildParameters, build -from project.utils import setup_logging -import project.version - - -def _parse_args(argv=None): - if argv is None: - argv = sys.argv[1:] - - parser = argparse.ArgumentParser( - description=Dirs.get_cmake_help(), - formatter_class=argparse.RawDescriptionHelpFormatter) - - project.version.add_to_arg_parser(parser) - - # The hint parameter is basically a workaround for when this is run on a - # CI, _but_ testing another CI is desired. This shouldn't be used in a - # real CI workflow. - parser.add_argument('--hint', metavar='CI_NAME', - choices=Dirs.all_ci_names(), - help=argparse.SUPPRESS) - parser.add_argument('--install', action='store_true', - help='install the project') - parser.add_argument('--boost', metavar='DIR', dest='boost_dir', - help='set Boost directory path') - parser.add_argument('--subdir', metavar='DIR', - help='relative project directory path') - parser.add_argument('cmake_args', nargs='*', metavar='CMAKE_ARG', default=[], - help='additional CMake arguments, to be passed verbatim') - return parser.parse_args(argv) - - -def build_ci(dirs, argv=None): - args = _parse_args(argv) - with setup_logging(): - if dirs is None: - dirs = Dirs.detect(args.hint) - - src_dir = dirs.get_src_dir() - if args.subdir: - src_dir = os.path.join(src_dir, args.subdir) - install_dir = dirs.get_install_dir() if args.install else None - - boost_dir = args.boost_dir - if not boost_dir: - # If we've built Boost using project.ci.boost already, use that. - # Otherwise, try to use the latest pre-built Boost provided by the CI - # system. - boost_dir = dirs.get_boost_dir() - if not os.path.isdir(boost_dir): - boost_dir = dirs.get_prebuilt_boost_dir() - - params = BuildParameters(src_dir, - build_dir=dirs.get_cmake_dir(), - install_dir=install_dir, - platform=dirs.get_platform(), - configuration=dirs.get_configuration(), - boost_dir=boost_dir, - toolset_version=dirs.get_toolset(), - cmake_args=dirs.get_cmake_args() + args.cmake_args) - build(params) - - -def main(argv=None): - build_ci(None, argv) - - -if __name__ == '__main__': - main() diff --git a/pyproject.toml b/pyproject.toml index 87e8c3c..c6797f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ classifiers = [ boost-build = "project.boost.build:_main" boost-download = "project.boost.download:_main" ci-boost = "project.ci.boost:main" -ci-cmake = "project.ci.cmake:main" +ci-build = "project.ci.build:main" project-build = "project.build:main" [tool.setuptools] -- cgit v1.2.3