diff options
| author | Jack Nagel | 2012-05-28 20:39:05 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-05-30 22:32:48 -0500 |
| commit | 53ce9dba536caeba5c884e3f904d91f9529f6b80 (patch) | |
| tree | 9bca3cd5175cb28e3bde4281c6b351df4dbb1e7c /Library/Homebrew/utils.rb | |
| parent | 7bb1894df53e983a305cbdd1c98e433833059263 (diff) | |
| download | brew-53ce9dba536caeba5c884e3f904d91f9529f6b80.tar.bz2 | |
archs_for_command: use new Mach-O Pathname methods
- Reimplement archs_for_command on top of the new Mach-O methods
- Move ArchitectureListExtension to mach.rb
- Add a test for the ArchitectureListExtension
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 37 |
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 |
