Bug 1832

Summary: deheader for ns-3
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: coreAssignee: ns-bugs <ns-bugs>
Status: PATCH WANTED ---    
Severity: enhancement CC: ns-bugs, tommaso.pecorella
Priority: P5    
Version: unspecified   
Hardware: PC   
OS: Linux   
Attachments: deheader.py (modified for use with ns-3-dev)
deheader report (from bug 1237)

Description Tom Henderson 2014-01-12 17:58:00 EST
This is a carry-over from work done on bug 1237.

Removing unnecessary header inclusions improves compilation time.  Some projects exist to automate this, including:
http://code.google.com/p/include-what-you-use/

Daniel Camara spent some time a while back to work on deheader for ns-3.  His findings, however, were not yet merged, and need to be updated.

Steps to work on this:

- configure ns-3 without python bindings (the python bindings will change due to this work).  './waf configure --disable-python'

- try to reduce the unnecessary includes such as already found by the attached. 

- consider to run deheader.py yourself on the codebase

- submit patches to one of the ns-3 maintainers, or attach to this bug report
Comment 1 Tom Henderson 2014-01-12 17:59:38 EST
Created attachment 1757 [details]
deheader.py (modified for use with ns-3-dev)
Comment 2 Tom Henderson 2014-01-12 18:00:12 EST
Created attachment 1758 [details]
deheader report (from bug 1237)
Comment 3 Tommaso Pecorella 2015-11-15 11:13:20 EST
Deheader seems to work only on cpp files.

A similar tool 8requiring clang, tho) is here: http://include-what-you-use.org
According to the docs, it's more aggressive (and optimizing) and it works also on header files. It's worth a check.

About the patch, I think that if someone has enough time to setup a machine running IWYU, he/she can create the patches quite easily.
Comment 4 Tommaso Pecorella 2016-07-16 17:48:52 EDT
A followup on this task.

Tonight I (manually) substituting some headers with the respective forward declarations.

C++ didn't complain at all, but PyBindGen did.
Better: it didn't at the moment, but then it generated all sort of errors about wrong forward declarations in the various ns3module.cc.

This happened with gcc 4.8.4, gccxml 0.9 and Python 2.7.6