diff options
| author | Jack Nagel | 2013-08-31 16:10:35 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-08-31 16:16:54 -0500 |
| commit | 0c75f2d280aa48a03d74b887a824fe783e4eeadc (patch) | |
| tree | 51e31c0aad10496b6d35970f69c61ea848e9cbc4 /Library/Homebrew | |
| parent | 6ed24d3877eca5b117924831ae3e3267123e0675 (diff) | |
| download | brew-0c75f2d280aa48a03d74b887a824fe783e4eeadc.tar.bz2 | |
Push dependency option generation into BuildOptions
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/build_options.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 15 |
2 files changed, 10 insertions, 14 deletions
diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb index 18285a7a5..0cd3a5a46 100644 --- a/Library/Homebrew/build_options.rb +++ b/Library/Homebrew/build_options.rb @@ -20,6 +20,15 @@ class BuildOptions @options << Option.new(name, description) end + def add_dep_option(dep) + name = dep.name.split("/").last # strip any tap prefix + if dep.optional? && !has_option?("with-#{name}") + add("with-#{name}", "Build with #{name} support") + elsif dep.recommended? && !has_option?("without-#{name}") + add("without-#{name}", "Build without #{name} support") + end + end + def has_option? name any? { |opt| opt.name == name } end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 888eefd9f..bbcb1dab2 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -692,7 +692,7 @@ class Formula def depends_on dep d = dependencies.add(dep) - post_depends_on(d) unless d.nil? + build.add_dep_option(d) unless d.nil? end def option name, description=nil @@ -754,19 +754,6 @@ class Formula @test_defined = true @test = block end - - private - - def post_depends_on(dep) - # Generate with- or without- options for optional and recommended - # dependencies and requirements - name = dep.name.split("/").last # strip any tap prefix - if dep.optional? && !build.has_option?("with-#{name}") - build.add("with-#{name}", "Build with #{name} support") - elsif dep.recommended? && !build.has_option?("without-#{name}") - build.add("without-#{name}", "Build without #{name} support") - end - end end end |
