Ensure option names are consistent for default formula requirements

This commit is contained in:
Jack Nagel 2013-12-09 14:36:10 -06:00
parent 901902b53b
commit 08055e1776
5 changed files with 18 additions and 10 deletions

View File

@ -81,7 +81,7 @@ class Build
def expand_reqs
f.recursive_requirements do |dependent, req|
if (req.optional? || req.recommended?) && dependent.build.without?(req.name)
if (req.optional? || req.recommended?) && dependent.build.without?(req)
Requirement.prune
elsif req.build? && dependent != f
Requirement.prune
@ -94,7 +94,7 @@ class Build
def expand_deps
f.recursive_dependencies do |dependent, dep|
if (dep.optional? || dep.recommended?) && dependent.build.without?(dep.name)
if (dep.optional? || dep.recommended?) && dependent.build.without?(dep)
Dependency.prune
elsif dep.build? && dependent != f
Dependency.prune

View File

@ -61,7 +61,13 @@ class BuildOptions
args.include? '--' + name
end
def with? name
def with? val
if val.respond_to?(:option_name)
name = val.option_name
else
name = val
end
if has_option? "with-#{name}"
include? "with-#{name}"
elsif has_option? "without-#{name}"

View File

@ -5,10 +5,10 @@ class Dependency
include Dependable
attr_reader :name, :tags
attr_accessor :env_proc
attr_accessor :env_proc, :option_name
def initialize(name, tags=[])
@name = name
@name = @option_name = name
@tags = tags
end
@ -97,7 +97,7 @@ class Dependency
if block_given?
yield dependent, dep
elsif dep.optional? || dep.recommended?
prune unless dependent.build.with?(dep.name)
prune unless dependent.build.with?(dep)
end
end
end

View File

@ -180,7 +180,7 @@ class FormulaInstaller
def check_requirements
unsatisfied = ARGV.filter_for_dependencies do
f.recursive_requirements do |dependent, req|
if (req.optional? || req.recommended?) && dependent.build.without?(req.name)
if (req.optional? || req.recommended?) && dependent.build.without?(req)
Requirement.prune
elsif req.build? && install_bottle?(dependent)
Requirement.prune
@ -208,7 +208,7 @@ class FormulaInstaller
Dependency.expand(f, deps) do |dependent, dep|
dep.universal! if f.build.universal? && !dep.build?
if (dep.optional? || dep.recommended?) && dependent.build.without?(dep.name)
if (dep.optional? || dep.recommended?) && dependent.build.without?(dep)
Dependency.prune
elsif dep.build? && dependent == f && pour_bottle
Dependency.prune

View File

@ -10,12 +10,13 @@ class Requirement
include Dependable
extend BuildEnvironmentDSL
attr_reader :tags, :name
attr_reader :tags, :name, :option_name
def initialize(tags=[])
@tags = tags
@tags << :build if self.class.build
@name ||= infer_name
@option_name = @name
end
# The message to show when the requirement is not met.
@ -70,6 +71,7 @@ class Requirement
f = self.class.default_formula
raise "No default formula defined for #{inspect}" if f.nil?
dep = Dependency.new(f, tags)
dep.option_name = name
dep.env_proc = method(:modify_build_environment)
dep
end
@ -174,7 +176,7 @@ class Requirement
if block_given?
yield dependent, req
elsif req.optional? || req.recommended?
prune unless dependent.build.with?(req.name)
prune unless dependent.build.with?(req)
end
end
end