Skip to content

Commit

Permalink
Merge pull request #205641 from Homebrew/cargo-c-binary-linkage
Browse files Browse the repository at this point in the history
cargo-c: use brew-provided function for checking binary linkage
  • Loading branch information
chenrui333 authored Jan 27, 2025
2 parents 45622aa + 0245273 commit 09da98b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Formula/c/cargo-c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,9 @@ def install
system "cargo", "install", *std_cargo_args
end

def check_binary_linkage(binary, library)
binary.dynamically_linked_libraries.any? do |dll|
next false unless dll.start_with?(HOMEBREW_PREFIX.to_s)

File.realpath(dll) == File.realpath(library)
end
end

test do
require "utils/linkage"

cargo_error = "could not find `Cargo.toml`"
assert_match cargo_error, shell_output("#{bin}/cargo-cinstall cinstall 2>&1", 1)
assert_match cargo_error, shell_output("#{bin}/cargo-cbuild cbuild 2>&1", 1)
Expand All @@ -60,7 +54,7 @@ def check_binary_linkage(binary, library)
Formula["openssl@3"].opt_lib/shared_library("libssl"),
Formula["openssl@3"].opt_lib/shared_library("libcrypto"),
].each do |library|
assert check_binary_linkage(bin/"cargo-cbuild", library),
assert Utils.binary_linked_to_library?(bin/"cargo-cbuild", library),
"No linkage with #{library.basename}! Cargo is likely using a vendored version."
end
end
Expand Down

0 comments on commit 09da98b

Please sign in to comment.