X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=development%2Ftools%2Fheader_check.sh;h=881fe1a6875a588945e87b624891eec2907b2d36;hb=6461d6aa1b01a97814020020e260c34c117a2631;hp=9b4125415845e86196cdb80b63bf951682c434e8;hpb=5ea35e2d62dc91ec767f13c435ee2172ed3dd6d2;p=lyx.git diff --git a/development/tools/header_check.sh b/development/tools/header_check.sh old mode 100644 new mode 100755 index 9b41254158..881fe1a687 --- a/development/tools/header_check.sh +++ b/development/tools/header_check.sh @@ -26,9 +26,9 @@ set -u LOG_FILE="$(basename $0).log" # For only standard headers: - PATTERN='^#include <' +# PATTERN='^#include <' # For all headers: -# PATTERN='^#include' + PATTERN='^#include' # Exclude common headers with regex # (e.g. 'debug.h' will exclude 'support/debug.h') @@ -36,7 +36,7 @@ LOG_FILE="$(basename $0).log" # require headers not needed on win/linux. So check the logs before # deleting "redundant" standard libraries, Qt headers or includes around # various ifdefs... -EXCLUDE='\(debug.h\|cstdio\|config\)' +EXCLUDE='\(debug.h\|cstdio\|config.h\)' NCORES=$(grep "CPU" /proc/cpuinfo | wc -l) @@ -45,15 +45,18 @@ function BUILD_FN () PREFIX='' # This is not a clean make. - IFS='' ERROR_OUTPUT=$(make -j${NCORES} 2>&1) + make -j${NCORES} 2>/dev/null 1>/dev/null ERROR_CODE=$? - # Without the grep, ERROR_OUTPUT might contain messages such as: - # 2885 translated messages, 2169 fuzzy translations, 1356 untranslated messages. - ERROR_OUTPUT=$(echo "${ERROR_OUTPUT}" | grep -i "error: ") # The sed regex is more strict than it needs to be. if (( ERROR_CODE != 0 )); then + # Use just one core, so we don't mix outputs + IFS='' ERROR_OUTPUT=$(make 2>&1) + # Without the grep, ERROR_OUTPUT might contain messages such as: + # 2885 translated messages, 2169 fuzzy translations, 1356 untranslated messages. + ERROR_OUTPUT=$(echo "${ERROR_OUTPUT}" | grep -i "error: ") + cppORh=$(echo "${ERROR_OUTPUT}" | head -n 1 | \ sed 's/.*\.\(cpp\|h\):[0-9]\+:[0-9]\+: error: .*/\1/') if [ "${cppORh}" = "cpp" ]; then @@ -75,7 +78,7 @@ make -j${NCORES} 2>&1 >/dev/null || exit echo "BUILD_FN exited without error after removing the following include statements invididually:" > "${LOG_FILE}" \ || { echo "ERROR: could not create log file, ${LOG_FILE}"; exit 1; } -find -regex ".*\(cpp\|h\)$" | \ +find -regex ".*\(cpp\|h\)$" | grep -vE "frontends/qt4/ui_|frontends/qt4/moc_" | sort | while read FILE_ do FILE_COPY=$( tempfile ) @@ -96,7 +99,9 @@ do if [ "${BUILD_FN_RET}" = 0 ]; then echo "${FILE_}::${INCLUDE}" >> "${LOG_FILE}" elif [ -n "${PREFIX}" ]; then - echo "${PREFIX}${FILE_}::${INCLUDE}" >> "${LOG_FILE}" + if [ ${FILE_:(-2):2} == .h ]; then + echo "${PREFIX}${FILE_}::${INCLUDE}" >> "${LOG_FILE}" + fi fi fi done