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

Introduce a pure Swift runfiles library #1310

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

cerisier
Copy link

@cerisier cerisier commented Sep 17, 2024

First shot at implementing #890

Main implementation

I followed guidance from @fmeum and based this implementation on the runfiles library of rules_python where applicable since this was pointed as the reference implementation.

In addition to rules_python implementation, this implementation uses a similar mechanism as the C++ implementation for deducing the RUNFILES_DIR and RUNFILES_MANIFEST_FILE location based on argv0.

TODO

  • Implement runfiles directory detection from argv0
  • Make a proper PR description describing the API, the heuristics behind directory discovery and path lookup.
  • Discuss the proper way to solve the current repository issue and whether to keep the BazelRunfilesConstants file generation.
  • Fix Linux compat

@cerisier cerisier marked this pull request as ready for review January 4, 2025 09:17
@cerisier cerisier changed the title Introduce a runfiles library Introduce a pure Swift runfiles library Jan 4, 2025
swift/runfiles/README.md Outdated Show resolved Hide resolved
let runfiles = try Runfiles.create()

// Runfiles lookup paths have the form `my_workspace/package/file`.
// Runfiles path lookup may return nil.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In which cases can it return nil, and should it throw instead?

Copy link
Author

Choose a reason for hiding this comment

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

It returns nil in 2 scenarios:

  1. The runfiles path is relative
  2. No manifest entry for this path if using the manifest

I can make it throw instead indeed.

Co-authored-by: Brentley Jones <github@brentleyjones.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.

3 participants