diff options
| author | Adam Vandenberg | 2010-05-10 10:14:20 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-05-10 20:40:16 -0700 |
| commit | 5f4871ba9df0e00daf042803d8945deba2534951 (patch) | |
| tree | 32755478b33b22e313da3e0a452ff6a91c154749 /Library | |
| parent | 2563b32bb6843e09a515fd01f6aa6bd9df388cdc (diff) | |
| download | brew-5f4871ba9df0e00daf042803d8945deba2534951.tar.bz2 | |
Improve archs_for_command
* Work on commands or dylibs
* Use an extension for the list of arches
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/utils.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 700b0acf1..3d65b74b4 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -130,26 +130,33 @@ def gzip path return Pathname.new(path+".gz") end -# Returns array of architectures that the given command is built for. +module ArchitectureListExtension + def universal? + self.include? :i386 and self.include? :x86_64 + 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. - IO.popen("/usr/bin/file #{cmd}").readlines.inject(%w[]) do |archs, line| + archs = IO.popen("/usr/bin/file #{cmd}").readlines.inject([]) do |archs, line| case line - when /Mach-O executable ppc/ + when /Mach-O (executable|dynamically linked shared library) ppc/ archs << :ppc7400 - when /Mach-O 64-bit executable ppc64/ + when /Mach-O 64-bit (executable|dynamically linked shared library) ppc64/ archs << :ppc64 - when /Mach-O executable i386/ + when /Mach-O (executable|dynamically linked shared library) i386/ archs << :i386 - when /Mach-O 64-bit executable x86_64/ + when /Mach-O 64-bit (executable|dynamically linked shared library) x86_64/ archs << :x86_64 else archs end end + archs.extend(ArchitectureListExtension) end # String extensions added by inreplace below. |
