From 444094f20d0a38bf44eafdd578cc0160224f5553 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Wed, 9 Jun 2021 21:05:19 +0300 Subject: [PATCH] add helper script to remove boost namespace from the library and smoke-test the result --- .github/workflows/ci.yml | 6 +- .../pfr/detail/tie_from_structure_tuple.hpp | 2 +- misc/generate_cpp17.py | 2 +- misc/strip_boost_namespace.sh | 57 +++++++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100755 misc/strip_boost_namespace.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b66d90b..77578af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: - toolset: gcc-7 cxxstd: "03,11,14,17" os: ubuntu-18.04 - - toolset: gcc-9 + - toolset: gcc-9 # Do not remove! It is the only toolset that tests misc/strip_boost_namespace.sh cxxstd: "03,11,14,17,2a" os: ubuntu-18.04 - toolset: gcc-10 @@ -102,6 +102,10 @@ jobs: ./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release "${{matrix.cxxflags}}" "${{matrix.linkflags}}" "${{matrix.launcher}}" dist/bin/inspect libs/$LIBRARY + - name: Test boost namespace stripping + if: ${{matrix.compiler == 'gcc-9' }} + run: ../boost-root/libs/$LIBRARY/misc/strip_boost_namespace.sh + - name: Prepare coverage data if: matrix.gcov_tool run: | diff --git a/include/boost/pfr/detail/tie_from_structure_tuple.hpp b/include/boost/pfr/detail/tie_from_structure_tuple.hpp index a01fdd5..6ee0e0c 100644 --- a/include/boost/pfr/detail/tie_from_structure_tuple.hpp +++ b/include/boost/pfr/detail/tie_from_structure_tuple.hpp @@ -39,6 +39,6 @@ struct tie_from_structure_tuple : std::tuple { } }; -}}} // boost::pfr::detail +}}} // namespace boost::pfr::detail #endif // BOOST_PFR_DETAIL_TIE_FROM_STRUCTURE_TUPLE_HPP diff --git a/misc/generate_cpp17.py b/misc/generate_cpp17.py index ee94c32..9db94ba 100644 --- a/misc/generate_cpp17.py +++ b/misc/generate_cpp17.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# Copyright (c) 2016-2020 Antony Polukhin +# Copyright (c) 2016-2021 Antony Polukhin # # 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) diff --git a/misc/strip_boost_namespace.sh b/misc/strip_boost_namespace.sh new file mode 100755 index 0000000..e98fb5b --- /dev/null +++ b/misc/strip_boost_namespace.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Copyright (c) 2021 Antony Polukhin +# +# 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) + +TARGET_PATH="`dirname \"$0\"`/../../freestanding_pfr" +TARGET_PATH=`cd "${TARGET_PATH}";pwd` +SOURCE_PATH="`dirname \"$0\"`/.." +SOURCE_PATH=`cd "${SOURCE_PATH}";pwd` + + +echo "***** Copying from ${SOURCE_PATH} to ${TARGET_PATH}" +rm -rf ${TARGET_PATH} +mkdir ${TARGET_PATH} + +cp -rf ${SOURCE_PATH}/* ${TARGET_PATH} + +mv ${TARGET_PATH}/include/boost/* ${TARGET_PATH}/include/ +rm -rf ${TARGET_PATH}/include/boost +rm -rf ${TARGET_PATH}/test + +echo "***** Changing sources" +find ${TARGET_PATH} -type f | xargs sed -i 's|namespace boost { ||g' +find ${TARGET_PATH} -type f | xargs sed -i 's|namespace boost {||g' +find ${TARGET_PATH} -type f | xargs sed -i 's|} // namespace boost::| // namespace |g' + +find ${TARGET_PATH} -type f | xargs sed -i 's/::boost::pfr/::pfr/g' +find ${TARGET_PATH} -type f | xargs sed -i 's/boost::pfr/pfr/g' +find ${TARGET_PATH} -type f | xargs sed -i 's/BOOST_PFR_/PFR_/g' +find ${TARGET_PATH} -type f | xargs sed -i 's|boost/pfr|pfr|g' + +echo -n "***** Testing: " +if g++-9 -std=c++17 -DPFR_USE_LOOPHOLE=0 -DPFR_USE_CPP17=1 -I ${TARGET_PATH}/include/ ${TARGET_PATH}/example/motivating_example0.cpp && ./a.out > /dev/null; then + echo -n "OK" +else + echo -n "FAIL" + exit 2 +fi +if g++-9 -std=c++17 -DPFR_USE_LOOPHOLE=1 -DPFR_USE_CPP17=0 -I ${TARGET_PATH}/include/ ${TARGET_PATH}/example/motivating_example0.cpp && ./a.out > /dev/null; then + echo -n ", OK" +else + echo -n ", FAIL" + exit 3 +fi + +if g++-9 -std=c++17 -DPFR_USE_LOOPHOLE=0 -DPFR_USE_CPP17=0 -I ${TARGET_PATH}/include/ ${TARGET_PATH}/example/get.cpp && ./a.out > /dev/null; then + echo -e ", OK" +else + echo -e ", FAIL" + exit 4 +fi + +rm a.out || : + +echo "***** Done"