blob: da146ac89236291dd0b7474b42414a972beb287a (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  | 
require 'hardware'
module Homebrew extend self
  def __config
    puts config_s
  end
  def llvm
    @llvm ||= MacOS.llvm_build_version
  end
  def gcc_42
    @gcc_42 ||= MacOS.gcc_42_build_version
  end
  def gcc_40
    @gcc_40 ||= MacOS.gcc_40_build_version
  end
  def clang
    @clang ||= MacOS.clang_version
  end
  def clang_build
    @clang_build ||= MacOS.clang_build_version
  end
  def xcode_version
    @xcode_version || MacOS.xcode_version
  end
  def sha
    sha = HOMEBREW_REPOSITORY.cd do
      `git rev-parse --verify -q HEAD 2>/dev/null`.chomp
    end
    if sha.empty? then "(none)" else sha end
  end
  def describe_x11
    return "N/A" unless x11_installed?
    return case x11_path = Pathname.new("/usr/X11").realpath.to_s
    when "/usr/X11" then "/usr/X11"
    else "/usr/X11 => #{x11_path}"
    end
  end
  def describe_perl
    perl = `which perl`.chomp
    return "N/A" if perl.empty?
    real_perl = Pathname.new(perl).realpath.to_s
    return perl if perl == real_perl
    return "#{perl} => #{real_perl}"
  end
  def describe_python
    python = `which python`.chomp
    return "N/A" if python.empty?
    real_python = Pathname.new(python).realpath.to_s
    return python if python == real_python
    return "#{python} => #{real_python}"
  end
  def describe_ruby
    ruby = `which ruby`.chomp
    return "N/A" if ruby.empty?
    real_ruby = Pathname.new(ruby).realpath.to_s
    return ruby if ruby == real_ruby
    return "#{ruby} => #{real_ruby}"
  end
  def real_path a_path
    Pathname.new(a_path).realpath.to_s
  end
  def hardware
    "CPU: #{Hardware.cores_as_words}-core #{Hardware.bits}-bit #{Hardware.intel_family}"
  end
  def kernel
    `uname -m`.chomp
  end
  # we try to keep output minimal
  def dump_build_config
    puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}" if HOMEBREW_PREFIX.to_s != "/usr/local"
    puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.to_s != "#{HOMEBREW_PREFIX}/Cellar"
    puts hardware
    puts "MacOS: #{MACOS_FULL_VERSION}-#{kernel}"
    puts "Xcode: #{xcode_version}"
    puts "/usr/bin/ruby: #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}" if RUBY_VERSION.to_f != 1.8
    ruby = Pathname.new("/usr/bin/ruby")
    puts "/usr/bin/ruby => #{ruby.realpath}" unless ruby.realpath.to_s =~ %r{^/System}
    ponk = macports_or_fink_installed?
    puts "MacPorts/Fink: #{ponk?}" if ponk
    x11 = describe_x11
    puts "X11: #{x11}" unless x11 == "/usr/X11"
  end
  def config_s; <<-EOS.undent
    HOMEBREW_VERSION: #{HOMEBREW_VERSION}
    HEAD: #{sha}
    HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}
    HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}
    #{hardware}
    OS X: #{MACOS_FULL_VERSION}
    Kernel Architecture: #{kernel}
    Xcode: #{xcode_version}
    GCC-4.0: #{gcc_40 ? "build #{gcc_40}" : "N/A"}
    GCC-4.2: #{gcc_42 ? "build #{gcc_42}" : "N/A"}
    LLVM: #{llvm ? "build #{llvm}" : "N/A"}
    Clang: #{clang ? "#{clang} build #{clang_build}" : "N/A"}
    MacPorts or Fink? #{macports_or_fink_installed?}
    X11: #{describe_x11}
    System Ruby: #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}
    /usr/bin/ruby => #{real_path("/usr/bin/ruby")}
    Which Perl:   #{describe_perl}
    Which Python: #{describe_python}
    Which Ruby:   #{describe_ruby}
    EOS
  end
end
  |