Repository navigation
include: use angle brackets for exported headers, and check it - #4375
grandixximo wants to merge 1 commit into
Conversation
|
Since I cleaned the tree we can enforce it and error the CI when mistakes are done, objections? Anyway Bertho won't let them pass ;-) |
004a0ad to
b3e6a46
Compare
|
BTW, I don't think we should enforce this in CI. At least not yet. I'd like to see more cleanup before we start enforcing. The cleanup may expose situations that require a second thought. |
|
Fair, I'll keep them as warning for now then. |
That I need to rephrase. I don't think it should be checked in CI yet, at all. (see my added review comment) The code organization is still messy. That is something that needs fixing first. We need to have (all) the libraries in their own isolated directory and analyze the cross-dependencies. |
|
Ok, I see, I'll get on the cleaning first then, but I'm taking a break tomorrow, traveling with family, I'll be around a bit less... |
b3e6a46 to
d2b5eee
Compare
d2b5eee to
cf6931e
Compare
|
@BsAtHome The cross-dependency analysis you asked for.
The five-way one inside libnml was not a dependency. Those six subdirectories have empty
So one cycle left and it is one I would leave alone. Does that settle the gate, or is there something else you want first? This is rebased on master. |
|
The fact that we treat some files differently is still a problem. That reminds me, have you checked I still think we should split this PR. One for the actual include type changes that are warranted and then the style check we need to work on a bit more (IMO). |
cf6931e to
82ce52a
Compare
|
@BsAtHome Split done. #4448 carries the include changes, this one is the check alone. CI here fails until that merges, since the eight lines it fixes are exactly what the check flags. On rtapi. It is 25 exported headers, 4 private ones and 13 sources in one directory, and which sources build depends on So rather than enumerate exceptions I would rather remove the need for them: give exported headers a directory that holds nothing else, so "sits beside an exported header" and "is an exported header" become the same statement. That is your isolated-directory point applied to the header side, and the check then needs no exceptions at all. rtapi is both the worst case and the best proof. Two things I ran into while looking. The export set has two sources of truth: Worth pursuing in that order? |
|
The multiple copy recipes are the actual problem, I think. They should not copy locally, but add to one variable and one rule does the copying. When we remove a header from being exported, then that is always a problem. You need a The only alternative is to move everything that is exportable to the include directory permanently (no more copying). But I fear that it also would make things difficult at this state. We need to have all the proper interfaces in the includes and nothing else. That will take some more cleanup before we get to that point. |
|
Gets back to scrubbing... |
82ce52a to
56eae7b
Compare
|
@BsAtHome Rebased, and the exception table is gone. With #4448 and #4449 in, the check passes on master with One cost, stated plainly. Without the table a file beside an exported header may quote it, so the five Also fixed a crash: the file list came from #4452 has the one-rule header export you asked for. |
|
If we don't merge, need keep checking these by hand, the exclusions are gone, any more blockers? |
| for m in RE_QUOTED.finditer(text): | ||
| name = m.group(1) |
There was a problem hiding this comment.
How does this track includes in a component that is not using #include but uses include "bla";?
There was a problem hiding this comment.
It did not. Fixed: the check now reads include "bla"; above the ;; line as well, where halcompile takes its own include directive rather than the preprocessor's, and .icomp is in the suffix list too. Both forms in a component are flagged now, and the tree is still clean.
| if path in exported: | ||
| # An exported header is copied to include/ and has to keep finding | ||
| # its siblings there, so it includes them with quotes. | ||
| continue |
There was a problem hiding this comment.
This is an assumption that may not be true. At least, it is not enforced.
There was a problem hiding this comment.
Correct, nothing enforces it. It is an assumption about layout rather than about includes, and #4461 removes the layout: the 37 exported headers move into src/include, which holds nothing else. A sibling include then has to name a file in that same directory, so the check can verify it instead of assuming it.
| if directory == os.path.dirname(source): | ||
| continue # beside the header, taking the source copy |
There was a problem hiding this comment.
This assumes that the directory is determining whether a quoted include is fine. That is also an assumption.
There was a problem hiding this comment.
Also correct. That branch exists only because sources sit beside exported headers. After #4461 none do, so it has no instances left and goes, and what is left is one rule with no exceptions.
It is not about will/wont merge. It is about me having reservations that the code base is ready for this (besides my review comments). |
56eae7b to
4ef0fe5
Compare
|
We need to revisit this when the includes are moved. |
Nothing catches the wrong form today, since both compile. A quoted include of an exported header searches the includer's directory first and then falls back to include/, so it works until a header of the same name turns up beside the includer. The exported set is the content of include/, so the check follows the directory rather than a list of its own. No source under src/ shares a directory with an exported header any more, so every quoted include of one from src/ is flagged. The exported headers themselves are not under src/ and keep including their siblings with quotes. There are no per-file exceptions. Findings are warnings by default and errors with --error, which is how CI runs it, and named files can be passed for use from a pre-commit hook.
4ef0fe5 to
d5c7e8e
Compare
|
#4461 is in, so I rebased this onto it. The check now reads |
Bertho's ask on hold since August was to move the exported headers first; #4461 did that, so this is the check alone, rebased onto it.
The exported headers live in
include/, which every compile searches. A quoted include of one still compiles, since it searches the includer's directory and then falls back to the same path, so nothing catches the wrong form until a same-named header turns up beside the includer.scripts/include-style-check.pytakes the exported set frominclude/itself, so it follows the directory rather than a list of its own. No source undersrc/shares a directory with an exported header any more, so the rule is one sentence with no exceptions: fromsrc/, an exported header takes angle brackets. The headers ininclude/keep quoting each other, which finds the sibling wherever the directory is installed.Findings are warnings by default and errors with
--error, which is how the cppcheck job runs it. Named files can be passed, which suits a pre-commit hook, and it annotates the offending lines in CI.Master passes clean. Turning one
<hal.h>back into"hal.h"is reported.