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 def expand_reqs
f.recursive_requirements do |dependent, req| 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 Requirement.prune
elsif req.build? && dependent != f elsif req.build? && dependent != f
Requirement.prune Requirement.prune
@ -94,7 +94,7 @@ class Build
def expand_deps def expand_deps
f.recursive_dependencies do |dependent, dep| 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 Dependency.prune
elsif dep.build? && dependent != f elsif dep.build? && dependent != f
Dependency.prune Dependency.prune

View File

@ -61,7 +61,13 @@ class BuildOptions
args.include? '--' + name args.include? '--' + name
end 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}" if has_option? "with-#{name}"
include? "with-#{name}" include? "with-#{name}"
elsif has_option? "without-#{name}" elsif has_option? "without-#{name}"

View File

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

View File

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

View File

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