]> git.saurik.com Git - wxWidgets.git/blame - misc/scripts/check_unused_headers
removing early init, fixes #12231
[wxWidgets.git] / misc / scripts / check_unused_headers
CommitLineData
eedb553a
FM
1#!/bin/bash
2#
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# Version: $Id$
8# Licence: wxWindows licence
9################################################################################
10
11
12
13if [[ "$1" = "-v" || "$1" = "--verbose" ]]; then
14 verbose=yes
15else
16 verbose=no
17fi
18
19
20me=$(basename $0)
21path=${0%%/$me} # path from which the script has been launched
22current=$(pwd)
23
24# the path where this script resides:
25scriptPath=$current/$path
26
27# other interesting wx paths
28headerPath="$scriptPath/../../include"
29srcPath="$scriptPath/../../src"
30
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
36cd $headerPath
37headerList=`find wx -name "*.h"`
38cd $srcPath
39srcList=`find . -name "*.cpp"`
40
41
42unusedHeaders=0
43
44function checkIfHeaderIsUsed
45{
46 local headerToCheck="$1"
47 local found=no
48
49 if [[ $verbose = yes ]]; then
50 echo -n "checking if header: $headerToCheck is used... "
51 fi
52
53 # find the first occurrence of this header in wx sources and headers:
54 cd $headerPath
55 grep -m 1 "$headerToCheck" $headerList >/dev/null 2>&1
56 if [[ $? = 0 ]]; then found=yes; fi
57
58 cd $srcPath
59 grep -m 1 "$headerToCheck" $srcList >/dev/null 2>&1
60 if [[ $? = 0 ]]; then found=yes; fi
61
62 if [[ $found = no ]]; then
63
64 if [[ $verbose = yes ]]; then
65 echo "no, it's not!"
66 fi
67
68 # this header is not used anywhere...
69 echo "WARNING: unused header $headerToCheck"
70 ((( unusedHeaders++ )))
71 else
72 if [[ $verbose = yes ]]; then
73 echo "yes, it is"
74 fi
75 fi
76}
77
78echo " This script will look for unused wxWidgets headers"
79echo " Note that some headers maybe not referenced by wxWidgets sources/headers but still"
80echo " be useful for user applications; others instead are simply old and forgotten."
81echo
82
83for header in $headerList; do
84 checkIfHeaderIsUsed $header
85done
86
87if [[ $unusedHeaders -gt 0 ]]; then
88 echo " => WARNING: found $unusedHeaders unused headers!"
89else
90 echo " => All headers are referenced in either wxWidgets sources or in other headers"
91fi