2013-01-23 00:26:23 -06:00
|
|
|
class BuildOptions
|
2014-07-31 19:37:39 -05:00
|
|
|
def initialize(args, options)
|
2014-08-13 11:09:57 -05:00
|
|
|
@args = args
|
2014-07-31 19:37:39 -05:00
|
|
|
@options = options
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def include?(name)
|
2014-08-11 17:48:30 -05:00
|
|
|
@args.include?("--#{name}")
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def with?(val)
|
2014-10-09 00:20:15 -05:00
|
|
|
name = val.respond_to?(:option_name) ? val.option_name : val
|
2013-12-09 14:36:10 -06:00
|
|
|
|
2014-07-31 19:37:39 -05:00
|
|
|
if option_defined? "with-#{name}"
|
2013-01-23 00:26:26 -06:00
|
|
|
include? "with-#{name}"
|
2014-07-31 19:37:39 -05:00
|
|
|
elsif option_defined? "without-#{name}"
|
2015-08-03 13:09:07 +01:00
|
|
|
!include? "without-#{name}"
|
2013-01-23 00:26:26 -06:00
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def without?(name)
|
|
|
|
!with? name
|
2013-01-23 00:26:26 -06:00
|
|
|
end
|
|
|
|
|
2013-10-08 10:12:44 +01:00
|
|
|
def bottle?
|
2014-07-31 16:32:04 -05:00
|
|
|
include? "build-bottle"
|
2013-10-08 10:12:44 +01:00
|
|
|
end
|
|
|
|
|
2013-01-23 00:26:23 -06:00
|
|
|
def head?
|
2014-07-31 16:32:04 -05:00
|
|
|
include? "HEAD"
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def devel?
|
2014-07-31 16:32:04 -05:00
|
|
|
include? "devel"
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def stable?
|
2015-08-03 13:09:07 +01:00
|
|
|
!(head? || devel?)
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
# True if the user requested a universal build.
|
|
|
|
def universal?
|
2014-08-16 01:33:41 -05:00
|
|
|
include?("universal") && option_defined?("universal")
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
|
|
|
|
2013-10-07 00:40:32 -07:00
|
|
|
# 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")
|
2013-10-07 00:40:32 -07:00
|
|
|
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
|
2014-08-13 11:09:57 -05:00
|
|
|
@options & @args
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def unused_options
|
2014-08-13 11:09:57 -05:00
|
|
|
@options - @args
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|
2014-07-31 19:37:39 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def option_defined?(name)
|
2014-07-31 19:37:39 -05:00
|
|
|
@options.include? name
|
|
|
|
end
|
2013-01-23 00:26:23 -06:00
|
|
|
end
|