blob: a7fd8715e6484e8ee60410434265a54c1f9804b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
def hw_model_output
require 'fileutils'
HOMEBREW_CACHE.mkpath
exe=HOMEBREW_CACHE+'hw.model'
Kernel.system "gcc -Os #{File.dirname __FILE__}/hw.model.c -o #{exe}" unless exe.file?
/(.*)(\d+),(\d+)/ =~ `#{exe}`
yield $1, $2.to_i, $3.to_i
end
# http://support.apple.com/kb/HT3696
# http://www.cocoadev.com/index.pl?MacintoshModels
def hw_model
hw_model_output do |model, major, minor|
case model
when "iMac"
if major <=4
:core1
else
$unknown_hw_model=true if major >8
:core2
end
when "MacBookAir"
$unknown_hw_model=true if major > 1
:core2
when "MacBook"
if major <= 1
:core1
else
$unknown_hw_model=true if major > 4
:core2
end
when "MacBookPro"
if major <= 1
:core1
else
$unknown_hw_model=true if major > 5
:core2
end
when "Macmini" # Mac mini (Core Duo/Solo)
$unknown_hw_model=true if major > 1
:core
when "MacPro"
$unknown_hw_model=true if major > 3
:xeon
when "PowerBook", "PowerMac", "RackMac" then :ppc
when "Xserve"
$unknown_hw_model=true if major > 2
:xeon
when "ADP" then :dunno # Developer Transition Kit
when "M43ADP" then :dunno # Development Mac Pro
else :dunno
end
end
end
|