aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/mach.rb
diff options
context:
space:
mode:
authorMisty De Meo2013-08-11 19:11:58 -0700
committerMisty De Meo2013-08-15 22:46:56 -0700
commit1470fd3f0f992ad2dd14d173710b630cf64a9b80 (patch)
tree2f4f1459709baa45add4f19b262f866c74aef332 /Library/Homebrew/mach.rb
parent7583729b2055bdea7c44541e3d1851f447090b5e (diff)
downloadhomebrew-1470fd3f0f992ad2dd14d173710b630cf64a9b80.tar.bz2
Mach: improve PPC arch detection
Also adds some reusable constants into the global Hardware::CPU namespace, available on both OS X and Linux.
Diffstat (limited to 'Library/Homebrew/mach.rb')
-rw-r--r--Library/Homebrew/mach.rb32
1 files changed, 28 insertions, 4 deletions
diff --git a/Library/Homebrew/mach.rb b/Library/Homebrew/mach.rb
index 44726ac5f..a2a87db46 100644
--- a/Library/Homebrew/mach.rb
+++ b/Library/Homebrew/mach.rb
@@ -1,20 +1,44 @@
module ArchitectureListExtension
+ def fat?
+ length > 1
+ end
+
+ def intel_universal?
+ intersects_all?(Hardware::CPU::INTEL_32BIT_ARCHS, Hardware::CPU::INTEL_64BIT_ARCHS)
+ end
+
+ def ppc_universal?
+ intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::PPC_64BIT_ARCHS)
+ end
+
+ # Old-style 32-bit PPC/Intel universal, e.g. ppc7400 and i386
+ def cross_universal?
+ intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::INTEL_32BIT_ARCHS)
+ end
+
def universal?
- self.include? :i386 and self.include? :x86_64
+ intel_universal? || ppc_universal? || cross_universal?
end
def ppc?
- self.include? :ppc7400 or self.include? :ppc64
+ (PPC_32BIT_ARCHS+PPC_64BIT_ARCHS).any? {|a| self.include? a}
end
def remove_ppc!
- self.delete :ppc7400
- self.delete :ppc64
+ (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each {|a| self.delete a}
end
def as_arch_flags
self.collect{ |a| "-arch #{a}" }.join(' ')
end
+
+ protected
+
+ def intersects_all?(*set)
+ set.all? do |archset|
+ archset.any? {|a| self.include? a}
+ end
+ end
end
module MachO