55# file COPYING or http://www.opensource.org/licenses/mit-license.php.
66#
77# Check for duplicate includes.
8+ # Guard against accidental introduction of new Boost dependencies.
89
910filter_suffix () {
1011 git ls-files | grep -E " ^src/.*\.${1} " ' $' | grep -Ev " /(leveldb|secp256k1|univalue)/"
1112}
1213
1314EXIT_CODE=0
15+
1416for HEADER_FILE in $( filter_suffix h) ; do
1517 DUPLICATE_INCLUDES_IN_HEADER_FILE=$( grep -E " ^#include " < " ${HEADER_FILE} " | sort | uniq -d)
1618 if [[ ${DUPLICATE_INCLUDES_IN_HEADER_FILE} != " " ]]; then
@@ -20,6 +22,7 @@ for HEADER_FILE in $(filter_suffix h); do
2022 EXIT_CODE=1
2123 fi
2224done
25+
2326for CPP_FILE in $( filter_suffix cpp) ; do
2427 DUPLICATE_INCLUDES_IN_CPP_FILE=$( grep -E " ^#include " < " ${CPP_FILE} " | sort | uniq -d)
2528 if [[ ${DUPLICATE_INCLUDES_IN_CPP_FILE} != " " ]]; then
@@ -29,4 +32,69 @@ for CPP_FILE in $(filter_suffix cpp); do
2932 EXIT_CODE=1
3033 fi
3134done
35+
36+ EXPECTED_BOOST_INCLUDES=(
37+ boost/algorithm/string.hpp
38+ boost/algorithm/string/case_conv.hpp
39+ boost/algorithm/string/classification.hpp
40+ boost/algorithm/string/join.hpp
41+ boost/algorithm/string/predicate.hpp
42+ boost/algorithm/string/replace.hpp
43+ boost/algorithm/string/split.hpp
44+ boost/assign/std/vector.hpp
45+ boost/bind.hpp
46+ boost/chrono/chrono.hpp
47+ boost/date_time/posix_time/posix_time.hpp
48+ boost/filesystem.hpp
49+ boost/filesystem/detail/utf8_codecvt_facet.hpp
50+ boost/filesystem/fstream.hpp
51+ boost/interprocess/sync/file_lock.hpp
52+ boost/multi_index/hashed_index.hpp
53+ boost/multi_index/ordered_index.hpp
54+ boost/multi_index/sequenced_index.hpp
55+ boost/multi_index_container.hpp
56+ boost/optional.hpp
57+ boost/preprocessor/cat.hpp
58+ boost/preprocessor/stringize.hpp
59+ boost/program_options/detail/config_file.hpp
60+ boost/scoped_array.hpp
61+ boost/signals2/connection.hpp
62+ boost/signals2/last_value.hpp
63+ boost/signals2/signal.hpp
64+ boost/test/unit_test.hpp
65+ boost/thread.hpp
66+ boost/thread/condition_variable.hpp
67+ boost/thread/mutex.hpp
68+ boost/thread/thread.hpp
69+ boost/variant.hpp
70+ boost/variant/apply_visitor.hpp
71+ boost/variant/static_visitor.hpp
72+ )
73+
74+ for BOOST_INCLUDE in $( git grep ' ^#include <boost/' -- " *.cpp" " *.h" | cut -f2 -d: | cut -f2 -d' <' | cut -f1 -d' >' | sort -u) ; do
75+ IS_EXPECTED_INCLUDE=0
76+ for EXPECTED_BOOST_INCLUDE in " ${EXPECTED_BOOST_INCLUDES[@]} " ; do
77+ if [[ " ${BOOST_INCLUDE} " == " ${EXPECTED_BOOST_INCLUDE} " ]]; then
78+ IS_EXPECTED_INCLUDE=1
79+ break
80+ fi
81+ done
82+ if [[ ${IS_EXPECTED_INCLUDE} == 0 ]]; then
83+ EXIT_CODE=1
84+ echo " A new Boost dependency in the form of \" ${BOOST_INCLUDE} \" appears to have been introduced:"
85+ git grep " ${BOOST_INCLUDE} " -- " *.cpp" " *.h"
86+ echo
87+ fi
88+ done
89+
90+ for EXPECTED_BOOST_INCLUDE in " ${EXPECTED_BOOST_INCLUDES[@]} " ; do
91+ if ! git grep -q " ^#include <${EXPECTED_BOOST_INCLUDE} >" -- " *.cpp" " *.h" ; then
92+ echo " Good job! The Boost dependency \" ${EXPECTED_BOOST_INCLUDE} \" is no longer used."
93+ echo " Please remove it from EXPECTED_BOOST_INCLUDES in $0 "
94+ echo " to make sure this dependency is not accidentally reintroduced."
95+ echo
96+ EXIT_CODE=1
97+ fi
98+ done
99+
32100exit ${EXIT_CODE}
0 commit comments