diff options
| author | Adam Vandenberg | 2010-05-10 10:14:20 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-05-10 20:40:16 -0700 |
| commit | ea8ebf7899f83cb91759f4a1ea1d8b5d218a5c76 (patch) | |
| tree | dd36674b778d2dc2d93997653ef4cc099eac7506 /Library | |
| parent | 8f867170cb8f1ad2968337321cbec93062df3d30 (diff) | |
| download | homebrew-ea8ebf7899f83cb91759f4a1ea1d8b5d218a5c76.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. |
