]>
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
7 # Licence: wxWindows licence
8 ################################################################################
12 if [[ "$1" = "-v" || "$1" = "--verbose" ]]; then
20 path
=${0%%/$me} # path from which the script has been launched
23 # the path where this script resides:
24 scriptPath
=$current/$path
26 # other interesting wx paths
27 headerPath
="$scriptPath/../../include"
28 srcPath
="$scriptPath/../../src"
30 # get list of wx source and header filenames
31 # NOTE: these list won't contain the .svn backup copies of the real sources/headers
32 # NOTE2: we keep the size of these lists small avoiding to include the prefixes
33 # like e.g. ../../include so to not incurr in OS limits when passing
34 # them as arguments of commands
36 headerList
=`find wx -name "*.h"`
38 srcList
=`find . -name "*.cpp"`
43 function checkIfHeaderIsUsed
45 local headerToCheck
="$1"
48 if [[ $verbose = yes ]]; then
49 echo -n "checking if header: $headerToCheck is used... "
52 # find the first occurrence of this header in wx sources and headers:
54 grep -m 1 "$headerToCheck" $headerList >/dev
/null
2>&1
55 if [[ $?
= 0 ]]; then found
=yes; fi
58 grep -m 1 "$headerToCheck" $srcList >/dev
/null
2>&1
59 if [[ $?
= 0 ]]; then found
=yes; fi
61 if [[ $found = no
]]; then
63 if [[ $verbose = yes ]]; then
67 # this header is not used anywhere...
68 echo "WARNING: unused header $headerToCheck"
69 ((( unusedHeaders
++ )))
71 if [[ $verbose = yes ]]; then
77 echo " This script will look for unused wxWidgets headers"
78 echo " Note that some headers maybe not referenced by wxWidgets sources/headers but still"
79 echo " be useful for user applications; others instead are simply old and forgotten."
82 for header
in $headerList; do
83 checkIfHeaderIsUsed
$header
86 if [[ $unusedHeaders -gt 0 ]]; then
87 echo " => WARNING: found $unusedHeaders unused headers!"
89 echo " => All headers are referenced in either wxWidgets sources or in other headers"