fix: Replicates SPM default behavior for publicHeadersPath: If this is nil, the directory is set to include
Match SPM's default behavior for public headers path
When SPM processes a target without an explicit publicHeadersPath, it follows these rules:
- If
publicHeadersPathis nil and aninclude/directory exists, useinclude/as the public headers path - 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 whenpublicHeadersPathis not set - Using
include/as the public headers path if it exists - Making all headers in
include/*.hvisible to clang targets
https://developer.apple.com/documentation/packagedescription/target/publicheaderspath
Does this fix a certain use case? If so, can we add or adjust an example to show it?
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?
We will wait for the #1458 to merge, then rebase this PR on those changes.