]>
git.saurik.com Git - wxWidgets.git/blob - misc/scripts/check_unused_headers
3 # Name: check_unused_headers
4 # Purpose: checks all wxWidgets headers looking for headers not referenced anywhere
5 # Usage: run with --verbose for verbose output
6 # Copyright: (c) 2007 Francesco Montorsi
8 # Licence: wxWindows licence
9 ################################################################################
13 if [[ "$1" = "-v" || "$1" = "--verbose" ]]; then
21 path
=${0%%/$me} # path from which the script has been launched
24 # the path where this script resides:
25 scriptPath
=$current/$path
27 # other interesting wx paths
28 headerPath
="$scriptPath/../../include"
29 srcPath
="$scriptPath/../../src"
31 # get list of wx source and header filenames
32 # NOTE: these list won't contain the .svn backup copies of the real sources/headers
33 # NOTE2: we keep the size of these lists small avoiding to include the prefixes
34 # like e.g. ../../include so to not incurr in OS limits when passing
35 # them as arguments of commands
37 headerList
=`find wx -name "*.h"`
39 srcList
=`find . -name "*.cpp"`
44 function checkIfHeaderIsUsed
46 local headerToCheck
="$1"
49 if [[ $verbose = yes ]]; then
50 echo -n "checking if header: $headerToCheck is used... "
53 # find the first occurrence of this header in wx sources and headers:
55 grep -m 1 "$headerToCheck" $headerList >/dev
/null
2>&1
56 if [[ $?
= 0 ]]; then found
=yes; fi
59 grep -m 1 "$headerToCheck" $srcList >/dev
/null
2>&1
60 if [[ $?
= 0 ]]; then found
=yes; fi
62 if [[ $found = no
]]; then
64 if [[ $verbose = yes ]]; then
68 # this header is not used anywhere...
69 echo "WARNING: unused header $headerToCheck"
70 ((( unusedHeaders
++ )))
72 if [[ $verbose = yes ]]; then
78 echo " This script will look for unused wxWidgets headers"
79 echo " Note that some headers maybe not referenced by wxWidgets sources/headers but still"
80 echo " be useful for user applications; others instead are simply old and forgotten."
83 for header
in $headerList; do
84 checkIfHeaderIsUsed
$header
87 if [[ $unusedHeaders -gt 0 ]]; then
88 echo " => WARNING: found $unusedHeaders unused headers!"
90 echo " => All headers are referenced in either wxWidgets sources or in other headers"