4 # This file is part of LyX, the document processor.
5 # Licence details can be found in the file COPYING.
7 # author Scott Kostyshak
9 # Full author contact details are available in file CREDITS
13 # All .cpp and .h files in the current directory and subdirectories
14 # are checked to see which include statements could be omitted without
15 # causing a build error. Many of these omissions would not be desired.
16 # For example, currently if you don't include Undo.h in Undo.cpp, there
17 # is no error because Undo.h is included in Cursor.h which is included
18 # in Undo.cpp. But clearly we do want to include Undo.h in Undo.cpp.
20 # The results are stored in header_check.sh.log
24 LOG_FILE="$(basename $0).log"
26 # For only standard headers:
31 # Exclude common headers with regex
32 # (e.g. 'debug.h' will exclude 'support/debug.h')
33 # LyX was compiled on exotic environments and these sometimes
34 # require headers not needed on win/linux. So check the logs before
35 # deleting "redundant" standard libraries or includes around various
37 EXCLUDE='\(debug.h\|cstdio\)'
41 # This is not a clean make.
42 make -j$(grep "CPU" /proc/cpuinfo | wc -l)
45 echo "BUILD_FN exited without error after removing
46 the following include statements invididually:" > "${LOG_FILE}" \
47 || { echo "ERROR: could not create log file, ${LOG_FILE}"; exit 1; }
49 find -regex ".*\(cpp\|h\)$" | \
52 FILE_COPY=$( tempfile )
53 cp "${FILE_}" "${FILE_COPY}" \
54 || { echo "ERROR: bu copy failed" >&2; exit 1; }
55 echo "processing ${FILE_}..."
56 grep "${PATTERN}" "${FILE_}" | \
59 if echo "${INCLUDE}" | grep -q -v "${EXCLUDE}"; then
60 cp "${FILE_COPY}" "${FILE_}" \
61 || { echo "ERROR: restore copy failed" >&2; exit 1; }
62 sed -i "s@${INCLUDE}@@" "${FILE_}"
63 ( BUILD_FN ) &>/dev/null && echo "${FILE_}::${INCLUDE}" >> "${LOG_FILE}"
66 cp "${FILE_COPY}" "${FILE_}"