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

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

0xLucasMarcal
Copy link
Contributor

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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
# Conflicts:
#	swiftpkg/internal/modulemap_parser/collect_module.bzl
#	swiftpkg/internal/swiftpkg_build_files.bzl
@brentleyjones
Copy link
Collaborator

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

@0xLucasMarcal
Copy link
Contributor Author

0xLucasMarcal commented Jan 6, 2025

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 0xLucasMarcal requested a review from cgrindel January 7, 2025 23:26
if [[ "${expected}" != "${actual}" ]]; then
echo >&2 "${err_msg}"
exit 1
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all tests were passed even when they didn't match. Just add a small fix and improve the clarity

Copy link
Owner

Choose a reason for hiding this comment

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

If the pattern check was failing, we should understand why it was failing. The test is using Bash regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have context on that. The other tests in this file aren't running regex match asserts, they use full strings, so I thought the best decision was to keep things simple.

Copy link
Owner

Choose a reason for hiding this comment

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

I have put up #1458 to fix the existing issues with the test. Please revert your changes, removing the assert_match in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice!!! Let me revert my changes

Copy link
Owner

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

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

Most of my comments are around the example and the affect on a unit test.

if [[ "${expected}" != "${actual}" ]]; then
echo >&2 "${err_msg}"
exit 1
fi
Copy link
Owner

Choose a reason for hiding this comment

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

If the pattern check was failing, we should understand why it was failing. The test is using Bash regex.

@cgrindel
Copy link
Owner

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

mergify bot added a commit that referenced this pull request Jan 28, 2025
As pointed out #1429, the `pkg_manifest_minimal` example was calling
`ComplexClass.greet()` and printing the result, but the function did not
return anything. Instead, it was printing in `greet()` function. That
was not the original intent. I updated `ComplexClass.greet()` to return
the greeting so that the executable can print it. I also added a check
in `do_test` to confirm that it was being output properly. All of this
was a miss on my part.

Thanks to @0xLucasMarcal  for pointing this.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…-folder-search-when-not-specified

# Conflicts:
#	examples/pkg_manifest_minimal/do_test
#	swiftpkg/tests/swiftpkg_build_files_tests.bzl
Copy link
Owner

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

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

It looks like you need to execute bazel run //:tidy to update some source files. Also, it looks like some integration tests are failing. Let me know when they are green and I will review.

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.

None yet

4 participants