-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependency visibility should be enforced #1987
Comments
@billhoffman Is there a standard way of doing this with CMake? |
Not exactly what you want, but with regard to headers, as a start, we have include-what-you-use running on a nightly basis. https://drake-jenkins.csail.mit.edu/job/linux-clang-nightly-include-what-you-use/ |
Nice! It looks like this tool enforces the "weak |
Great to know that IWYU is running, but it seems tangential to the visibility/physical-layering issue. |
You need to include the correct headers first. |
I'm not sure what you mean. To get started, all we really need is the ordered list of directories that CMake visits. Is that a thing we can make it output? |
As a clarification, by way of example, here are three specific defects that we'd like to find with this kind of enforcement:
|
Let's make some time to talk about this one when Kitware visits TRI next week. |
From f2f discussion with @bradking and @jwnimmer-tri: Part 1: Determining the physical ordering automatically. We can replace Alternative considered: Develop a separate notation for dependency declaration. Do a topological sort and cycle check on that notation in both CMake and our enforcement script. This may become a first-class feature in an upcoming version of CMake, in which case we can switch to it then. Part 2: Enforcing the physical ordering. We can write the ordering to a file, and then run a Python script ctest that parses the Alternative considered: Get the compiler to dump the Alternative considered: Restructure the Drake tree so that the compiler can enforce physical ordering by only including a Alternative considered: Restructure the Drake libraries so that CMake can enforce physical encoding. This would require making all dependencies (even header-only ones) artificial link dependencies, using a Schwarz counter or similar. |
I suggest WONTFIXing this, in lieu of #3129. |
I would suggest it anyway. This is not a CMake issue per se. |
I think you are confusing dealing with legacy code with the build system. |
Agree with @jwnimmer-tri, closing as wontfix. |
Absent a concept of "visibility" in the build system, we should have a test that does a rudimentary sanity check of
#include
statements. To at least a first approximation, if CMake visits directory A before directory B, nothing in directory A should#include
a file from directory B. (If you know of cases where such a dependency should be allowed, please chime in!)The implementation of this test doesn't need to be rock-solid. One-off static analysis in Python would be pretty useful.
@jwnimmer-tri, I know this is also of interest to you.
The text was updated successfully, but these errors were encountered: