diff options
| author | Jack Nagel | 2013-01-26 17:55:07 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-01-26 18:20:36 -0600 |
| commit | f62762b3abc198a927ede15df146f2b40cb86b59 (patch) | |
| tree | 0cb1d916751476421484cc6a38aee810a6b47b3f /Library/Homebrew | |
| parent | 036f3e7bfc7332cf487920cd05383f7bc378dddb (diff) | |
| download | brew-f62762b3abc198a927ede15df146f2b40cb86b59.tar.bz2 | |
Generate options immediately following depends_on
Given
depends_on 'gnutls' => :recommended
depends_on 'libgcrypt' unless build.without? 'gnutls'
the dependency on libgcrypt should be enabled by default. However, the
corresponding option has not yet been generated, so the condition is
true and the dependency is disabled.
Instead, add a hook method that fires after each depends_on and adds the
appropriate option.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/formula.rb | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 7af0989a7..9c70f0210 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -420,8 +420,6 @@ class Formula raise NameError if !klass.ancestors.include? Formula - klass.finalize_dsl - return klass.new(name) if install_type == :from_name return klass.new(name, path.to_s) rescue NoMethodError @@ -743,6 +741,7 @@ private def depends_on dep dependencies.add(dep) + post_depends_on end def option name, description=nil @@ -805,20 +804,15 @@ private @test = block end - # This method is called once by `factory` before creating any instances. - # It allows the DSL to finalize itself, reducing complexity in the constructor. - def finalize_dsl - # Synthesize options for optional dependencies - dependencies.deps.select(&:optional?).each do |dep| - unless build.has_option? "with-#{dep.name}" - option "with-#{dep.name}", "Build with #{dep.name} support" - end - end + private - # Synthesize options for recommended dependencies - dependencies.deps.select(&:recommended?).each do |dep| - unless build.has_option? "without-#{dep.name}" - option "without-#{dep.name}", "Build without #{dep.name} support" + def post_depends_on + # Generate with- and without- options for optional and recommended deps + dependencies.deps.each do |dep| + if dep.optional? && !build.has_option?("with-#{dep.name}") + build.add("with-#{dep.name}", "Build with #{dep.name} support") + elsif dep.recommended? && !build.has_option?("without-#{dep.name}") + build.add("without-#{dep.name}", "Build without #{dep.name} support") end end end |
