Remove confusing implicit options handling
This code is supposed to allow depends_on "foo" => "with-bar" to work when foo has only a "without-bar" option. The options system was not designed to support this. Unfortunately, it was bolted on anyway. The implementation is extremely difficult to understand, and it only works for certain types of options, which is confusing from a user's point of view. Luckily, no formulae in core or the official taps rely on the behavior in order to function. It is hindering progress in improving this code, so I am removing it.
This commit is contained in:
parent
5ccce044ca
commit
fd86e6d636
@ -120,33 +120,4 @@ class BuildOptions
|
||||
def unused_options
|
||||
Options.new(@options - @args)
|
||||
end
|
||||
|
||||
# Some options are implicitly ON because they are not explictly turned off
|
||||
# by their counterpart option. This applies only to with-/without- options.
|
||||
# implicit_options are needed because `depends_on 'spam' => 'with-stuff'`
|
||||
# complains if 'spam' has stuff as default and only defines `--without-stuff`.
|
||||
def implicit_options
|
||||
implicit = unused_options.map do |option|
|
||||
opposite_of option unless has_opposite_of? option
|
||||
end.compact
|
||||
Options.new(implicit)
|
||||
end
|
||||
|
||||
def has_opposite_of? option
|
||||
@options.include? opposite_of(option)
|
||||
end
|
||||
|
||||
def opposite_of option
|
||||
option = Option.new(option) unless Option === option
|
||||
|
||||
if option.name =~ /^with-(.+)$/
|
||||
Option.new("without-#{$1}")
|
||||
elsif option.name =~ /^without-(.+)$/
|
||||
Option.new("with-#{$1}")
|
||||
elsif option.name =~ /^enable-(.+)$/
|
||||
Option.new("disable-#{$1}")
|
||||
elsif option.name =~ /^disable-(.+)$/
|
||||
Option.new("enable-#{$1}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -46,7 +46,6 @@ class Dependency
|
||||
def missing_options(inherited_options=[])
|
||||
missing = options | inherited_options
|
||||
missing -= Tab.for_formula(to_formula).used_options
|
||||
missing -= to_formula.build.implicit_options
|
||||
missing
|
||||
end
|
||||
|
||||
|
||||
@ -43,35 +43,6 @@ class BuildOptionsTests < Homebrew::TestCase
|
||||
assert_includes @build.unused_options, "--without-baz"
|
||||
end
|
||||
|
||||
def test_implicit_options
|
||||
# --without-baz is not explicitly specified on the command line (i.e. args)
|
||||
# therefore --with-baz should be implicitly assumed:
|
||||
assert_includes @build.implicit_options, "--with-baz"
|
||||
# But all these should not be in the implict_options:
|
||||
refute_includes @build.implicit_options, "--without-baz"
|
||||
refute_includes @build.implicit_options, "--with-bar"
|
||||
refute_includes @build.implicit_options, "--without-bar"
|
||||
refute_includes @build.implicit_options, "--with-qux"
|
||||
end
|
||||
|
||||
def test_opposite_of
|
||||
assert_equal Option.new("without-foo"), @build.opposite_of(Option.new("with-foo"))
|
||||
assert_equal Option.new("with-foo"), @build.opposite_of("without-foo")
|
||||
assert_equal Option.new("disable-spam"), @build.opposite_of(Option.new("enable-spam"))
|
||||
assert_equal Option.new("enable-beer"), @build.opposite_of("disable-beer")
|
||||
end
|
||||
|
||||
def test_has_opposite_of?
|
||||
assert @build.has_opposite_of?("--without-foo")
|
||||
assert @build.has_opposite_of?(Option.new("--with-qux"))
|
||||
assert !@build.has_opposite_of?("--without-qux")
|
||||
assert !@build.has_opposite_of?("--without-nonexisting")
|
||||
end
|
||||
|
||||
def test_actually_recognizes_implicit_options
|
||||
assert @build.has_opposite_of?("--with-baz")
|
||||
end
|
||||
|
||||
def test_copies_do_not_share_underlying_options
|
||||
orig = BuildOptions.new []
|
||||
copy = orig.dup
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user