From 35e2209c10ffcf6a666ac4a8051a1f20801895ea Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Tue, 26 Jan 2016 11:57:58 -0500 Subject: [PATCH] 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 --- Library/Homebrew/os/mac/architecture_list.rb | 52 +++++++++++++++++ .../os/mac/{mach.rb => cctools_mach.rb} | 57 +------------------ 2 files changed, 54 insertions(+), 55 deletions(-) create mode 100644 Library/Homebrew/os/mac/architecture_list.rb rename Library/Homebrew/os/mac/{mach.rb => cctools_mach.rb} (73%) diff --git a/Library/Homebrew/os/mac/architecture_list.rb b/Library/Homebrew/os/mac/architecture_list.rb new file mode 100644 index 0000000000..809a27077c --- /dev/null +++ b/Library/Homebrew/os/mac/architecture_list.rb @@ -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 diff --git a/Library/Homebrew/os/mac/mach.rb b/Library/Homebrew/os/mac/cctools_mach.rb similarity index 73% rename from Library/Homebrew/os/mac/mach.rb rename to Library/Homebrew/os/mac/cctools_mach.rb index b2060e3758..60f12a7ee8 100644 --- a/Library/Homebrew/os/mac/mach.rb +++ b/Library/Homebrew/os/mac/cctools_mach.rb @@ -1,57 +1,6 @@ -module ArchitectureListExtension - # @private - def fat? - length > 1 - end +require "os/mac/architecture_list" - # @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 - -module MachO +module CctoolsMachO # @private OTOOL_RX = /\t(.*) \(compatibility version (?:\d+\.)*\d+, current version (?:\d+\.)*\d+\)/ @@ -77,8 +26,6 @@ module MachO end when 0xcefaedfe, 0xcffaedfe, 0xfeedface, 0xfeedfacf # Single arch offsets << 0 - when 0x7f454c46 # ELF - mach_data << { :arch => :x86_64, :type => :executable } else raise "Not a Mach-O binary." end