Pass expansion-time build options to install_dependency

This commit is contained in:
Jack Nagel 2014-02-27 14:22:43 -06:00
parent 97dd879159
commit 793d6de6c3
3 changed files with 27 additions and 14 deletions

View File

@ -36,12 +36,15 @@ class Dependency
to_formula.installed? to_formula.installed?
end end
def satisfied? def satisfied?(inherited_options)
installed? && missing_options.empty? installed? && missing_options(inherited_options).empty?
end end
def missing_options def missing_options(inherited_options=[])
options - Tab.for_formula(to_formula).used_options - to_formula.build.implicit_options missing = options | inherited_options
missing -= Tab.for_formula(to_formula).used_options
missing -= to_formula.build.implicit_options
missing
end end
def universal! def universal!

View File

@ -92,10 +92,10 @@ class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError
end end
class UnsatisfiedDependencyError < Homebrew::InstallationError class UnsatisfiedDependencyError < Homebrew::InstallationError
def initialize(f, dep) def initialize(f, dep, inherited_options)
super f, <<-EOS.undent super f, <<-EOS.undent
#{f} dependency #{dep} not installed with: #{f} dependency #{dep} not installed with:
#{dep.missing_options * ', '} #{dep.missing_options(inherited_options) * ', '}
EOS EOS
end end
end end

View File

@ -239,9 +239,11 @@ class FormulaInstaller
# because it depends on the contents of ARGV. # because it depends on the contents of ARGV.
pour_bottle = pour_bottle? pour_bottle = pour_bottle?
ARGV.filter_for_dependencies do inherited_options = {}
expanded_deps = ARGV.filter_for_dependencies do
Dependency.expand(f, deps) do |dependent, dep| Dependency.expand(f, deps) do |dependent, dep|
dep.universal! if f.build.universal? && !dep.build? options = inherited_options[dep] = inherited_options_for(f, dep)
if (dep.optional? || dep.recommended?) && dependent.build.without?(dep) if (dep.optional? || dep.recommended?) && dependent.build.without?(dep)
Dependency.prune Dependency.prune
@ -249,35 +251,43 @@ class FormulaInstaller
Dependency.prune Dependency.prune
elsif dep.build? && dependent != f && install_bottle?(dependent) elsif dep.build? && dependent != f && install_bottle?(dependent)
Dependency.prune Dependency.prune
elsif dep.satisfied? elsif dep.satisfied?(options)
Dependency.skip Dependency.skip
elsif dep.installed? elsif dep.installed?
raise UnsatisfiedDependencyError.new(f, dep) raise UnsatisfiedDependencyError.new(f, dep, options)
end end
end end
end end
expanded_deps.map { |dep| [dep, inherited_options[dep]] }
end
def inherited_options_for(f, dep)
options = Options.new
options << Option.new("universal") if f.build.universal? && !dep.build?
options
end end
def install_dependencies(deps) def install_dependencies(deps)
if deps.length > 1 if deps.length > 1
oh1 "Installing dependencies for #{f}: #{Tty.green}#{deps*", "}#{Tty.reset}" oh1 "Installing dependencies for #{f}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}"
end end
ARGV.filter_for_dependencies do ARGV.filter_for_dependencies do
deps.each { |dep| install_dependency(dep) } deps.each { |dep, options| install_dependency(dep, options) }
end end
@show_header = true unless deps.empty? @show_header = true unless deps.empty?
end end
def install_dependency dep def install_dependency(dep, inherited_options)
df = dep.to_formula df = dep.to_formula
outdated_keg = Keg.new(df.linked_keg.realpath) rescue nil outdated_keg = Keg.new(df.linked_keg.realpath) rescue nil
fi = FormulaInstaller.new(df) fi = FormulaInstaller.new(df)
fi.tab = Tab.for_formula(dep.to_formula) fi.tab = Tab.for_formula(dep.to_formula)
fi.options = dep.options fi.options = dep.options | inherited_options
fi.ignore_deps = true fi.ignore_deps = true
fi.only_deps = false fi.only_deps = false
fi.show_header = false fi.show_header = false