Class: BuildOptions Private

Inherits:
Object show all
Defined in:
build_options.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Options for a formula build.

Instance Method Summary collapse

Constructor Details

#initialize(args, options) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



7
8
9
10
# File 'build_options.rb', line 7

def initialize(args, options)
  @args = T.let(args, Options)
  @options = T.let(options, Options)
end

Instance Method Details

#any_args_or_options?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

True if the build has any arguments or options specified.

Returns:

  • (Boolean)


106
107
108
# File 'build_options.rb', line 106

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

#bottle?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

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

Returns:

  • (Boolean)


66
67
68
# File 'build_options.rb', line 66

def bottle?
  include? "build-bottle"
end

#head?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

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

Examples

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)


87
88
89
# File 'build_options.rb', line 87

def head?
  include? "HEAD"
end

#stable?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

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

Example

args << "--some-feature" if build.stable?

Returns:

  • (Boolean)


100
101
102
# File 'build_options.rb', line 100

def stable?
  !head?
end

#unused_optionsOptions

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



116
117
118
# File 'build_options.rb', line 116

def unused_options
  @options - @args
end

#used_optionsOptions

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



111
112
113
# File 'build_options.rb', line 111

def used_options
  @options & @args
end

#with?(val) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

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

Examples

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

Parameters:

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'build_options.rb', line 34

def with?(val)
  option_names = if val.is_a?(String)
    [val]
  else
    val.option_names
  end

  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

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

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

Example

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

Parameters:

Returns:

  • (Boolean)


60
61
62
# File 'build_options.rb', line 60

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