From 892a3239bc4b382ed2c1b714396650f28096da2e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 16 Jul 2016 21:05:07 +0100 Subject: [PATCH] hardware: more porting to generic layer. --- Library/Homebrew/hardware.rb | 15 +++++++++++++-- Library/Homebrew/test/test_hardware.rb | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index c705c5e50c..5447854a65 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -28,7 +28,11 @@ module Hardware end def type - :dunno + case RUBY_PLATFORM + when /x86_64/, /i\d86/ then :intel + when /ppc\d+/ then :ppc + else :dunno + end end def family @@ -40,7 +44,14 @@ module Hardware end def bits - 64 + case RUBY_PLATFORM + when /x86_64/, /ppc64/ then 64 + when /i\d86/, /ppc/ then 32 + end + end + + def sse4? + RUBY_PLATFORM.to_s.include?("x86_64") end def is_32_bit? diff --git a/Library/Homebrew/test/test_hardware.rb b/Library/Homebrew/test/test_hardware.rb index d38c74df6d..56d0980fa6 100644 --- a/Library/Homebrew/test/test_hardware.rb +++ b/Library/Homebrew/test/test_hardware.rb @@ -3,11 +3,11 @@ require "hardware" class HardwareTests < Homebrew::TestCase def test_hardware_cpu_type - assert_includes [:intel, :ppc], Hardware::CPU.type + assert_includes [:intel, :ppc, :dunno], Hardware::CPU.type end def test_hardware_intel_family - families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake] + families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :dunno] assert_includes families, Hardware::CPU.family end if Hardware::CPU.intel? end