Skip to content

Comments

Safer header export#30

Open
sleepy-monax wants to merge 2 commits intostablefrom
smnx/safer-header-export
Open

Safer header export#30
sleepy-monax wants to merge 2 commits intostablefrom
smnx/safer-header-export

Conversation

@sleepy-monax
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies the header export mechanism by replacing a multi-conditional approach with a single, explicit property-based system. The change aims to make header exports "safer" by requiring explicit configuration.

Key Changes:

  • Replaces three conditional checks (cpp-root-include, cpp-excluded, LIB type default) with a single export-headers property check
  • Changes from implicit parent directory inclusion for libraries to explicit path specification
  • Removes automatic header export behavior for library components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

elif c.type == model.Kind.LIB:
res.add(str(Path(c.dirname()).parent))
if "export-headers" in c.props:
res.add(str(Path(c.dirname()) / c.props["export-headers"]))
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The new implementation doesn't validate that the path specified in c.props["export-headers"] exists or is a valid directory. Consider adding validation to ensure the exported header path exists and is accessible, to provide better error messages when components are misconfigured.

For example, you could add a check like:

header_path = Path(c.dirname()) / c.props["export-headers"]
if not header_path.exists():
    _logger.warning(f"Component {c.id} specifies non-existent export-headers path: {header_path}")

This would help developers catch configuration errors early rather than encountering cryptic compilation errors later.

Suggested change
res.add(str(Path(c.dirname()) / c.props["export-headers"]))
header_path = Path(c.dirname()) / c.props["export-headers"]
if header_path.exists() and header_path.is_dir():
res.add(str(header_path))
else:
_logger.warning(
"Component %s specifies non-existent or invalid export-headers path: %s",
getattr(c, "id", "<unknown>"),
header_path,
)

Copilot uses AI. Check for mistakes.
continue
res.add(str(headerPath))

# TODO: Remove when we get 1.0 (will probably be forgotten anyway :^) )
Copy link
Member

Choose a reason for hiding this comment

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

lulz x)

@sleepy-monax sleepy-monax force-pushed the smnx/safer-header-export branch from aa14593 to 890f83e Compare January 27, 2026 09:07
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.

2 participants