From 793d6de6c3211ffea112770081e788e760806366 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 27 Feb 2014 14:22:43 -0600 Subject: [PATCH] Pass expansion-time build options to install_dependency --- Library/Homebrew/dependency.rb | 11 +++++++---- Library/Homebrew/exceptions.rb | 4 ++-- Library/Homebrew/formula_installer.rb | 26 ++++++++++++++++++-------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 8ddeb90fd2..02d981b012 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -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! diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index f88b6fc571..6829c17a9d 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index e7c8ff0e73..3f3f722351 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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