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` \
16 -e animations
`# No headers here` \
18 -e bin
/ `# Skip subdirs not containing C/C++ code ` \
21 -e docmodel
/ `# No headers here` \
23 -e external
/ `# FIXME Should be handled differently, but it\'s such a mess` \
28 -e instsetoo_native
/ \
59 -e instdir
/ `# Skip typical build-related temporaries` \
63 -e dictionaries
/ `# Skip typical submodules` \
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")";
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";