copperspice / doxypress

Documentation generator using annotated sources for multiple computer languages
https://www.copperspice.com/
GNU General Public License v2.0
148 stars 14 forks source link

Add a clang-include-input-paths option #43

Closed brycelelbach closed 3 years ago

brycelelbach commented 3 years ago

This PR adds a new option, clang-include-input-paths, which is on by default. If this option is on, then the directory of each input file is added to the include path when using Clang parsing. This behavior is the current status quo, but some projects need to be able to disable it.

Adding the directory of every input file to the include path is problematic for a number of projects. We ran into problems with it in Thrust.

For example, imagine a project that has this structure:

include/myproject/version.h
include/myproject/component0/coolstuff.h
include/myproject/component1/coolstuff.h
include/myproject/component1/widget.h

And those files are intended to be included by users as:

#include <myproject/version.h>
#include <myproject/component0/coolstuff.h>
#include <myproject/component1/coolstuff.h>
#include <myproject/component1/widget.h>

But within include/myproject/component1/widget.h, you might have:

#include "coolstuff.h" // Should resolve to `include/myproject/component1/coolstuff.h`.

If you have "input-source" = [ "include/" ], then the directories of all headers found in include will be added as includes by Doxypress:

-Iinclude/myproject -Iinclude/myproject/component0 -Iinclude/myproject/component1

This is problematic, because now include/myproject/component1/widget.h will include include/myproject/component0/coolstuff.h instead of include/myproject/component1/coolstuff.h.

Alternatively, consider the case we ran into in Thrust, where our project structure looks like:

thrust/version.h
...
thrust/system/detail/errno.h
...

With "input-source" = [ "thrust" ], Doxypress will add the following as includes:

"-Ithrust ... -Ithrust/system/detail"

This is problematic because errno.h is also the name of a system header, and will now be found instead of the system header.

agserm commented 3 years ago

Thanks for your submission! This has been merged into DoxyPress as 19ed582. The name of the tag was changed to clang-include-input-source to better reflect its relationship to the input-source configuration.