rules_swift_package_manager icon indicating copy to clipboard operation
rules_swift_package_manager copied to clipboard

fix: Replicates SPM default behavior for publicHeadersPath: If this is nil, the directory is set to include

Open 0xLucasMarcal opened this issue 1 year ago • 3 comments

Match SPM's default behavior for public headers path

When SPM processes a target without an explicit publicHeadersPath, it follows these rules:

  1. If publicHeadersPath is nil and an include/ directory exists, use include/ as the public headers path
  2. This makes all headers in the include/ directory visible to dependent targets

This PR replicates this canonical behavior by:

  • Checking for the existence of include/ directory when publicHeadersPath is not set
  • Using include/ as the public headers path if it exists
  • Making all headers in include/*.h visible to clang targets

https://developer.apple.com/documentation/packagedescription/target/publicheaderspath

0xLucasMarcal avatar Jan 06 '25 17:01 0xLucasMarcal

Does this fix a certain use case? If so, can we add or adjust an example to show it?

brentleyjones avatar Jan 06 '25 17:01 brentleyjones

Does this fix a certain use case? If so, can we add or adjust an example to show it?

It was causing tree-sitter build to fail, but after fixing the header not found by patching rules_swift_package_manager, the build started failing with a new error, that tree-sitter wasn't exposing all the source files to SPM. So I sent a PR fixing that and explicitly setting include as publicHeadersPath. So now, I have no fully running example 😓

What do you suggest in this case?

0xLucasMarcal avatar Jan 06 '25 18:01 0xLucasMarcal

We will wait for the #1458 to merge, then rebase this PR on those changes.

cgrindel avatar Jan 25 '25 15:01 cgrindel