|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright (c) 2018 The Bitcoin Core developers |
| 4 | +# Distributed under the MIT software license, see the accompanying |
| 5 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 6 | +# |
| 7 | +# Check for circular dependencies |
| 8 | + |
| 9 | +export LC_ALL=C |
| 10 | + |
| 11 | +EXPECTED_CIRCULAR_DEPENDENCIES=( |
| 12 | + "chainparamsbase -> util -> chainparamsbase" |
| 13 | + "checkpoints -> validation -> checkpoints" |
| 14 | + "index/txindex -> validation -> index/txindex" |
| 15 | + "policy/fees -> txmempool -> policy/fees" |
| 16 | + "policy/policy -> validation -> policy/policy" |
| 17 | + "qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel" |
| 18 | + "qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel" |
| 19 | + "qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui" |
| 20 | + "qt/bitcoingui -> qt/walletframe -> qt/bitcoingui" |
| 21 | + "qt/bitcoingui -> qt/walletview -> qt/bitcoingui" |
| 22 | + "qt/clientmodel -> qt/peertablemodel -> qt/clientmodel" |
| 23 | + "qt/paymentserver -> qt/walletmodel -> qt/paymentserver" |
| 24 | + "qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel" |
| 25 | + "qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog" |
| 26 | + "qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel" |
| 27 | + "qt/walletmodel -> qt/walletmodeltransaction -> qt/walletmodel" |
| 28 | + "rpc/rawtransaction -> wallet/rpcwallet -> rpc/rawtransaction" |
| 29 | + "txmempool -> validation -> txmempool" |
| 30 | + "validation -> validationinterface -> validation" |
| 31 | + "wallet/coincontrol -> wallet/wallet -> wallet/coincontrol" |
| 32 | + "wallet/fees -> wallet/wallet -> wallet/fees" |
| 33 | + "wallet/rpcwallet -> wallet/wallet -> wallet/rpcwallet" |
| 34 | + "wallet/wallet -> wallet/walletdb -> wallet/wallet" |
| 35 | + "policy/fees -> policy/policy -> validation -> policy/fees" |
| 36 | + "policy/rbf -> txmempool -> validation -> policy/rbf" |
| 37 | + "qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/addressbookpage" |
| 38 | + "qt/guiutil -> qt/walletmodel -> qt/optionsmodel -> qt/guiutil" |
| 39 | + "txmempool -> validation -> validationinterface -> txmempool" |
| 40 | + "qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/receivecoinsdialog -> qt/addressbookpage" |
| 41 | + "qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/signverifymessagedialog -> qt/addressbookpage" |
| 42 | + "qt/guiutil -> qt/walletmodel -> qt/optionsmodel -> qt/intro -> qt/guiutil" |
| 43 | + "qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/sendcoinsdialog -> qt/sendcoinsentry -> qt/addressbookpage" |
| 44 | +) |
| 45 | + |
| 46 | +EXIT_CODE=0 |
| 47 | + |
| 48 | +CIRCULAR_DEPENDENCIES=() |
| 49 | + |
| 50 | +IFS=$'\n' |
| 51 | +for CIRC in $(cd src && ../contrib/devtools/circular-dependencies.py {*,*/*,*/*/*}.{h,cpp} | sed -e 's/^Circular dependency: //'); do |
| 52 | + CIRCULAR_DEPENDENCIES+=($CIRC) |
| 53 | + IS_EXPECTED_CIRC=0 |
| 54 | + for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do |
| 55 | + if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then |
| 56 | + IS_EXPECTED_CIRC=1 |
| 57 | + break |
| 58 | + fi |
| 59 | + done |
| 60 | + if [[ ${IS_EXPECTED_CIRC} == 0 ]]; then |
| 61 | + echo "A new circular dependency in the form of \"${CIRC}\" appears to have been introduced." |
| 62 | + echo |
| 63 | + EXIT_CODE=1 |
| 64 | + fi |
| 65 | +done |
| 66 | + |
| 67 | +for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do |
| 68 | + IS_PRESENT_EXPECTED_CIRC=0 |
| 69 | + for CIRC in "${CIRCULAR_DEPENDENCIES[@]}"; do |
| 70 | + if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then |
| 71 | + IS_PRESENT_EXPECTED_CIRC=1 |
| 72 | + break |
| 73 | + fi |
| 74 | + done |
| 75 | + if [[ ${IS_PRESENT_EXPECTED_CIRC} == 0 ]]; then |
| 76 | + echo "Good job! The circular dependency \"${EXPECTED_CIRC}\" is no longer present." |
| 77 | + echo "Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in $0" |
| 78 | + echo "to make sure this circular dependency is not accidentally reintroduced." |
| 79 | + echo |
| 80 | + EXIT_CODE=1 |
| 81 | + fi |
| 82 | +done |
| 83 | + |
| 84 | +exit ${EXIT_CODE} |
0 commit comments