Changeset View
Changeset View
Standalone View
Standalone View
test/lint/lint-circular-dependencies.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
# | # | ||||
# Copyright (c) 2018 The Bitcoin Core developers | # Copyright (c) 2018 The Bitcoin Core developers | ||||
# 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. | ||||
# | # | ||||
# Check for circular dependencies | # Check for circular dependencies | ||||
export LC_ALL=C | export LC_ALL=C | ||||
set -euo pipefail | |||||
: "${TOPLEVEL:=$(git rev-parse --show-toplevel)}" | |||||
EXPECTED_CIRCULAR_DEPENDENCIES=( | EXPECTED_CIRCULAR_DEPENDENCIES=( | ||||
"index/txindex -> validation -> index/txindex" | "index/txindex -> validation -> index/txindex" | ||||
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel" | "qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel" | ||||
"qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel" | "qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel" | ||||
"qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui" | "qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui" | ||||
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui" | "qt/bitcoingui -> qt/walletframe -> qt/bitcoingui" | ||||
"qt/bitcoingui -> qt/walletview -> qt/bitcoingui" | "qt/bitcoingui -> qt/walletview -> qt/bitcoingui" | ||||
"qt/clientmodel -> qt/peertablemodel -> qt/clientmodel" | "qt/clientmodel -> qt/peertablemodel -> qt/clientmodel" | ||||
Show All 18 Lines | EXPECTED_CIRCULAR_DEPENDENCIES=( | ||||
"pow/aserti32d -> validation -> pow/aserti32d" | "pow/aserti32d -> validation -> pow/aserti32d" | ||||
"pow/aserti32d -> validation -> pow/pow -> pow/aserti32d" | "pow/aserti32d -> validation -> pow/pow -> pow/aserti32d" | ||||
) | ) | ||||
EXIT_CODE=0 | EXIT_CODE=0 | ||||
CIRCULAR_DEPENDENCIES=() | CIRCULAR_DEPENDENCIES=() | ||||
pushd "${TOPLEVEL}" | |||||
IFS=$'\n' | IFS=$'\n' | ||||
for CIRC in $(cd src && ../contrib/devtools/circular-dependencies.py {*,*/*,*/*/*}.{h,cpp} | sed -e 's/^Circular dependency: //'); do | for CIRC in $(cd src && ../contrib/devtools/circular-dependencies.py {*,*/*,*/*/*}.{h,cpp} | sed -e 's/^Circular dependency: //'); do | ||||
CIRCULAR_DEPENDENCIES+=("$CIRC") | CIRCULAR_DEPENDENCIES+=("$CIRC") | ||||
IS_EXPECTED_CIRC=0 | IS_EXPECTED_CIRC=0 | ||||
for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do | for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do | ||||
if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then | if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then | ||||
IS_EXPECTED_CIRC=1 | IS_EXPECTED_CIRC=1 | ||||
break | break | ||||
Show All 18 Lines | if [[ ${IS_PRESENT_EXPECTED_CIRC} == 0 ]]; then | ||||
echo "Good job! The circular dependency \"${EXPECTED_CIRC}\" is no longer present." | echo "Good job! The circular dependency \"${EXPECTED_CIRC}\" is no longer present." | ||||
echo "Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in $0" | echo "Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in $0" | ||||
echo "to make sure this circular dependency is not accidentally reintroduced." | echo "to make sure this circular dependency is not accidentally reintroduced." | ||||
echo | echo | ||||
EXIT_CODE=1 | EXIT_CODE=1 | ||||
fi | fi | ||||
done | done | ||||
popd | |||||
exit ${EXIT_CODE} | exit ${EXIT_CODE} |