Class: BuildOptions Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Options for a formula build.

Instance Method Summary collapse

Instance Method Details

#any_args_or_options?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

True if the build has any arguments or options specified.

Returns:

  • (Boolean)

95
96
97
# File 'Library/Homebrew/build_options.rb', line 95

def any_args_or_options?
  !@args.empty? || !@options.empty?
end

#bottle?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Returns:

  • (Boolean)

53
54
55
# File 'Library/Homebrew/build_options.rb', line 53

def bottle?
  private_include? "build-bottle"
end

#cxx11?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Returns:

  • (Boolean)

89
90
91
92
# File 'Library/Homebrew/build_options.rb', line 89

def cxx11?
  odeprecated "BuildOptions#cxx11?"
  private_include?("c++11") && option_defined?("c++11")
end

#head?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Returns:

  • (Boolean)

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

def head?
  private_include? "HEAD"
end

#include?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.

TODO: rename private_include? when include? is removed.

Returns:

  • (Boolean)

16
17
18
19
# File 'Library/Homebrew/build_options.rb', line 16

def include?(name)
  odeprecated "BuildOptions#include?"
  private_include?("--#{name}")
end

#stable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

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

Returns:

  • (Boolean)

76
77
78
# File 'Library/Homebrew/build_options.rb', line 76

def stable?
  !head?
end

#universal?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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?

Returns:

  • (Boolean)

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

def universal?
  odeprecated "BuildOptions#universal?"
  private_include?("universal") && option_defined?("universal")
end

#with?(val) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Returns:

  • (Boolean)

32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'Library/Homebrew/build_options.rb', line 32

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

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

#without?(val) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

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

Returns:

  • (Boolean)

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

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