Class: BuildOptions

Inherits:
Object show all
Defined in:
Library/Homebrew/build_options.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.formula_install_optionsObject



107
108
109
110
111
# File 'Library/Homebrew/build_options.rb', line 107

def self.formula_install_options
  @formula_install_options ||= ARGV.formula_install_option_names.map do |option_name|
    Option.new option_name[2..-1]
  end
end

Instance Method Details

#bottle?Boolean Also known as: build_bottle?

True if a Formula is being built as a bottle (i.e. binary package).



47
48
49
# File 'Library/Homebrew/build_options.rb', line 47

def bottle?
  include? "build-bottle"
end

#cxx11?Boolean

True if a Formula is being built in C++11 mode.



83
84
85
# File 'Library/Homebrew/build_options.rb', line 83

def cxx11?
  include?("c++11") && option_defined?("c++11")
end

#devel?Boolean

True if a Formula is being built with Formula.devel instead of Formula.stable.

args << "--some-beta" if build.devel?


65
66
67
# File 'Library/Homebrew/build_options.rb', line 65

def devel?
  include? "devel"
end

#head?Boolean

True if a Formula is being built with Formula.head instead of Formula.stable.

args << "--some-new-stuff" if build.head?
# If there are multiple conditional arguments use a block instead of lines.
 if build.head?
   args << "--i-want-pizza"
   args << "--and-a-cold-beer" if build.with? "cold-beer"
 end


59
60
61
# File 'Library/Homebrew/build_options.rb', line 59

def head?
  include? "HEAD"
end

#include?(name) ⇒ Boolean

Deprecated.

True if a Formula is being built with a specific option (which isn't named with-* or without-*).



11
12
13
# File 'Library/Homebrew/build_options.rb', line 11

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

#stable?Boolean

True if a Formula is being built with Formula.stable instead of Formula.devel or Formula.head. This is the default.

args << "--some-beta" if build.devel?


71
72
73
# File 'Library/Homebrew/build_options.rb', line 71

def stable?
  !(head? || devel?)
end

#universal?Boolean

True if a Formula is being built universally. e.g. on newer Intel Macs this means a combined x86_64/x86 binary/library.

args << "--universal-binary" if build.universal?


78
79
80
# File 'Library/Homebrew/build_options.rb', line 78

def universal?
  include?("universal") && option_defined?("universal")
end

#with?(val) ⇒ Boolean

True if a Formula is being built with a specific option.

args << "--i-want-spam" if build.with? "spam"

args << "--qt-gui" if build.with? "qt" # "--with-qt" ==> build.with? "qt"

# If a formula presents a user with a choice, but the choice must be fulfilled:
if build.with? "example2"
  args << "--with-example2"
else
  args << "--with-example1"
end


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'Library/Homebrew/build_options.rb', line 26

def with?(val)
  option_names = val.respond_to?(:option_names) ? val.option_names : [val]

  option_names.any? do |name|
    if option_defined? "with-#{name}"
      include? "with-#{name}"
    elsif option_defined? "without-#{name}"
      !include? "without-#{name}"
    else
      false
    end
  end
end

#without?(val) ⇒ Boolean

True if a Formula is being built without a specific option.

args << "--no-spam-plz" if build.without? "spam"


42
43
44
# File 'Library/Homebrew/build_options.rb', line 42

def without?(val)
  !with?(val)
end