diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..835681d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,390 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + - develop + - feature/** + +env: + UBSAN_OPTIONS: print_stacktrace=1 + +jobs: + posix: + strategy: + fail-fast: false + matrix: + include: + - toolset: gcc-4.8 + cxxstd: "03,11" + os: ubuntu-latest + container: ubuntu:18.04 + install: g++-4.8 + - toolset: gcc-5 + cxxstd: "03,11,14,1z" + os: ubuntu-latest + container: ubuntu:18.04 + install: g++-5 + - toolset: gcc-6 + cxxstd: "03,11,14,1z" + os: ubuntu-latest + container: ubuntu:18.04 + install: g++-6 + - toolset: gcc-7 + cxxstd: "03,11,14,17" + os: ubuntu-latest + container: ubuntu:18.04 + - toolset: gcc-8 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: g++-8 + - toolset: gcc-9 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + - toolset: gcc-10 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: g++-10 + - toolset: gcc-11 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: g++-11 + - toolset: gcc-12 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: g++-12 + - toolset: clang + compiler: clang++-3.9 + cxxstd: "03,11,14" + os: ubuntu-latest + container: ubuntu:18.04 + install: clang-3.9 + - toolset: clang + compiler: clang++-4.0 + cxxstd: "03,11,14" + os: ubuntu-latest + container: ubuntu:18.04 + install: clang-4.0 + - toolset: clang + compiler: clang++-5.0 + cxxstd: "03,11,14,1z" + os: ubuntu-latest + container: ubuntu:18.04 + install: clang-5.0 + - toolset: clang + compiler: clang++-6.0 + cxxstd: "03,11,14,17" + os: ubuntu-20.04 + install: clang-6.0 + - toolset: clang + compiler: clang++-7 + cxxstd: "03,11,14,17" + os: ubuntu-20.04 + install: clang-7 + - toolset: clang + compiler: clang++-8 + cxxstd: "03,11,14,17" + os: ubuntu-20.04 + install: clang-8 + - toolset: clang + compiler: clang++-9 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: clang-9 + - toolset: clang + compiler: clang++-10 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: clang-10 + - toolset: clang + compiler: clang++-11 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: clang-11 + - toolset: clang + compiler: clang++-12 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: clang-12 + - toolset: clang + compiler: clang++-13 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: clang-13 + - toolset: clang + compiler: clang++-14 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: clang-14 + - toolset: clang + cxxstd: "03,11,14,17,2a" + os: macos-11 + + runs-on: ${{matrix.os}} + container: ${{matrix.container}} + + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + + - name: Setup container environment + if: matrix.container + run: | + apt-get update + apt-get -y install sudo python git g++ + + - name: Install packages + if: matrix.install + run: sudo apt-get -y install ${{matrix.install}} + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + ./bootstrap.sh + ./b2 -d0 headers + + - name: Create user-config.jam + if: matrix.compiler + run: | + echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam + + - name: Run tests + run: | + cd ../boost-root + ./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release + + windows: + strategy: + fail-fast: false + matrix: + include: + - toolset: msvc-14.0 + cxxstd: "14,latest" + addrmd: 32,64 + os: windows-2019 + - toolset: msvc-14.2 + cxxstd: "14,17,20,latest" + addrmd: 32,64 + os: windows-2019 + - toolset: msvc-14.3 + cxxstd: "14,17,20,latest" + addrmd: 32,64 + os: windows-2022 + - toolset: clang-win + cxxstd: "14,17,latest" + addrmd: 32,64 + os: windows-2022 + - toolset: gcc + cxxstd: "03,11,14,17,2a" + addrmd: 64 + os: windows-2019 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + cmd /c bootstrap + b2 -d0 headers + + - name: Run tests + shell: cmd + run: | + cd ../boost-root + b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker + + posix-cmake-subdir: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + - os: ubuntu-22.04 + - os: macos-11 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Install packages + if: matrix.install + run: sudo apt-get -y install ${{matrix.install}} + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + + - name: Use library with add_subdirectory + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test + mkdir __build__ && cd __build__ + cmake .. + cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-install: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + - os: ubuntu-22.04 + - os: macos-11 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Install packages + if: matrix.install + run: sudo apt-get -y install ${{matrix.install}} + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local .. + + - name: Install + run: | + cd ../boost-root/__build__ + cmake --build . --target install + + - name: Use the installed library + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__ + cmake -DCMAKE_INSTALL_PREFIX=~/.local .. + cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-test: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + - os: ubuntu-22.04 + - os: macos-11 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Install packages + if: matrix.install + run: sudo apt-get -y install ${{matrix.install}} + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON .. + + - name: Build tests + run: | + cd ../boost-root/__build__ + cmake --build . --target tests + + - name: Run tests + run: | + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3201291 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +# Generated by `boostdep --cmake compat` +# Copyright 2020, 2021 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.8...3.20) + +project(boost_compat VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) + +add_library(boost_compat INTERFACE) +add_library(Boost::compat ALIAS boost_compat) + +target_include_directories(boost_compat INTERFACE include) + +target_compile_features(boost_compat INTERFACE cxx_std_11) + +if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") + + add_subdirectory(test) + +endif() diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..ff8f381 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,2 @@ +/pdf/ +/html/ diff --git a/doc/Jamfile b/doc/Jamfile new file mode 100644 index 0000000..1517a46 --- /dev/null +++ b/doc/Jamfile @@ -0,0 +1,21 @@ +# Copyright 2017, 2018, 2023 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt) + +import asciidoctor ; + +html compat.html : compat.adoc ; + +install html_ : compat.html : html ; + +pdf compat.pdf : compat.adoc ; +explicit compat.pdf ; + +install pdf_ : compat.pdf : pdf ; +explicit pdf_ ; + +############################################################################### +alias boostdoc ; +explicit boostdoc ; +alias boostrelease : html_ ; +explicit boostrelease ; diff --git a/doc/compat-docinfo-footer.html b/doc/compat-docinfo-footer.html new file mode 100644 index 0000000..d0d391a --- /dev/null +++ b/doc/compat-docinfo-footer.html @@ -0,0 +1,6 @@ + diff --git a/doc/compat.adoc b/doc/compat.adoc new file mode 100644 index 0000000..aa2e2e4 --- /dev/null +++ b/doc/compat.adoc @@ -0,0 +1,22 @@ +//// +Copyright 2018, 2023 Peter Dimov +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +# Boost.Compat +{cpp}11 Implementations of Standard Components Added in Later {cpp} Standards +:toc: left +:toclevels: 4 +:idprefix: +:docinfo: private-footer +:source-highlighter: rouge +:source-language: c++ + +:leveloffset: +1 + +include::compat/overview.adoc[] +include::compat/changelog.adoc[] +include::compat/copyright.adoc[] + +:leveloffset: -1 diff --git a/doc/compat/changelog.adoc b/doc/compat/changelog.adoc new file mode 100644 index 0000000..53b6b34 --- /dev/null +++ b/doc/compat/changelog.adoc @@ -0,0 +1,13 @@ +//// +Copyright 2023 Peter Dimov +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#changelog] +# Revision History +:idprefix: changelog_ + +## Changes in 1.83.0 + +* Initial release. diff --git a/doc/compat/copyright.adoc b/doc/compat/copyright.adoc new file mode 100644 index 0000000..8ce0850 --- /dev/null +++ b/doc/compat/copyright.adoc @@ -0,0 +1,12 @@ +//// +Copyright 2023 Peter Dimov +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#copyright] +# Copyright and License +:idprefix: + +This documentation is copyright 2023 Peter Dimov and is distributed under +the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0]. diff --git a/doc/compat/overview.adoc b/doc/compat/overview.adoc new file mode 100644 index 0000000..6090d6f --- /dev/null +++ b/doc/compat/overview.adoc @@ -0,0 +1,27 @@ +//// +Copyright 2023 Peter Dimov +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#overview] +# Overview +:idprefix: overview_ + +Boost.Compat is a repository of {cpp}11 implementations +of standard components added in later {cpp} standards. Its +target audience is Boost library authors whose libraries +support a lower {cpp} standard, but wish to utilize a component +added in a subsequent one. + +The criteria for inclusion in Boost.Compat are as follows: + +* The implementation should be relatively simple and + header-only. +* The component must implement the standard functionality + exactly, without deviations or extensions. This allows + (but does not require) the implementation to be a simple + `using` declaration in case the standard component is + available. +* The component must not depend on any Boost libraries + except Boost.Config, Boost.Assert, or Boost.ThrowException. diff --git a/index.html b/index.html new file mode 100644 index 0000000..7c77b9b --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + + +Automatic redirection failed, please go to +doc/html/compat.html. + + + diff --git a/meta/libraries.json b/meta/libraries.json new file mode 100644 index 0000000..05b3c6e --- /dev/null +++ b/meta/libraries.json @@ -0,0 +1,15 @@ +{ + "key": "compat", + "name": "Compat", + "authors": [ + "Peter Dimov" + ], + "maintainers": [ + "Peter Dimov " + ], + "description": "C++11 implementations of standard components added in later C++ standards.", + "category": [ + "Emulation", "Programming" + ], + "cxxstd": "11" +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..2ca3df7 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2018, 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) + +if(HAVE_BOOST_TEST) + +boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::compat Boost::core) + +endif() diff --git a/test/Jamfile b/test/Jamfile new file mode 100644 index 0000000..d4a1f67 --- /dev/null +++ b/test/Jamfile @@ -0,0 +1,23 @@ +# Boost.Compat Test Jamfile +# Copyright 2015-2023 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +import testing ; +import ../../config/checks/config : requires ; + +project + : default-build + + extra + + : requirements + + [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_decltype cxx11_constexpr ] + + msvc:on + gcc:on + clang:on + ; + +run quick.cpp ; diff --git a/test/cmake_install_test/CMakeLists.txt b/test/cmake_install_test/CMakeLists.txt new file mode 100644 index 0000000..84a0077 --- /dev/null +++ b/test/cmake_install_test/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018, 2019, 2023 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_install_test LANGUAGES CXX) + +find_package(boost_compat REQUIRED) + +add_executable(quick ../quick.cpp) +target_link_libraries(quick Boost::compat) + +enable_testing() +add_test(quick quick) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 0000000..8412e8b --- /dev/null +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2018, 2019, 2023 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_subdir_test LANGUAGES CXX) + +add_subdirectory(../.. boostorg/compat) + +add_subdirectory(../../../assert boostorg/assert) +add_subdirectory(../../../config boostorg/config) +add_subdirectory(../../../throw_exception boostorg/throw_exception) + +add_executable(quick ../quick.cpp) +target_link_libraries(quick Boost::compat) + +enable_testing() +add_test(quick quick) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/quick.cpp b/test/quick.cpp new file mode 100644 index 0000000..341c4f5 --- /dev/null +++ b/test/quick.cpp @@ -0,0 +1,7 @@ +// Copyright 2023 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +int main() +{ +}