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

utils: add check_binary_linkage function #19116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alebcay
Copy link
Member

@alebcay alebcay commented Jan 18, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This PR adds Utils::check_binary_linkage, which is a helper-function that is already used in some (primarily Rust-based) formulae.

The function is more or less copied verbatim, except types are loosened to accept String or Pathname. An optional prefix parameter can also be set to change the filtering behavior - this flag really only exists because we have to tweak the filtering behavior a bit in the test. Maybe we can just not do any filtering and that'll be fine - but for now I've kept it as close to the original as possible.

Open to suggestions all around, but I'm a bit extra miffed about:

  • Where would be the best place to put this file, and the file name. There didn't appear to be another file in utils that seemed like a good place, so I created a new one.
  • The tests still feel a bit clunky to me and I think there's probably room for improvement. Note that we set prefix in invocations to Utils::check_binary_linkage because in the test environment, HOMEBREW_CELLAR is a sibling to HOMEBREW_PREFIX, not a child, so filtering on HOMEBREW_PREFIX will exclude all the libraries in HOMEBREW_CELLAR, unlike in a real Homebrew installation where the cellar is in HOMEBREW_PREFIX/"Cellar".

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good to me if suggestion is applied (or similar naming to end in ?). If you're happy to apply suggestion as-is: feel free to merge without a rereview.

Library/Homebrew/utils/linkage.rb Outdated Show resolved Hide resolved
@alebcay alebcay force-pushed the utils-check-binary-linkage branch from 1e4048f to 796dc51 Compare January 20, 2025 02:38
@alebcay
Copy link
Member Author

alebcay commented Jan 20, 2025

  • Renamed the function to binary_linked_to_library?
  • Would appreciate some ideas on the test failure. The two added test cases seem to pass locally for me on macOS and in ubuntu22.04 brew container. Looks like the compilation of the test program is failing, but I'm not able to reproduce the failure (or would be helpful to get some verbose/debug output for why the command is failing)

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.

2 participants