Merge #13230: Simplify include analysis by enforcing the developer guide's include syntax
16e3cd380a
Clarify include recommendation (practicalswift)6d10f43738
Enforce the use of bracket syntax includes ("#include <foo.h>") (practicalswift)906bee8e5f
Use bracket syntax includes ("#include <foo.h>") (practicalswift) Pull request description: When analysing includes in the project it is often assumed that the preferred bracket include syntax (`#include <foo.h>`) mentioned in `developer-docs.md` is used consistently. @sipa:s excellent circular dependencies script [`circular-dependencies.py`](50c69b7801/contrib/devtools/circular-dependencies.py
) (#13228) is an example of a script making this reasonable assumption. This PR enables automatic Travis checking of the include syntax making sure that the bracket syntax includes (`#include <foo.h>`) is used consistently. Tree-SHA512: a414921aabe8e487ebed42f3f1cbd02fecd1add385065c1f2244cd602c31889e61fea5a801507ec501ef9bd309b05d3c999f915cec1c2b44f085bb0d2835c182
This commit is contained in:
commit
7c32b414b6
7 changed files with 33 additions and 22 deletions
|
@ -622,8 +622,8 @@ namespace {
|
||||||
|
|
||||||
- *Rationale*: Avoids confusion about the namespace context
|
- *Rationale*: Avoids confusion about the namespace context
|
||||||
|
|
||||||
- Prefer `#include <primitives/transaction.h>` bracket syntax instead of
|
- Use `#include <primitives/transaction.h>` bracket syntax instead of
|
||||||
`#include "primitives/transactions.h"` quote syntax when possible.
|
`#include "primitives/transactions.h"` quote syntax.
|
||||||
|
|
||||||
- *Rationale*: Bracket syntax is less ambiguous because the preprocessor
|
- *Rationale*: Bracket syntax is less ambiguous because the preprocessor
|
||||||
searches a fixed list of include directories without taking location of the
|
searches a fixed list of include directories without taking location of the
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "bench.h"
|
#include <bench/bench.h>
|
||||||
|
|
||||||
#include "uint256.h"
|
#include <uint256.h>
|
||||||
#include "random.h"
|
#include <random.h>
|
||||||
#include "consensus/merkle.h"
|
#include <consensus/merkle.h>
|
||||||
|
|
||||||
static void MerkleRoot(benchmark::State& state)
|
static void MerkleRoot(benchmark::State& state)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <x86intrin.h>
|
#include <x86intrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "crypto/sha256.h"
|
#include <crypto/sha256.h>
|
||||||
#include "crypto/common.h"
|
#include <crypto/common.h>
|
||||||
|
|
||||||
namespace sha256d64_avx2 {
|
namespace sha256d64_avx2 {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <x86intrin.h>
|
#include <x86intrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "crypto/sha256.h"
|
#include <crypto/sha256.h>
|
||||||
#include "crypto/common.h"
|
#include <crypto/common.h>
|
||||||
|
|
||||||
namespace sha256d64_sse41 {
|
namespace sha256d64_sse41 {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "stdlib.h"
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "rpc/blockchain.h"
|
#include <rpc/blockchain.h>
|
||||||
#include "test/test_bitcoin.h"
|
#include <test/test_bitcoin.h>
|
||||||
|
|
||||||
/* Equality between doubles is imprecise. Comparison should be done
|
/* Equality between doubles is imprecise. Comparison should be done
|
||||||
* with a small threshold of tolerance, rather than exact equality.
|
* with a small threshold of tolerance, rather than exact equality.
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "wallet/wallet.h"
|
#include <wallet/wallet.h>
|
||||||
#include "wallet/coinselection.h"
|
#include <wallet/coinselection.h>
|
||||||
#include "wallet/coincontrol.h"
|
#include <wallet/coincontrol.h>
|
||||||
#include "amount.h"
|
#include <amount.h>
|
||||||
#include "primitives/transaction.h"
|
#include <primitives/transaction.h>
|
||||||
#include "random.h"
|
#include <random.h>
|
||||||
#include "test/test_bitcoin.h"
|
#include <test/test_bitcoin.h>
|
||||||
#include "wallet/test/wallet_test_fixture.h"
|
#include <wallet/test/wallet_test_fixture.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
|
@ -6,9 +6,12 @@
|
||||||
#
|
#
|
||||||
# Check for duplicate includes.
|
# Check for duplicate includes.
|
||||||
# Guard against accidental introduction of new Boost dependencies.
|
# Guard against accidental introduction of new Boost dependencies.
|
||||||
|
# Check includes: Check for duplicate includes. Enforce bracket syntax includes.
|
||||||
|
|
||||||
|
IGNORE_REGEXP="/(leveldb|secp256k1|univalue)/"
|
||||||
|
|
||||||
filter_suffix() {
|
filter_suffix() {
|
||||||
git ls-files | grep -E "^src/.*\.${1}"'$' | grep -Ev "/(leveldb|secp256k1|univalue)/"
|
git ls-files | grep -E "^src/.*\.${1}"'$' | grep -Ev "${IGNORE_REGEXP}"
|
||||||
}
|
}
|
||||||
|
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
|
@ -105,4 +108,12 @@ for EXPECTED_BOOST_INCLUDE in "${EXPECTED_BOOST_INCLUDES[@]}"; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
QUOTE_SYNTAX_INCLUDES=$(git grep '^#include "' -- "*.cpp" "*.h" | grep -Ev "${IGNORE_REGEXP}")
|
||||||
|
if [[ ${QUOTE_SYNTAX_INCLUDES} != "" ]]; then
|
||||||
|
echo "Please use bracket syntax includes (\"#include <foo.h>\") instead of quote syntax includes:"
|
||||||
|
echo "${QUOTE_SYNTAX_INCLUDES}"
|
||||||
|
echo
|
||||||
|
EXIT_CODE=1
|
||||||
|
fi
|
||||||
|
|
||||||
exit ${EXIT_CODE}
|
exit ${EXIT_CODE}
|
||||||
|
|
Loading…
Reference in a new issue