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?
end
def satisfied?
installed? && missing_options.empty?
def satisfied?(inherited_options)
installed? && missing_options(inherited_options).empty?
end
def missing_options
options - Tab.for_formula(to_formula).used_options - to_formula.build.implicit_options
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
def universal!

View File

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

View File

@ -239,9 +239,11 @@ class FormulaInstaller
# because it depends on the contents of ARGV.
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|
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)
Dependency.prune
@ -249,35 +251,43 @@ class FormulaInstaller
Dependency.prune
elsif dep.build? && dependent != f && install_bottle?(dependent)
Dependency.prune
elsif dep.satisfied?
elsif dep.satisfied?(options)
Dependency.skip
elsif dep.installed?
raise UnsatisfiedDependencyError.new(f, dep)
raise UnsatisfiedDependencyError.new(f, dep, options)
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
def install_dependencies(deps)
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
ARGV.filter_for_dependencies do
deps.each { |dep| install_dependency(dep) }
deps.each { |dep, options| install_dependency(dep, options) }
end
@show_header = true unless deps.empty?
end
def install_dependency dep
def install_dependency(dep, inherited_options)
df = dep.to_formula
outdated_keg = Keg.new(df.linked_keg.realpath) rescue nil
fi = FormulaInstaller.new(df)
fi.tab = Tab.for_formula(dep.to_formula)
fi.options = dep.options
fi.options = dep.options | inherited_options
fi.ignore_deps = true
fi.only_deps = false
fi.show_header = false