diff options
| author | ilovezfs | 2016-05-08 06:02:05 -0700 |
|---|---|---|
| committer | ilovezfs | 2016-06-11 01:26:28 -0700 |
| commit | 6367508454ccd53d742f104d87ac8347efa7f441 (patch) | |
| tree | 39b5d62155a9779d324cc138161deea4a04c803e /Library/Homebrew/cmd | |
| parent | 11d47e8325f50ab7993f3fca0432876da0ea1c11 (diff) | |
| download | brew-6367508454ccd53d742f104d87ac8347efa7f441.tar.bz2 | |
deps should respect skip-recommended
For example, `brew deps libass --skip-recommended` shouldn't print
harfbuzz because, even though libass builds with harfbuzz when harfbuzz
is not skipped, we asked to skip recommended, of which harfbuzz is one.
The corresponding change is made for `brew uses` as well.
Thanks to Xu Cheng for contributing the code. Any errors are mine.
Closes #129.
Signed-off-by: ilovezfs <ilovezfs@icloud.com>
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/deps.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/uses.rb | 16 |
2 files changed, 28 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index 4c5dbb932..dfdd2d9f8 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -85,10 +85,22 @@ module Homebrew if recursive deps = f.recursive_dependencies do |dependent, dep| - Dependency.prune if ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } && !dependent.build.with?(dep) + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") + end end reqs = f.recursive_requirements do |dependent, req| - Requirement.prune if ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } && !dependent.build.with?(req) + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end end else deps = f.deps.reject do |dep| diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index 045e0a94f..ff7f7529e 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -48,10 +48,22 @@ module Homebrew begin if recursive deps = f.recursive_dependencies do |dependent, dep| - Dependency.prune if ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } && !dependent.build.with?(dep) + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") + end end reqs = f.recursive_requirements do |dependent, req| - Requirement.prune if ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } && !dependent.build.with?(req) + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end end deps.any? { |dep| dep.to_formula.full_name == ff.full_name rescue dep.name == ff.name } || reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) } |
