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: follow symlinks when searching for xcframework directories #983

Merged
merged 9 commits into from
Apr 22, 2024

Conversation

jflan-dd
Copy link
Contributor

@jflan-dd jflan-dd commented Mar 26, 2024

One of the packages we depend on puts its XCFramework behind a symlink for some reason. Without this change rspm doesn't follow the symlink to find the contents of the actual framework.

mimic behavior of _list_files_under

@cgrindel
Copy link
Owner

Curious. What was the situation that instigated this change?

@jflan-dd
Copy link
Contributor Author

@cgrindel One of our third party dependencies is laid out with a symlink at the root to an XCFramework that's in its own directory. The Package.swift file points to the symlink for the binaryTarget's path.

Similar to this: https://github.com/jflan-dd/symlink_framework

Without this change this code wasn't following the symlink to find the .framework inside.

@cgrindel
Copy link
Owner

What do you think about adding that Swift package to one of the examples? This will ensure the code change works and it continues to work.

@jflan-dd
Copy link
Contributor Author

jflan-dd commented Apr 9, 2024

@cgrindel I'm very new to Bazel and don't have a good understanding of how the tests are setup in this repository. I've added an example with an empty XCFramework behind a symlink, but I don't know how to add a test to make sure it can build or make sure it runs with the other tests.

Could you provide some guidance?

@cgrindel
Copy link
Owner

@jflan-dd I think we want this example to have a local Swift package that includes the symlinked framework and then some code that uses the Swift package in some way. Here is my suggestion:

  1. Create a third_party/symlinked_framework directory.
  2. Move the Framework directory and the EmptyFramework.xcframework symlink under third_party/symlinked_framework.
  3. Move swift/Package.swift to third_party/symlinked_framework and modify the path in the file to point to the correct place. Also, change the name of the product to be EmptyFramework.
  4. Add Package.swift to the examples/symlink_example directory. It should reference the EmptyFramework product in the local package. (see the resources_example).
  5. Add some Swift code that uses the EmptyFramework.
  6. Use the Gazelle plugin to generate some Bazel build files.

How does that sound?

@cgrindel
Copy link
Owner

One last thing, once you are able to run do_test from inside the symlink_example, you should

  1. Run bazel clean from inside the symlink_example. (Remove the bazel-XXX symlinks.)
  2. Add your example to this list.
  3. From the parent workspace (rules_swift_package_manager), execute bazel test //examples:symlink_example_test_bazel_.bazelversion. This executes the example in the same way that it is run in CI.

@jflan-dd
Copy link
Contributor Author

@cgrindel Thanks for the guidance!

I've added a test and validated locally that the test fails without the change to follow symlinks.

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.

Overall, LGTM. Just a question about tidy and the example.

examples/symlink_example/do_test Outdated Show resolved Hide resolved
@jflan-dd
Copy link
Contributor Author

@cgrindel are there any other changes/additions you're looking for?

@brentleyjones brentleyjones enabled auto-merge (squash) April 22, 2024 18:30
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.

LGTM. Thanks!

@brentleyjones brentleyjones merged commit 488aea4 into cgrindel:main Apr 22, 2024
36 checks passed
@jflan-dd jflan-dd deleted the follow-directory-symlinks branch April 22, 2024 22:12
renovate bot added a commit to bazel-contrib/rules_bazel_integration_test that referenced this pull request Apr 23, 2024
…#304)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| rules_swift_package_manager | bazel_dep | minor | `0.29.2` -> `0.30.0`
|
|
[rules_swift_package_manager](https://github.com/cgrindel/rules_swift_package_manager)
| http_archive | minor | `v0.29.2` -> `v0.30.0` |

---

### Release Notes

<details>
<summary>cgrindel/rules_swift_package_manager
(rules_swift_package_manager)</summary>

###
[`v0.30.0`](https://github.com/cgrindel/rules_swift_package_manager/releases/tag/v0.30.0)

[Compare
Source](https://github.com/cgrindel/rules_swift_package_manager/compare/v0.29.2...v0.30.0)

#### What's Changed

- chore(deps): update dependency vapor/vapor to v4.92.6 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1000
- chore(deps): update dependency quick/nimble to from: "13.3.0" by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1001
- chore(deps): update dependency rules_xcodeproj to v2.1.0 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1003
- chore(deps): update dependency rules_xcodeproj to v2.1.1 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1006
- chore(deps): update dependency firebase/firebase-ios-sdk to from:
"10.24.0" by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1007
- chore(deps): update dependency rules_apple to v3.5.1 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1005
- chore(deps): update dependency nicklockwood/swiftformat to from:
"0.53.6" by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1008
- chore(deps): update dependency stripe-ios to v23.27.0 by
[@&#8203;jpsim](https://github.com/jpsim) in
[cgrindel/rules_swift_package_manager#1009
- chore(deps): update dependency shakebugs/shake-ios to from: "16.2.4"
by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1011
- chore: update README.md for v0.29.2 by
[@&#8203;cgrindel-app-token-generator](https://github.com/cgrindel-app-token-generator)
in
[cgrindel/rules_swift_package_manager#1004
- chore(deps): update dependency protobuf to v26 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1013
- chore(deps): update dependency nicklockwood/swiftformat to from:
"0.53.7" by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1014
- chore(deps): update dependency rules_xcodeproj to v2.2.0 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1015
- chore(deps): update dependency airbnb/lottie-spm to from: "4.4.3" by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1017
- chore(deps): update dependency ashleymills/reachability.swift to from:
"5.2.2" by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1018
- feat: Implement support for new swift_proto_library rule by
[@&#8203;AttilaTheFun](https://github.com/AttilaTheFun) in
[cgrindel/rules_swift_package_manager#834
- chore(deps): update dependency rules_apple to v3.5.1 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1024
- chore(deps): update dependency
pointfreeco/swift-composable-architecture to from: "1.9.3" by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1020
- chore(deps): update dependency vapor/vapor to v4.93.0 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1022
- chore(deps): update dependency protobuf to v26 by
[@&#8203;cgrindel-self-hosted-renovate](https://github.com/cgrindel-self-hosted-renovate)
in
[cgrindel/rules_swift_package_manager#1025
- fix: follow symlinks when searching for xcframework directories by
[@&#8203;jflan-dd](https://github.com/jflan-dd) in
[cgrindel/rules_swift_package_manager#983

**Full Changelog**:
cgrindel/rules_swift_package_manager@v0.29.2...v0.30.0

#### Bazel Module Snippet

```python
bazel_dep(name = "rules_swift_package_manager", version = "0.30.0")
```

#### Workspace Snippet

```python
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_swift_package_manager",
    sha256 = "28d33f5f2898f660acafb250b266d7ea1f059bcb9c473838ef9c2431374af150",
    urls = [
        "https://github.com/cgrindel/rules_swift_package_manager/releases/download/v0.30.0/rules_swift_package_manager.v0.30.0.tar.gz",
    ],
)

load("@&#8203;rules_swift_package_manager//:deps.bzl", "swift_bazel_dependencies")

swift_bazel_dependencies()

load("@&#8203;cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")

bazel_starlib_dependencies()

### MARK: - Gazelle
### gazelle:repo bazel_gazelle

load("@&#8203;bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@&#8203;rules_swift_package_manager//:go_deps.bzl", "swift_bazel_go_dependencies")
load("@&#8203;io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

### Declare Go dependencies before calling go_rules_dependencies.
swift_bazel_go_dependencies()

go_rules_dependencies()

go_register_toolchains(version = "1.21.1")

gazelle_dependencies()

### MARK: - Swift Toolchain

http_archive(
    name = "build_bazel_rules_swift",

### Populate with your preferred release 
### https://github.com/bazelbuild/rules_swift/releases
)

load(
    "@&#8203;build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)
load("//:swift_deps.bzl", "swift_dependencies")

### gazelle:repository_macro swift_deps.bzl%swift_dependencies
swift_dependencies()

swift_rules_dependencies()

load(
    "@&#8203;build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()
```

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/bazel-contrib/rules_bazel_integration_test).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMTMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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

3 participants