Bug 70373 - Identify unused source files
Summary: Identify unused source files
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: low minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyMedium, easyHack, skillScript
Depends on:
Blocks:
 
Reported: 2013-10-11 11:47 UTC by Björn Michaelsen
Modified: 2020-05-11 18:35 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
proof of concept (1.19 KB, text/plain)
2013-10-11 11:47 UTC, Björn Michaelsen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Michaelsen 2013-10-11 11:47:59 UTC
Created attachment 87450 [details]
proof of concept

gbuild now has a pretty complete view of the build and thus we can identify
which C/C++ files are used during the build. This can be used to identify cxx files in the repository that are never build and thus should be removed.

A simple approach to this would be the the one taken in fdo#70371: scan the dep
files.

An alternative is the attached patch which does not need a build and derives
the info directly from gbuild. The advantage here is, that with a bit of
tweaking, this could even 'see' which parts of the build are used on other
platforms (by switching some variables from config_host.mk).

So this Easy Hack is to start with one of the approaches above:
- make them work with C/C++/Objective C files
- compare the result with `git ls-tree` output (see fdo#70731)
- output possibly unused files in the repository

bonuspoints for making this aware of multiple platforms to reduce false
positives, but this is not required to close this bug as resolved/fixed. ;)
Comment 1 Varadharajan Chandran 2013-10-14 02:25:08 UTC
I would like to work on this bug but am new to this and this would be my first. Can someone please guide?
Comment 2 Björn Michaelsen 2013-10-14 11:52:04 UTC
@Varadharajan: Well, since somebody already provided a script at https://bugs.freedesktop.org/show_bug.cgi?id=70371 -- you need to get your build going e.g. as per https://wiki.documentfoundation.org/Development/BuildingOnLinux and then modify the script to scan for source files, not headers.

In general please dont ask for "please guide" in general, but with a concrete question, so we can help you. Also chat (libreoffice-dev on freenode) is a better medium for this as we can help you interactively:

 http://webchat.freenode.net/?channels=libreoffice-dev
Comment 3 Varadharajan Chandran 2013-10-14 14:44:23 UTC
Okay thanks for the pointer. I have already got my build going. will look into the script provided
(In reply to comment #2)
> @Varadharajan: Well, since somebody already provided a script at
> https://bugs.freedesktop.org/show_bug.cgi?id=70371 -- you need to get your
> build going e.g. as per
> https://wiki.documentfoundation.org/Development/BuildingOnLinux and then
> modify the script to scan for source files, not headers.
> 
> In general please dont ask for "please guide" in general, but with a
> concrete question, so we can help you. Also chat (libreoffice-dev on
> freenode) is a better medium for this as we can help you interactively:
> 
>  http://webchat.freenode.net/?channels=libreoffice-dev
Comment 4 Robinson Tryon (qubit) 2015-12-14 06:50:15 UTC Comment hidden (obsolete)
Comment 5 Robinson Tryon (qubit) 2016-02-18 14:51:58 UTC Comment hidden (obsolete)
Comment 6 Gabor Kelemen (allotropia) 2020-05-11 18:35:37 UTC
We have bin/find-files-not-referenced-by-makefile.py since:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=b0a07d94095883c17ab444801a27d30819aec201

I think we can close this, thanks to Noel Grandin :)