aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/build_options.rb
blob: 64ca931736df873258d4a8a2169fd91e654c121e (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
class BuildOptions
  def initialize(args, options)
    @args = args
    @options = options
  end

  def include? name
    @args.include?("--#{name}")
  end

  def with? val
    name = val.respond_to?(:option_name) ? val.option_name : val

    if option_defined? "with-#{name}"
      include? "with-#{name}"
    elsif option_defined? "without-#{name}"
      not include? "without-#{name}"
    else
      false
    end
  end

  def without? name
    not with? name
  end

  def bottle?
    include? "build-bottle"
  end

  def head?
    include? "HEAD"
  end

  def devel?
    include? "devel"
  end

  def stable?
    not (head? or devel?)
  end

  # True if the user requested a universal build.
  def universal?
    include?("universal") && option_defined?("universal")
  end

  # True if the user requested to enable C++11 mode.
  def cxx11?
    include?("c++11") && option_defined?("c++11")
  end

  # Request a 32-bit only build.
  # This is needed for some use-cases though we prefer to build Universal
  # when a 32-bit version is needed.
  def build_32_bit?
    include?("32-bit") && option_defined?("32-bit")
  end

  def used_options
    @options & @args
  end

  def unused_options
    @options - @args
  end

  private

  def option_defined? name
    @options.include? name
  end
end