Skip to content
Snippets Groups Projects
Commit abca5936 authored by Tim D. Smith's avatar Tim D. Smith
Browse files

Add --reverse to brew linkage

For each dylib the keg references, print the dylib followed by the
binaries which link to it.

Closes #431.
parent fbac41d9
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ module Homebrew
result = LinkageChecker.new(keg)
if ARGV.include?("--test")
result.display_test_output
elsif ARGV.include?("--reverse")
result.display_reverse_output
else
result.display_normal_output
end
......@@ -42,6 +44,7 @@ module Homebrew
@system_dylibs = Set.new
@broken_dylibs = Set.new
@variable_dylibs = Set.new
@reverse_links = Hash.new { |h, k| h[k] = Set.new }
check_dylibs
end
......@@ -50,6 +53,7 @@ module Homebrew
next if file.symlink? || file.directory?
next unless file.dylib? || file.mach_o_executable? || file.mach_o_bundle?
file.dynamically_linked_libraries.each do |dylib|
@reverse_links[dylib] << file
if dylib.start_with? "@"
@variable_dylibs << dylib
else
......@@ -84,6 +88,19 @@ module Homebrew
display_items "Possible undeclared dependencies", @undeclared_deps
end
def display_reverse_output
return if @reverse_links.empty?
sorted = @reverse_links.sort
sorted.each do |dylib, files|
puts dylib
files.each do |f|
unprefixed = f.to_s.strip_prefix "#{@keg.to_s}/"
puts " #{unprefixed}"
end
puts unless dylib == sorted.last[0]
end
end
def display_test_output
display_items "Missing libraries", @broken_dylibs
puts "No broken dylib links" if @broken_dylibs.empty?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment