5
5
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
6
#
7
7
# Check for duplicate includes.
8
+ # Guard against accidental introduction of new Boost dependencies.
8
9
9
10
filter_suffix () {
10
11
git ls-files | grep -E " ^src/.*\.${1} " ' $' | grep -Ev " /(leveldb|secp256k1|univalue)/"
11
12
}
12
13
13
14
EXIT_CODE=0
15
+
14
16
for HEADER_FILE in $( filter_suffix h) ; do
15
17
DUPLICATE_INCLUDES_IN_HEADER_FILE=$( grep -E " ^#include " < " ${HEADER_FILE} " | sort | uniq -d)
16
18
if [[ ${DUPLICATE_INCLUDES_IN_HEADER_FILE} != " " ]]; then
@@ -20,6 +22,7 @@ for HEADER_FILE in $(filter_suffix h); do
20
22
EXIT_CODE=1
21
23
fi
22
24
done
25
+
23
26
for CPP_FILE in $( filter_suffix cpp) ; do
24
27
DUPLICATE_INCLUDES_IN_CPP_FILE=$( grep -E " ^#include " < " ${CPP_FILE} " | sort | uniq -d)
25
28
if [[ ${DUPLICATE_INCLUDES_IN_CPP_FILE} != " " ]]; then
@@ -29,4 +32,69 @@ for CPP_FILE in $(filter_suffix cpp); do
29
32
EXIT_CODE=1
30
33
fi
31
34
done
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
+
32
100
exit ${EXIT_CODE}
0 commit comments