wxWidgets/misc/scripts/check_unused_headers
Vadim Zeitlin 3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00

91 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
#
# Name: check_unused_headers
# Purpose: checks all wxWidgets headers looking for headers not referenced anywhere
# Usage: run with --verbose for verbose output
# Copyright: (c) 2007 Francesco Montorsi
# Licence: wxWindows licence
################################################################################
if [[ "$1" = "-v" || "$1" = "--verbose" ]]; then
verbose=yes
else
verbose=no
fi
me=$(basename $0)
path=${0%%/$me} # path from which the script has been launched
current=$(pwd)
# the path where this script resides:
scriptPath=$current/$path
# other interesting wx paths
headerPath="$scriptPath/../../include"
srcPath="$scriptPath/../../src"
# get list of wx source and header filenames
# NOTE: these list won't contain the .svn backup copies of the real sources/headers
# NOTE2: we keep the size of these lists small avoiding to include the prefixes
# like e.g. ../../include so to not incurr in OS limits when passing
# them as arguments of commands
cd $headerPath
headerList=`find wx -name "*.h"`
cd $srcPath
srcList=`find . -name "*.cpp"`
unusedHeaders=0
function checkIfHeaderIsUsed
{
local headerToCheck="$1"
local found=no
if [[ $verbose = yes ]]; then
echo -n "checking if header: $headerToCheck is used... "
fi
# find the first occurrence of this header in wx sources and headers:
cd $headerPath
grep -m 1 "$headerToCheck" $headerList >/dev/null 2>&1
if [[ $? = 0 ]]; then found=yes; fi
cd $srcPath
grep -m 1 "$headerToCheck" $srcList >/dev/null 2>&1
if [[ $? = 0 ]]; then found=yes; fi
if [[ $found = no ]]; then
if [[ $verbose = yes ]]; then
echo "no, it's not!"
fi
# this header is not used anywhere...
echo "WARNING: unused header $headerToCheck"
((( unusedHeaders++ )))
else
if [[ $verbose = yes ]]; then
echo "yes, it is"
fi
fi
}
echo " This script will look for unused wxWidgets headers"
echo " Note that some headers maybe not referenced by wxWidgets sources/headers but still"
echo " be useful for user applications; others instead are simply old and forgotten."
echo
for header in $headerList; do
checkIfHeaderIsUsed $header
done
if [[ $unusedHeaders -gt 0 ]]; then
echo " => WARNING: found $unusedHeaders unused headers!"
else
echo " => All headers are referenced in either wxWidgets sources or in other headers"
fi