Skip to content

feat: Add wrapped_facade_headers library for resolving IWYU violations; Add header wrappers for sys/types.h; Resolve off_t IWYU violations. #52

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

Merged
merged 3 commits into from
Apr 7, 2025

Conversation

Bill-hbrhbr
Copy link
Collaborator

@Bill-hbrhbr Bill-hbrhbr commented Apr 4, 2025

Description

This PR closes #50 by introducing a new ystdlib module: wrapped_facade_headers.

Summary

The goal of this module is to provide platform-agnostic include wrappers for system headers that behave differently across operating systems—particularly between Linux and macOS.

We introduce a wrapped header following the Linux-style path for each platform-sensitive include, e.g.

#include <ystdlib/wrapped_facade_headers/sys/types.h>  // Provides off_t on all supported platforms

These headers resolve to the correct platform-specific includes internally, ensuring cross-platform consistency with simple include statements and without triggering clang-tidy warnings.

Testing

For each specific case we counter that requires a wrapped header, we add a trivial test file (e.g. test/test_off_t.cpp) that:

  • Includes the wrapped header
  • References the type or symbol that would cause warnings beforehand
  • Ensures clang-tidy (with misc-include-cleaner) passes

Misc

Fixes the existing off_t problems in io_interface.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Added a trivial unit test for clang-tidy to check that off_t has a well-defined source header.

Summary by CodeRabbit

  • New Features

    • Introduced a modular build component to enhance dependency management and overall project structure.
  • Refactor

    • Updated header inclusions within I/O interfaces to improve consistency and maintenance.
  • Tests

    • Added a new test case verifying proper handling of type definitions.
  • Chores

    • Refined build and test configuration settings for a more robust development process.

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link

coderabbitai bot commented Apr 4, 2025

Walkthrough

This pull request introduces a new subdirectory, wrapped_facade_headers, into the build system and integrates it into various components. The PR updates the CMake configuration for the overall project and for the io_interface library by adding a public link dependency. It also replaces direct inclusions of <sys/types.h> in the io interfaces with an inclusion of the new header from the added directory. Additionally, a new custom header file and a corresponding Catch2 test have been added, and the taskfile now includes an extra test target suffix.

Changes

File(s) Change Summary
src/ystdlib/CMakeLists.txt, src/ystdlib/io_interface/CMakeLists.txt, src/ystdlib/wrapped_facade_headers/CMakeLists.txt, taskfile.yaml Updated build configuration: added new subdirectory wrapped_facade_headers, integrated it as a public dependency in the io_interface library, and added a new test target suffix.
src/ystdlib/io_interface/ReaderInterface.hpp, src/ystdlib/io_interface/WriterInterface.hpp Modified header inclusions: replaced <sys/types.h> with <ystdlib/wrapped_facade_headers/sys/types.h> and removed obsolete comments.
src/ystdlib/wrapped_facade_headers/sys/types.h, src/ystdlib/wrapped_facade_headers/test/test_off_t.cpp Added new custom header that wraps the system header and introduced a Catch2 test case to verify the off_t type.

Assessment against linked issues

Objective Addressed Explanation
Provide a well-defined off_t type across different OS platforms (#50)

Possibly related PRs

Suggested reviewers

  • davidlion
  • LinZhihao-723
  • kirkrodrigues

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ac60d1 and ac3718a.

📒 Files selected for processing (8)
  • src/ystdlib/CMakeLists.txt (1 hunks)
  • src/ystdlib/io_interface/CMakeLists.txt (1 hunks)
  • src/ystdlib/io_interface/ReaderInterface.hpp (1 hunks)
  • src/ystdlib/io_interface/WriterInterface.hpp (1 hunks)
  • src/ystdlib/wrapped_facade_headers/CMakeLists.txt (1 hunks)
  • src/ystdlib/wrapped_facade_headers/sys/types.h (1 hunks)
  • src/ystdlib/wrapped_facade_headers/test/test_off_t.cpp (1 hunks)
  • taskfile.yaml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/ystdlib/io_interface/WriterInterface.hpp
  • src/ystdlib/wrapped_facade_headers/test/test_off_t.cpp
  • src/ystdlib/io_interface/ReaderInterface.hpp
🔇 Additional comments (8)
src/ystdlib/CMakeLists.txt (1)

4-4: Change looks good!

The addition of the wrapped_facade_headers subdirectory properly integrates the new module into the build system. This aligns with the PR objective of creating platform-agnostic header wrappers.

src/ystdlib/wrapped_facade_headers/CMakeLists.txt (1)

1-8: Well-structured CMake configuration!

The CMake configuration follows project conventions and correctly sets up:

  • Library name and namespace
  • Public header for sys/types.h
  • Test source file for off_t verification

This provides a clean structure for the platform-agnostic headers.

src/ystdlib/wrapped_facade_headers/sys/types.h (1)

1-9: Good implementation of cross-platform header wrapper!

The implementation effectively:

  1. Uses IWYU pragma directives to control export visibility
  2. Includes the standard system headers
  3. Conditionally adds Apple-specific include for <sys/_types/_off_t.h>
  4. Properly handles formatting with clang-format directives

This approach resolves the platform-specific differences between Linux and macOS for the off_t type as intended.

taskfile.yaml (1)

23-23: Properly integrated test target suffix!

Adding "wrapped_facade_headers" to the test target suffixes list ensures the new module can be tested separately, which aligns with the existing pattern for other modules.

src/ystdlib/wrapped_facade_headers/test/test_off_t.cpp (1)

1-10: Test case looks good!

The test correctly verifies the availability of the off_t type through the wrapped header. The test follows project conventions including the preference for 0 == i rather than i == 0.

src/ystdlib/io_interface/CMakeLists.txt (1)

10-11: Great addition of wrapped_facade_headers dependency!

This change correctly adds the necessary public link to the newly introduced wrapped_facade_headers library, which supports the goal of providing platform-agnostic header wrappers. The PUBLIC_LINK_LIBRARIES designation ensures that consumers of the io_interface library will also have access to these wrapped headers.

src/ystdlib/io_interface/ReaderInterface.hpp (1)

7-8: Good replacement of system header with wrapped facade header

The change appropriately replaces the direct system header include with the new platform-agnostic wrapper. This aligns perfectly with the PR objective of providing portable header wrappers for platform-specific system includes and resolving issues with off_t type.

src/ystdlib/io_interface/WriterInterface.hpp (1)

7-8: Good replacement of system header with wrapped facade header

The change appropriately replaces the direct system header include with the new platform-agnostic wrapper. This modification successfully addresses platform inconsistencies for the off_t type used in the seek_from_current method, which fulfills the PR's objective.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sorry, something went wrong.

@Bill-hbrhbr Bill-hbrhbr changed the title feat(wrapped_facade_headers): Add facade headers feat(wrapped_facade_headers): Add portable header wrappers for platform-specific system includes. Apr 4, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title feat(wrapped_facade_headers): Add portable header wrappers for platform-specific system includes. feat(wrapped_facade_headers): Add portable header wrappers for platform-specific system includes; Resolve existing issues with off_t includes. Apr 4, 2025
@Bill-hbrhbr Bill-hbrhbr marked this pull request as ready for review April 4, 2025 06:15
@Bill-hbrhbr Bill-hbrhbr requested a review from a team as a code owner April 4, 2025 06:15
@davidlion davidlion changed the title feat(wrapped_facade_headers): Add portable header wrappers for platform-specific system includes; Resolve existing issues with off_t includes. feat: Add wrapped_facade_headers library for resolving IWYU violations; Add header wrappers for sys/types.h; Resolve off_t IWYU violations. Apr 6, 2025
@Bill-hbrhbr Bill-hbrhbr merged commit 6b5a88c into y-scope:main Apr 7, 2025
14 checks passed
@Bill-hbrhbr Bill-hbrhbr deleted the add-facade-headers branch April 7, 2025 19:03
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.

Provide a well-defined off_t type across different operating system platforms.
2 participants