aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb37
1 files changed, 2 insertions, 35 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index de797f2d6..ee45dd0f9 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -186,43 +186,10 @@ def gzip *paths
end
end
-module ArchitectureListExtension
- def universal?
- self.include? :i386 and self.include? :x86_64
- end
-
- def remove_ppc!
- self.delete :ppc7400
- self.delete :ppc64
- end
-
- def as_arch_flags
- self.collect{ |a| "-arch #{a}" }.join(' ')
- end
-end
-
# Returns array of architectures that the given command or library is built for.
def archs_for_command cmd
- cmd = cmd.to_s # If we were passed a Pathname, turn it into a string.
- cmd = `/usr/bin/which #{cmd}` unless Pathname.new(cmd).absolute?
- cmd.gsub! ' ', '\\ ' # Escape spaces in the filename.
-
- lines = `/usr/bin/file -L #{cmd}`
- archs = lines.to_a.inject([]) do |archs, line|
- case line
- when /Mach-O (executable|dynamically linked shared library) ppc/
- archs << :ppc7400
- when /Mach-O 64-bit (executable|dynamically linked shared library) ppc64/
- archs << :ppc64
- when /Mach-O (executable|dynamically linked shared library) i386/
- archs << :i386
- when /Mach-O 64-bit (executable|dynamically linked shared library) x86_64/
- archs << :x86_64
- else
- archs
- end
- end
- archs.extend(ArchitectureListExtension)
+ cmd = which(cmd) unless Pathname.new(cmd).absolute?
+ Pathname.new(cmd).archs
end
def inreplace path, before=nil, after=nil