Skip to content
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

build,github: add a step to check include style #2592

Closed
wants to merge 2 commits into from

Conversation

tchaikov
Copy link
Contributor

Previously, we do not enforce the policy of including Seastar headers using angle brackets instead of double quotes in our github workflow. In this change, a new step is added to check include style when building the Dev mode. This allows our CI to fail if a change violates this policy.

In C++, the `#include` preprocessor directive is used to include header
files. the path of the header files can be quoted using doube quotes
(`"`), and angle brackets (`<>`). Seastar headers should be considered
system headers. So we always enforces the policy to include Seastar
headers using angle brackets. But sometimes, LSP clients automatically
inserts headers to source file if the used symbols are not found by
the source file yet. This is handy to developers using the LSP clients,
but this could be annoying if the added `#include` directive uses double
quotes to include Seastar headers. This happens when clangd is used as
the LSP server, as Seastar includes its own headers using `-I` instead
of `-isystem`. We prefer the former, because the C++ compiler prints
warnings from the header files if they are included using `-I`, this
enables the compiler to report potential issues in Seastar's headers.

To identify issues like `#include "seastar/core/reactor.hh"`, in this
change, a new CMake target named "check-include-style" is added. This
target checks the Seastar source files for this issue, and fails the
build of the target if this issue is identified. Instead of implementing
the check in CMake, a dedicate Python script is used, this allows
developers which are not familiar with CMake to audit and improve this
script.

Signed-off-by: Kefu Chai <[email protected]>
Previously, we do not enforce the policy of including Seastar headers
using angle brackets instead of double quotes in our github workflow.
In this change, a new step is added to build "check-include-style"
target when building the Dev mode. This allows our CI to fail if the
tree being tested violates this policy.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov force-pushed the check-include-style branch from 6381640 to f0e9187 Compare December 22, 2024 12:58
@avikivity avikivity closed this in c863886 Dec 22, 2024
@tchaikov tchaikov deleted the check-include-style branch December 23, 2024 02:07
function (seastar_check_include_style target library)
get_target_property (sources ${library} SOURCES)
set (check-target "${target}-${library}")
message("${sources}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this message, which was added for debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #2593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant