Now that we have gbuild and gbuild only it should be rather easy to identify unused C/C++ headers. For this, this EasyHack asks to create a script that: - concats and sorts all the filenames mentioned in workdir/unxlngx6.pro/Dep/CxxObject and workdir/unxlngx6.pro/Dep/CObject - runs a `git ls-tree HEAD -r --name-only` - and reports files in the second that are not in the first. This might still create some false positives because of e.g. platform dependant files, but it should be a good starting point: Obviously such headers if truly unused, should be removed from the repository tree.
http://code.google.com/p/include-what-you-use/ might be useful.
Created attachment 87504 [details] compares workdir files with git ls-tree
(In reply to comment #2) > Created attachment 87504 [details] > compares workdir files with git ls-tree This is a work in progress quickly hacked perl script, which should do what is descibed in the request. Example output: http://sprunge.us/CZSh Note: I've disabled some options when compiling so there might be some false-positives ;)
(In reply to comment #0) > This might still create some false positives because of e.g. platform > dependant files, but it should be a good starting point: Obviously such > headers if truly unused, should be removed from the repository tree. Just a thought from a non-developer: what if we combine the output of all platforms (tinderboxes for example)? If header 'A' comes up in all output files, we can be (almost?) sure it isn't platform dependent. Isn't it? Kind regards, Joren
@Jelle: Awesome, quick work! Could you commit this to ./bin in the core repo (if you want to use gerrit, feel free to add me as a reviewer, so I can fasttrack that)? @Jorendc: Lets see how much false-positives there really are. If they are too many we might e.g. blacklist them (per platform). Another possibility would be to do `git grep` on the basename of the header and then see if there is any include statement for it. But first, lets get the script as-is in. ;)
I just picked three results from the list (http://sprunge.us/CZSh) and all of them were found using "git grep <include file>": vertcurs_mask.h salframeview.h and weakbase.h
Yes, there shouldn't be many of them, because I did a cleanup some month ago. See 0f11f30ea96fcec8d7c648089fc223a6fbed6aef, bbac35af148ed6c9f19386e4721fa38b500f45a1, and more... I searched for all *.h and *.hxx files and grepped if they are included or referenced in any way - if not I removed them.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=1793e5c1ff5d4b84178b4805026b8d455f32b0e5 fdo#70371: Initial perl script The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Closing this one as fixed as it is clearly working. @Jelle: Congratulations for fixing this Easy Hack. Feel free to file a follow up Easy Hack to: - run this one regularly manually and recheck the list - provide a blacklist of known false positives - create a way to run this e.g. on a tinderbox and check if there are new headers in the list - ...
Bjoern Michaelsen committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=e4fbcc549a143992f72333404adb0180afa69e1a fdo#70371: create findunusedheaders target The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyBeginner SkillScript ) [NinjaEdit]
Remove LibreOffice Dev List from CC on EasyHacks (curtailing excessive email to list) [NinjaEdit]