poppler: Upgrade 24.05.0
[LibreOffice.git] / bin / find-unusedheaders.sh
blob0a27696cc161bfb927abe9c66338925f6639aee6
1 #!/usr/bin/env bash
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # Search for headers not included in any source files
10 # Note: there are still exceptions (such as ODK) so results are not completely foolproof
12 # Search in all subdirs, except for those not containing C/C++ headers
13 for subdir in $(ls -d */ | grep -v \
14 -e include/ `# Handled differently` \
15 -e android \
16 -e animations `# No headers here` \
17 -e bean \
18 -e bin/ `# Skip subdirs not containing C/C++ code ` \
19 -e cpputools/ \
20 -e distro-configs/ \
21 -e docmodel/ `# No headers here` \
22 -e eventattacher/ \
23 -e external/ `# FIXME Should be handled differently, but it\'s such a mess` \
24 -e extras/ \
25 -e i18nlangtag/ \
26 -e icon-themes/ \
27 -e idlc/ \
28 -e instsetoo_native/ \
29 -e jurt/ \
30 -e jvmaccess/ \
31 -e librelogo/ \
32 -e m4/ \
33 -e msicreator/ \
34 -e nlpsolver/ \
35 -e offapi/ \
36 -e officecfg/ \
37 -e oovbaapi/ \
38 -e osx/ \
39 -e pch/ \
40 -e postprocess/ \
41 -e qadevOOo/ \
42 -e readlicense_oo/ \
43 -e remotebridges/ \
44 -e reportbuilder/ \
45 -e ridljar/ \
46 -e schema/ \
47 -e scp2/ \
48 -e smoketest/ \
49 -e swext/ \
50 -e sysui/ \
51 -e udkapi/ \
52 -e uitest/ \
53 -e unoil/ \
54 -e unotest/ \
55 -e ure/ \
56 -e wizards/ \
57 -e xmerge/ \
58 -e xmlreader/ \
59 -e instdir/ `# Skip typical build-related temporaries` \
60 -e workdir/ \
61 -e autom4te.cache/ \
62 -e config_host/ \
63 -e dictionaries/ `# Skip typical submodules` \
64 -e helpcontent2/ \
65 -e translations/
66 ) ; do
68 # Get a feeling of progress :)
69 echo "Checking module: $subdir";
71 # Find all .h / .hxx files and see if they are mentioned in the module
72 # skip special directories: pch and precompiled_ (compilerplugins does not have separate pch dir), workben (playground code), test (dead code?)
73 for i in $(find "$subdir" -name "*\.h" -o -name "*\.hxx" -o -name "\.hrc" -o -name "*\.hlst" | grep -v -e "/pch/" -e "/precompiled_" -e "/workben/" -e "/test/" | xargs basename -a ); do
74 # Search only in source files, and skip mentions in makefiles, .yaml, clang-format excludelist etc.
75 if [ $(git grep -l "$i" "$subdir"/{*\.[hc]xx,*\.[hc],*\.hrc,*\.mm,*\.m,*\.py} | wc -l) -eq 0 ] ; then
76 echo "Out of use header: $(find "$subdir" -name "$i")";
78 done
79 done
81 echo "Checking global headers";
82 # Search for files in include is different since they can be used in any module
83 for i in $(find include/ -name "*\.h" -o -name "*\.hxx" -o -name "\.hrc" | cut -d "/" -f 2- ); do
84 # Some headers are only included between double quotes
85 if [ $(git grep -l -e \<$i\> -e \"$i\" {*\.[hc]xx,*\.[hc],*\.hrc,*\.mm,*\.m} | grep -v pch | wc -l) -eq 0 ] ; then
86 echo "Out of use header: include/$i";
88 done