brew/Library/Homebrew/build_options.rb

82 lines
1.4 KiB
Ruby
Raw Normal View History

require 'options'
2013-01-23 00:26:23 -06:00
class BuildOptions
attr_accessor :universal
def initialize(args, options)
@args = args
@options = options
2013-01-23 00:26:23 -06:00
end
def include? name
@args.include?("--#{name}")
2013-01-23 00:26:23 -06:00
end
def with? val
if val.respond_to?(:option_name)
name = val.option_name
else
name = val
end
2014-07-31 19:37:39 -05:00
if option_defined? "with-#{name}"
include? "with-#{name}"
2014-07-31 19:37:39 -05:00
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
2013-01-23 00:26:23 -06:00
def head?
include? "HEAD"
2013-01-23 00:26:23 -06:00
end
def devel?
include? "devel"
2013-01-23 00:26:23 -06:00
end
def stable?
not (head? or devel?)
end
# True if the user requested a universal build.
def universal?
2014-07-31 19:37:39 -05:00
universal || include?("universal") && option_defined?("universal")
2013-01-23 00:26:23 -06:00
end
# True if the user requested to enable C++11 mode.
def cxx11?
2014-07-31 19:37:39 -05:00
include?("c++11") && option_defined?("c++11")
end
2013-01-23 00:26:23 -06:00
# 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?
2014-07-31 19:37:39 -05:00
include?("32-bit") && option_defined?("32-bit")
2013-01-23 00:26:23 -06:00
end
def used_options
Options.new(@options & @args)
2013-01-23 00:26:23 -06:00
end
def unused_options
Options.new(@options - @args)
2013-01-23 00:26:23 -06:00
end
2014-07-31 19:37:39 -05:00
private
def option_defined? name
@options.include? name
end
2013-01-23 00:26:23 -06:00
end