Mach: improve PPC arch detection
Also adds some reusable constants into the global Hardware::CPU namespace, available on both OS X and Linux.
This commit is contained in:
parent
fa03fd91b4
commit
ab633864d5
@ -1,5 +1,10 @@
|
|||||||
class Hardware
|
class Hardware
|
||||||
module CPU extend self
|
module CPU extend self
|
||||||
|
INTEL_32BIT_ARCHS = [:i386].freeze
|
||||||
|
INTEL_64BIT_ARCHS = [:x86_64].freeze
|
||||||
|
PPC_32BIT_ARCHS = [:ppc, :ppc7400, :ppc7450, :ppc970].freeze
|
||||||
|
PPC_64BIT_ARCHS = [:ppc64].freeze
|
||||||
|
|
||||||
def type
|
def type
|
||||||
@type || :dunno
|
@type || :dunno
|
||||||
end
|
end
|
||||||
|
@ -1,20 +1,44 @@
|
|||||||
module ArchitectureListExtension
|
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?
|
def universal?
|
||||||
self.include? :i386 and self.include? :x86_64
|
intel_universal? || ppc_universal? || cross_universal?
|
||||||
end
|
end
|
||||||
|
|
||||||
def ppc?
|
def ppc?
|
||||||
self.include? :ppc7400 or self.include? :ppc64
|
(PPC_32BIT_ARCHS+PPC_64BIT_ARCHS).any? {|a| self.include? a}
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_ppc!
|
def remove_ppc!
|
||||||
self.delete :ppc7400
|
(Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each {|a| self.delete a}
|
||||||
self.delete :ppc64
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_arch_flags
|
def as_arch_flags
|
||||||
self.collect{ |a| "-arch #{a}" }.join(' ')
|
self.collect{ |a| "-arch #{a}" }.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def intersects_all?(*set)
|
||||||
|
set.all? do |archset|
|
||||||
|
archset.any? {|a| self.include? a}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user