Move some helper functions into Hardware
This commit is contained in:
parent
83fc432eab
commit
4fbcf13e65
@ -59,10 +59,24 @@ class Hardware
|
|||||||
def self.processor_count
|
def self.processor_count
|
||||||
@@processor_count ||= `/usr/sbin/sysctl -n hw.ncpu`.to_i
|
@@processor_count ||= `/usr/sbin/sysctl -n hw.ncpu`.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.cores_as_words
|
||||||
|
case Hardware.processor_count
|
||||||
|
when 1 then 'single'
|
||||||
|
when 2 then 'dual'
|
||||||
|
when 4 then 'quad'
|
||||||
|
else
|
||||||
|
Hardware.processor_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.is_64_bit?
|
def self.is_64_bit?
|
||||||
self.sysctl_bool("hw.cpu64bit_capable")
|
self.sysctl_bool("hw.cpu64bit_capable")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.bits
|
||||||
|
Hardware.is_64_bit? ? 64 : 32
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def self.sysctl_bool(property)
|
def self.sysctl_bool(property)
|
||||||
|
|||||||
10
bin/brew
10
bin/brew
@ -42,14 +42,8 @@ end
|
|||||||
|
|
||||||
def dump_config
|
def dump_config
|
||||||
require 'hardware'
|
require 'hardware'
|
||||||
bits = Hardware.is_64_bit? ? 64 : 32
|
bits = Hardware.bits
|
||||||
cores = case Hardware.processor_count
|
cores = Hardware.cores_as_words
|
||||||
when 1 then 'single'
|
|
||||||
when 2 then 'dual'
|
|
||||||
when 4 then 'quad'
|
|
||||||
else
|
|
||||||
Hardware.processor_count
|
|
||||||
end
|
|
||||||
llvm = llvm_build
|
llvm = llvm_build
|
||||||
sha = `git rev-parse --verify HEAD`.chomp
|
sha = `git rev-parse --verify HEAD`.chomp
|
||||||
kernel_arch = `uname -m`.chomp
|
kernel_arch = `uname -m`.chomp
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user