Implement runfiles for rlocation#374
Open
titusfortner wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Bazel runfiles library for Ruby (
Bazel::Runfiles) and makes it available on theRUBYLIBof everyrb_binary/rb_testso user code can resolve the runtime location of its data dependencies.This mirrors the runfiles libraries shipped by other Bazel rulesets(
rules_python,rules_go, etc.), giving Ruby targets a supported, cross-platform way to callrlocationinstead of getting paths relative to the working directory.I ran a test on Selenium fork with this branch and it worked as expected.
What's included
Bazel::Runfiles.createauto-detects the runfiles strategy from the environment (RUNFILES_MANIFEST_FILE/RUNFILES_DIR), falling back to discovery from$PROGRAM_NAME.#rlocation(path)resolves a runfiles-relative path, with validation that rejects empty and non-normalized paths and passes absolute paths through unchanged.Two strategies:
ManifestBased(parses aMANIFEST, including the space/newline/backslash escaping convention and prefix-directory walking) andDirectoryBased(joins onto the runfiles root).ruby/runfiles/BUILD— exposes the file viaexports_files, anrb_librarytarget (//ruby/runfiles:runfiles, public visibility), and anrb_testfor the unit tests.rb_binaryintegration (ruby/private/binary.bzl+ launcher templates):_runfiles_helperattribute pointing at the library, added to the binary's runfiles..shand.cmdlauncher templates prepend the library's directory toRUBYLIB, sorequire 'bazel/runfiles'works out of the box.Tests
This adds tests, but they are tagged manual because no Ruby toolchain is registered. They do pass manually.