architecture_list: add new module.
remove old mach.rb, replace with cctools_mach.rb and prune ELF case move ArchitectureListExtension to separate file ELF support is maintained in Linuxbrew
This commit is contained in:
parent
0d094ac8ef
commit
35e2209c10
52
Library/Homebrew/os/mac/architecture_list.rb
Normal file
52
Library/Homebrew/os/mac/architecture_list.rb
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
module ArchitectureListExtension
|
||||||
|
# @private
|
||||||
|
def fat?
|
||||||
|
length > 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def intel_universal?
|
||||||
|
intersects_all?(Hardware::CPU::INTEL_32BIT_ARCHS, Hardware::CPU::INTEL_64BIT_ARCHS)
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
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
|
||||||
|
# @private
|
||||||
|
def cross_universal?
|
||||||
|
intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::INTEL_32BIT_ARCHS)
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def universal?
|
||||||
|
intel_universal? || ppc_universal? || cross_universal?
|
||||||
|
end
|
||||||
|
|
||||||
|
def ppc?
|
||||||
|
(Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| self.include? a }
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def remove_ppc!
|
||||||
|
(Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a }
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_arch_flags
|
||||||
|
collect { |a| "-arch #{a}" }.join(" ")
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_cmake_arch_flags
|
||||||
|
join(";")
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def intersects_all?(*set)
|
||||||
|
set.all? do |archset|
|
||||||
|
archset.any? { |a| self.include? a }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,57 +1,6 @@
|
|||||||
module ArchitectureListExtension
|
require "os/mac/architecture_list"
|
||||||
# @private
|
|
||||||
def fat?
|
|
||||||
length > 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
module CctoolsMachO
|
||||||
def intel_universal?
|
|
||||||
intersects_all?(Hardware::CPU::INTEL_32BIT_ARCHS, Hardware::CPU::INTEL_64BIT_ARCHS)
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
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
|
|
||||||
# @private
|
|
||||||
def cross_universal?
|
|
||||||
intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::INTEL_32BIT_ARCHS)
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def universal?
|
|
||||||
intel_universal? || ppc_universal? || cross_universal?
|
|
||||||
end
|
|
||||||
|
|
||||||
def ppc?
|
|
||||||
(Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| self.include? a }
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def remove_ppc!
|
|
||||||
(Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a }
|
|
||||||
end
|
|
||||||
|
|
||||||
def as_arch_flags
|
|
||||||
collect { |a| "-arch #{a}" }.join(" ")
|
|
||||||
end
|
|
||||||
|
|
||||||
def as_cmake_arch_flags
|
|
||||||
join(";")
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def intersects_all?(*set)
|
|
||||||
set.all? do |archset|
|
|
||||||
archset.any? { |a| self.include? a }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module MachO
|
|
||||||
# @private
|
# @private
|
||||||
OTOOL_RX = /\t(.*) \(compatibility version (?:\d+\.)*\d+, current version (?:\d+\.)*\d+\)/
|
OTOOL_RX = /\t(.*) \(compatibility version (?:\d+\.)*\d+, current version (?:\d+\.)*\d+\)/
|
||||||
|
|
||||||
@ -77,8 +26,6 @@ module MachO
|
|||||||
end
|
end
|
||||||
when 0xcefaedfe, 0xcffaedfe, 0xfeedface, 0xfeedfacf # Single arch
|
when 0xcefaedfe, 0xcffaedfe, 0xfeedface, 0xfeedfacf # Single arch
|
||||||
offsets << 0
|
offsets << 0
|
||||||
when 0x7f454c46 # ELF
|
|
||||||
mach_data << { :arch => :x86_64, :type => :executable }
|
|
||||||
else
|
else
|
||||||
raise "Not a Mach-O binary."
|
raise "Not a Mach-O binary."
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user