Re: Issue 1135 in include-what-you-use: Match Included Mappings with OS Package Versions

0 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
Nov 23, 2022, 2:19:37 PM11/23/22
to include-wh...@googlegroups.com
Comment #1 on issue 1135 by kimgr: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

I think it's fair to think of the mappings as "contrib" content. We include them, but don't really maintain them (because it would require that we used and installed all the weird libraries people like :)).

Instead, we try to provide stable scripts so that you can regenerate these library mappings ad hoc from a representative environment for your project. These scripts are in the `mapgen` directory in the IWYU source tree -- I'm actually not sure if packagers install those. Maybe we should add them to an install step so they end up in the install root somewhere.


notifi...@include-what-you-use.org

unread,
Nov 23, 2022, 2:20:31 PM11/23/22
to include-wh...@googlegroups.com
Comment #2 on issue 1135 by kimgr: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

(I was working on one for Boost at one point, but got distracted. Can see if I can revive it if you want to give it a go.)


notifi...@include-what-you-use.org

unread,
Nov 24, 2022, 8:58:20 AM11/24/22
to include-wh...@googlegroups.com
Comment #3 on issue 1135 by DaAwesomeP: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

Yeah it would be great if the OS-provided packages could include these scripts! And it would be even better if we could get them to bundle a pre-generated run for the OS-provided library versions. I agree that is much better than bundling pre-generated mappings to arbitrary library versions from the IWYU source tree.

Ill take a look at the Debian side of package generation soon and also the Boost scripts!


notifi...@include-what-you-use.org

unread,
Nov 24, 2022, 9:00:34 AM11/24/22
to include-wh...@googlegroups.com
Comment #3 on issue 1135 by DaAwesomeP: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

Yeah it would be great if the OS-provided packages could include these scripts! And it would be even better if we could get them to bundle a generated run for the OS-provided library versions as a part of their build process. I agree that is much better than bundling pre-generated mappings to arbitrary library versions from the IWYU source tree.

notifi...@include-what-you-use.org

unread,
Nov 25, 2022, 2:45:37 PM11/25/22
to include-wh...@googlegroups.com
Comment #4 on issue 1135 by kimgr: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

That would create a weird dependency between packages, i.e. the IWYU package would need access to Boost, Qt, etc. I think a better partitioning of responsibilities is to let the respective library packages ship with IWYU mappings, but that's a little presumptuous (IWYU is maybe not _that_ important :)).

So the right trade-off, to me, seems to be to make sure IWYU packages come with the mapgen scripts, so that users can solve their own problems in their own environment.


notifi...@include-what-you-use.org

unread,
Nov 28, 2022, 10:43:35 PM11/28/22
to include-wh...@googlegroups.com
Comment #5 on issue 1135 by DaAwesomeP: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

I see. I suppose it would only be a development/build dependency, but that is not great. Including the mapgen scripts does seem like the best option then.

I would be interested in seeing if there is a way to automate such scripts so that they can be as painless as possible to use. I wonder if there would be a way to allow the CMake IWYU integration to compile its own cache of magen results using the libraries sources included in the CMake project. A user could simply then install IWYU, add a few lines to their `CMakeLists.txt` to enable the mapgen scripts they need, and then it would take care of the rest when CMake configures itself. It would be entirely platform independent and remain a portable configuration solution. Since the mappings are generated by the user, I think it makes sense to store them in the CMake cache.

This would require CMake to know the location of the magen scripts which may not be consistent on all OSes. This is an issue I have with the currently precompiled mappings. @kimgr what do you think about including a command like `iwyu-mapgen` which would only add one command to the `PATH` but allow for scripts to more easily take advantage of the mapgen scripts? Could be a simple Bash/shell wrapper with commands like:

```
$ iwyu-mapgen --help
$ iwyu-mapgen --version
$ iwyu-mapgen --list-available
$ iwyu-mapgen --list-available --machine-readable
$ iwyu-mapgen boost <args>
$ iwyu-mapgen cpython <args>
$ iwyu-mapgen qt <args>
```

Ideally there would be a standard minimum set of supported arguments for each mapgen script and then any optional flags specific to each generator. A simple `--machine-readable` or similar flag might allow tools to detect which mapgen scripts are available.


notifi...@include-what-you-use.org

unread,
Nov 29, 2022, 2:34:12 PM11/29/22
to include-wh...@googlegroups.com
Comment #6 on issue 1135 by kimgr: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

To be honest, all I see is:
```
$ iwyu-mapgen --version
# not sure why this is necessary, but OK:
# iwyu-mapgen-boost.py --version, etc

$ iwyu-mapgen --list-available
# ls mapgen/

$ iwyu-mapgen --list-available --machine-readable
# ls mapgen/

$ iwyu-mapgen boost <args>
# $ mapgen/iwyu-mapgen-boost.py <args>

$ iwyu-mapgen cpython <args>
# mapgen/iwyu-mapgen-cpython.py <args>

$ iwyu-mapgen qt <args>
# mapgen/iwyu-mapgen-qt.py <args>
```

Integrating this into CMake only helps the CMake use case, not `iwyu_tool.py` or direct `include-what-you-use` invocations.

Let's focus on small steps and get the mapgen scripts included in `cmake install` so that packagers can/will include them.


notifi...@include-what-you-use.org

unread,
Nov 29, 2022, 2:50:03 PM11/29/22
to include-wh...@googlegroups.com
Comment #6 on issue 1135 by kimgr: Match Included Mappings with OS Package Versions
https://github.com/include-what-you-use/include-what-you-use/issues/1135

To be honest, all I see is:
```
$ iwyu-mapgen --version
# not sure why this is necessary, but OK:
# iwyu-mapgen-boost.py --version, etc

$ iwyu-mapgen --list-available
# ls mapgen/

$ iwyu-mapgen --list-available --machine-readable
# ls mapgen/

$ iwyu-mapgen boost <args>
# mapgen/iwyu-mapgen-boost.py <args>
Reply all
Reply to author
Forward
0 new messages