From 91a69c6e2c20fe5e170a06171dd08bf986235f71 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 26 Nov 2013 20:23:19 -0600 Subject: [PATCH] Add Hardware::CPU.intel? and Hardware::CPU.ppc? --- Library/Formula/avidemux.rb | 2 +- Library/Formula/boost.rb | 4 ++-- Library/Formula/ffmpeg.rb | 2 +- Library/Homebrew/hardware.rb | 10 +++++++++- Library/Homebrew/os/mac/hardware.rb | 14 ++++++-------- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Library/Formula/avidemux.rb b/Library/Formula/avidemux.rb index f5ecd000a21f..d4966935aa54 100644 --- a/Library/Formula/avidemux.rb +++ b/Library/Formula/avidemux.rb @@ -43,7 +43,7 @@ def install # For 32-bit compilation under gcc 4.2, see: # http://trac.macports.org/ticket/20938#comment:22 - if MacOS.version <= :leopard or Hardware.is_32_bit? && Hardware.cpu_type == :intel && ENV.compiler == :clang + if MacOS.version <= :leopard or Hardware.is_32_bit? && Hardware::CPU.intel? && ENV.compiler == :clang inreplace 'cmake/admFFmpegBuild.cmake', '${CMAKE_INSTALL_PREFIX})', '${CMAKE_INSTALL_PREFIX} --extra-cflags=-mdynamic-no-pic)' diff --git a/Library/Formula/boost.rb b/Library/Formula/boost.rb index 3e713779f08a..40048a953468 100644 --- a/Library/Formula/boost.rb +++ b/Library/Formula/boost.rb @@ -126,7 +126,7 @@ def install # The context library is implemented as x86_64 ASM, so it # won't build on PPC or 32-bit builds # see https://github.com/mxcl/homebrew/issues/17646 - if Hardware::CPU.type == :ppc || Hardware::CPU.is_32_bit? || build.universal? + if Hardware::CPU.ppc? || Hardware::CPU.is_32_bit? || build.universal? without_libraries << "context" # The coroutine library depends on the context library. without_libraries << "coroutine" @@ -178,7 +178,7 @@ def caveats EOS end - if Hardware::CPU.type == :ppc || Hardware::CPU.is_32_bit? || build.universal? + if Hardware::CPU.ppc? || Hardware::CPU.is_32_bit? || build.universal? s += <<-EOS.undent Building of Boost.Context and Boost.Coroutine is disabled as they are diff --git a/Library/Formula/ffmpeg.rb b/Library/Formula/ffmpeg.rb index 9ecea9f4d480..09f616e22569 100644 --- a/Library/Formula/ffmpeg.rb +++ b/Library/Formula/ffmpeg.rb @@ -102,7 +102,7 @@ def install # For 32-bit compilation under gcc 4.2, see: # http://trac.macports.org/ticket/20938#comment:22 - ENV.append_to_cflags "-mdynamic-no-pic" if Hardware.is_32_bit? && Hardware.cpu_type == :intel && ENV.compiler == :clang + ENV.append_to_cflags "-mdynamic-no-pic" if Hardware.is_32_bit? && Hardware::CPU.intel? && ENV.compiler == :clang system "./configure", *args diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index 0a52d10dbc31..a47de524724e 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -30,6 +30,14 @@ def is_32_bit? def is_64_bit? bits == 64 end + + def intel? + type == :intel + end + + def ppc? + type == :ppc + end end if OS.mac? @@ -53,7 +61,7 @@ def self.cores_as_words end def self.oldest_cpu - if Hardware::CPU.type == :intel + if Hardware::CPU.intel? if Hardware::CPU.is_64_bit? :core2 else diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb index 53a9a6463fba..888a99b1b50d 100644 --- a/Library/Homebrew/os/mac/hardware.rb +++ b/Library/Homebrew/os/mac/hardware.rb @@ -27,9 +27,8 @@ def type end def family - if type == :intel - @intel_family ||= `/usr/sbin/sysctl -n hw.cpufamily`.to_i - case @intel_family + if intel? + case @intel_family ||= `/usr/sbin/sysctl -n hw.cpufamily`.to_i when 0x73d67300 # Yonah: Core Solo/Duo :core when 0x426f69ef # Merom: Core 2 Duo @@ -49,9 +48,8 @@ def family else :dunno end - elsif type == :ppc - @ppc_family ||= `/usr/sbin/sysctl -n hw.cpusubtype`.to_i - case @ppc_family + elsif ppc? + case @ppc_family ||= `/usr/sbin/sysctl -n hw.cpusubtype`.to_i when 9 :g3 # PowerPC 750 when 10 @@ -81,11 +79,11 @@ def bits end def arch_32_bit - type == :intel ? :i386 : :ppc + intel? ? :i386 : :ppc end def arch_64_bit - type == :intel ? :x86_64 : :ppc64 + intel? ? :x86_64 : :ppc64 end # Returns an array that's been extended with ArchitectureListExtension,